Modulo:Identificativo radio: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
m fix |
||
(2 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 1: | Riga 1: | ||
-- Modulo per implementare le funzionalità di infobox |
-- Modulo per implementare le funzionalità di infobox |
||
local p = {} -- per l'esportazione delle funzioni del modulo |
local p = {} -- per l'esportazione delle funzioni del modulo |
||
local HtmlBuilder = require('Module:HtmlBuilder') -- richiesto per la costruzione del markup html |
|||
local args={} -- variabile che contiene gli argomenti passati al template |
local args={} -- variabile che contiene gli argomenti passati al template |
||
Riga 52: | Riga 50: | ||
-- Esclude lettere non corrispondenti a una bandiera |
-- Esclude lettere non corrispondenti a una bandiera |
||
if not args.codice then return '' end |
if not args.codice then return '' end |
||
root = |
root = mw.html.create('span') |
||
local codice = string.upper(args.codice) |
local codice = string.upper(args.codice) |
||
local extended_code = {} |
local extended_code = {} |
||
local flags = |
local flags = mw.html.create('') |
||
for letter in codice:gmatch(".") do |
for letter in codice:gmatch(".") do |
||
if icao_table[letter] then |
if icao_table[letter] then |
||
flags |
flags |
||
:tag('span') |
|||
:css('padding', '0 2px 0') |
|||
:wikitext('[[File:' .. icao_table[letter][2] .. '|' .. tostring(args.dimensione) |
|||
.. 'px|Bandiera ' .. icao_table[letter][1] .. ']]') |
.. 'px|Bandiera ' .. icao_table[letter][1] .. ']]') |
||
table.insert(extended_code, letter) |
table.insert(extended_code, letter) |
||
Riga 68: | Riga 66: | ||
if #extended_code == 0 then return '' end |
if #extended_code == 0 then return '' end |
||
root |
root |
||
:wikitext(table.concat(extended_code) .. ' ') |
|||
:node(flags) |
|||
return tostring(root) |
return tostring(root) |
||
end |
end |
||
Riga 78: | Riga 76: | ||
-- più sotto il codice per esteso) |
-- più sotto il codice per esteso) |
||
if not args.codice then return '' end |
if not args.codice then return '' end |
||
root = |
root = mw.html.create('div') |
||
root |
root |
||
:css('text-align', 'center') |
|||
local codice = string.upper(args.codice) |
local codice = string.upper(args.codice) |
||
local extended_code = {} |
local extended_code = {} |
||
local inner_div = |
local inner_div = mw.html.create('div') |
||
for letter in codice:gmatch(".") do |
for letter in codice:gmatch(".") do |
||
if icao_table[letter] then |
if icao_table[letter] then |
||
inner_div |
inner_div |
||
:tag('div') |
|||
:css('float', 'left') |
|||
:css('padding', '0 8px 0;') |
|||
:wikitext('[[File:' .. icao_table[letter][2] .. '|' .. tostring(args.dimensione) .. 'px|Bandiera ' .. icao_table[letter][1] .. ']]') |
|||
:tag('br', {selfClosing=true}) |
|||
:done() |
|||
:wikitext(letter) |
|||
table.insert(extended_code, icao_table[letter][1]) |
table.insert(extended_code, icao_table[letter][1]) |
||
end |
end |
||
Riga 98: | Riga 97: | ||
if #extended_code == 0 then return '' end |
if #extended_code == 0 then return '' end |
||
inner_div |
inner_div |
||
:css('width', tostring((args.dimensione+16)*#extended_code+16).. 'px') |
|||
:css('margin-left', 'auto') |
|||
:css('margin-right', 'auto') |
|||
root |
root |
||
:node(inner_div) |
|||
:tag('div') |
|||
:css('font-size', '80%') |
|||
:css('clear', 'both') |
|||
:wikitext("(''" .. table.concat(extended_code, '-') .. "'')") |
|||
return tostring(root) |
return tostring(root) |
||
end |
end |
Versione delle 15:58, 19 feb 2014
Istruzioni per l'uso
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Identificativo radio/man (modifica · cronologia)
Sandbox: Modulo:Identificativo radio/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:Identificativo radio/test (modifica · cronologia · Esegui)
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Identificativo radio/man (modifica · cronologia)
Sandbox: Modulo:Identificativo radio/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:Identificativo radio/test (modifica · cronologia · Esegui)
Modulo per inserire l'Indicativo di chiamata nell'infobox di una nave
-- Modulo per implementare le funzionalità di infobox
local p = {} -- per l'esportazione delle funzioni del modulo
local args={} -- variabile che contiene gli argomenti passati al template
local icao_table = {
A = {'Alfa', 'Alpha.svg'},
B = {'Bravo', 'Bravo.svg'},
C = {'Charlie', 'Charlie.svg'},
D = {'Delta', 'Delta.svg'},
E = {'Echo', 'Echo.svg'},
F = {'Foxtrot', 'Foxtrot.svg'},
G = {'Golf', 'Golf.svg'},
H = {'Hotel', 'Hotel.svg'},
I = {'India', 'India.svg'},
J = {'Juliet', 'Juliet.svg'},
K = {'Kilo', 'Kilo.svg'},
L = {'Lima', 'Lima.svg'},
M = {'Mike', 'Mike.svg'},
N = {'November', 'November.svg'},
O = {'Oscar', 'Oscar.svg'},
P = {'Papa', 'Papa.svg'},
Q = {'Quebec', 'Quebec.svg'},
R = {'Romeo', 'Romeo.svg'},
S = {'Sierra', 'Sierra.svg'},
T = {'Tango', 'Tango.svg'},
U = {'Uniform', 'Uniform.svg'},
V = {'Victor', 'Victor.svg'},
W = {'Whiskey', 'Whiskey flag.svg'},
X = {'X-ray', 'Xray.svg'},
Y = {'Yankee', 'Yankee.svg'},
Z = {'Zulu', 'Zulu.svg'},
['1'] = {'Unaone', 'ICS Pennant One.svg'},
['2'] = {'Bissotwo', 'ICS Pennant Two.svg'},
['3'] = {'Terrathree', 'ICS Pennant Three.svg'},
['4'] = {'Kartefour', 'ICS Pennant Four.svg'},
['5'] = {'Pantafive', 'ICS Pennant Five.svg'},
['6'] = {'Soxisix', 'ICS Pennant Six.svg'},
['7'] = {'Setteseven', 'ICS Pennant Seven.svg'},
['8'] = {'Oktoeight', 'ICS Pennant Eight.svg'},
['9'] = {'Novenine', 'ICS Pennant Niner.svg'},
['0'] = {'Nadazero', 'ICS Pennant Zero.svg'},
}
local parametri_nominati = { 'codice', 'compatto', 'dimensione'}
local function _identificativo_radio_compatto()
-- Restituisce l'identificativo radio come seguenza compatta inlinea
-- formata dalle lettere del codice seguita dalle bandiere.
-- Esclude lettere non corrispondenti a una bandiera
if not args.codice then return '' end
root = mw.html.create('span')
local codice = string.upper(args.codice)
local extended_code = {}
local flags = mw.html.create('')
for letter in codice:gmatch(".") do
if icao_table[letter] then
flags
:tag('span')
:css('padding', '0 2px 0')
:wikitext('[[File:' .. icao_table[letter][2] .. '|' .. tostring(args.dimensione)
.. 'px|Bandiera ' .. icao_table[letter][1] .. ']]')
table.insert(extended_code, letter)
end
end
if #extended_code == 0 then return '' end
root
:wikitext(table.concat(extended_code) .. ' ')
:node(flags)
return tostring(root)
end
local function _identificativo_radio()
-- Restituisce l'identificativo radio come tabella per l'inserimento
-- nel template infobox nave (bandiere con sotto la lettera e ancora
-- più sotto il codice per esteso)
if not args.codice then return '' end
root = mw.html.create('div')
root
:css('text-align', 'center')
local codice = string.upper(args.codice)
local extended_code = {}
local inner_div = mw.html.create('div')
for letter in codice:gmatch(".") do
if icao_table[letter] then
inner_div
:tag('div')
:css('float', 'left')
:css('padding', '0 8px 0;')
:wikitext('[[File:' .. icao_table[letter][2] .. '|' .. tostring(args.dimensione) .. 'px|Bandiera ' .. icao_table[letter][1] .. ']]')
:tag('br', {selfClosing=true})
:done()
:wikitext(letter)
table.insert(extended_code, icao_table[letter][1])
end
end
if #extended_code == 0 then return '' end
inner_div
:css('width', tostring((args.dimensione+16)*#extended_code+16).. 'px')
:css('margin-left', 'auto')
:css('margin-right', 'auto')
root
:node(inner_div)
:tag('div')
:css('font-size', '80%')
:css('clear', 'both')
:wikitext("(''" .. table.concat(extended_code, '-') .. "'')")
return tostring(root)
end
function p.codice(frame)
args['codice'] = frame.args[1]
if frame.args[2] and frame.args[2] ~= '' then
args['compatto'] = true
else
args['compatto'] = false
end
args['dimensione'] = tonumber(frame.args[3]) or 15
if args.compatto then
return _identificativo_radio_compatto()
else
return _identificativo_radio()
end
end
return p