Modulo:Infobox/sandbox: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Test parametro posizione |
||
(10 versioni intermedie di 2 utenti non mostrate) | |||
Riga 2:
local p = {} -- per l'esportazione delle funzioni del modulo
local args = {}
local origArgs
local root -- radice del markup html
local dump = {}
Riga 13:
valore = '<div>\n' .. valore .. '\n</div>'
end
return valore .. '\n'
end
Riga 45:
:tag('th')
:attr('colspan', 2)
:cssText(rowArgs.
:wikitext(rowArgs.gruppo)
-- Altrimenti se rowArgs.valore non è nullo inserisce una riga dati, verificando
Riga 55:
row
:tag('th')
:cssText(rowArgs.stilenomeN or args.StileNome or
:wikitext(rowArgs.nome)
dataCell = row:tag('td')
Riga 64:
end
dataCell
:addClass(rowArgs.classe or
:cssText(rowArgs.stilevaloreN or args.StileValore or
:wikitext(checkList(rowArgs.valore))
end
Riga 76:
:tag('span')
:addClass('sinottico_sottotitolo')
:cssText(args.StileSopraTitolo or
:wikitext(args.SopraTitolo)
:done()
Riga 87:
:tag('span')
:addClass('sinottico_sottotitolo')
:cssText(args.StileSottoTitolo or
:wikitext(args.SottoTitolo)
end
Riga 94:
:tag('caption')
:addClass('sinottico_testata')
:cssText(args.StileTitoloEst or
:node(suptitle)
:wikitext(args.TitoloEst)
Riga 105:
:attr('colspan', '2')
:node(suptitle)
:cssText(args.StileTitoloInt or
:wikitext(args.TitoloInt)
:node(subtitle)
Riga 117:
:addClass('sinottico_testo_centrale ' .. (args.ClasseImmagine or ''))
:attr('colspan', '2')
:cssText(args.StileImmagine or
:wikitext(args.Immagine)
if args.Didascalia then
Riga 124:
:done()
:tag('span')
:cssText(args.StileDidascalia or
:wikitext(args.Didascalia)
end
Riga 132:
local function renderRows()
local rownums = getArgNums(
for k, num in ipairs(rownums) do
local skip = false
Riga 139:
for j = k+1, #rownums do
if args['Gruppo' .. rownums[j]] ~= nil or args['GruppoOpzionale' .. rownums[j]]~=nil then break end
if args['Valore' .. rownums[j]] ~= nil or args['Nodo' .. rownums[j]] ~= nil then
skip = false▼
end▼
if args['Obbligato' .. rownums[j]] then▼
skip = false
break
end
end
root:wikitext(args['Nodo' .. num])
end
if not skip and args['GruppoOpzionale' .. num] ~= '$fine' then
Riga 153:
gruppo = args['GruppoOpzionale' .. num] or args['Gruppo' .. num],
nome = args['Nome' .. num],
valore = args['Valore
classe = args['Classe' .. num],
stilenomeN = args['NomeStile' .. num],
stilevaloreN = args['ValoreStile' .. num]
})
end
Riga 168 ⟶ 170:
:attr('colspan', '2')
:addClass('sinottico_piede')
:cssText(args.StileUltima or
:wikitext(args.Ultima)
:newline()
Riga 190 ⟶ 192:
local function _infobox()
-- Crea l'albero html che rappresenta la tabella del sinottico e restituisce il markup
if args.CreaTable == 'no' or args.Posizione == 'corpo' or args.Posizione == 'coda' then
root = mw.html.create('')
else
root = mw.html.create('table')
root
:addClass('infobox sinottico')
:cssText(args.StileTabella or
:attr('summary', args.Summary or 'Tabella sinottica che riassume i principali dati del soggetto')
end
Riga 204 ⟶ 206:
renderLastRow()
renderNavBar()
if args.Posizione == 'coda' then
res = res .. '</table>';
elseif args.Posizione == 'testa' then
res = mw.ustring.gsub( res, '</table>$', '')
return res
end
local function preprocessSingleArg(argName
-- Se l'argomento esiste e non è una stringa vuota lo aggiunge alla tabella degli argomenti
-- Argomenti uguali a stringa vuota sono trattati come nulli come da comportamento
-- precedente del template {{Infobox}}
if origArgs[argName] and origArgs[argName] ~= '' then
▲ end
end
end
Riga 258 ⟶ 263:
for j,v in ipairs(prefixTable) do
local prefixArgName = v.prefix .. tostring(i)
if origArgs[prefixArgName]
moreArgumentsExist = true -- Aggiunge una passata se un parametro è stato trovato, anche se nullo.
preprocessSingleArg(prefixArgName)
Riga 266 ⟶ 271:
for j,dependValue in ipairs(v.depend) do
local dependArgName = dependValue .. tostring(i)
preprocessSingleArg(dependArgName
end
end
Riga 313 ⟶ 318:
preprocessSingleArg('StileValore')
preprocessArgs({
{prefix = 'Nodo'},
{prefix = 'Gruppo', depend={'GruppoStile'}},
{prefix = 'GruppoOpzionale', depend={'GruppoStile'}},
{prefix = 'Valore', depend={'Nome', 'Classe', '
}, 50)
preprocessSingleArg('Ultima')
Riga 322 ⟶ 328:
preprocessSingleArg('LinkWikidata')
preprocessSingleArg('CreaTable')
preprocessSingleArg('Posizione')
preprocessSingleArg('Summary')
return _infobox()
|