Modulo:Mapframe/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
inserimento parametro elenco
use require('strict') instead of require('Module:No globals')
 
(5 versioni intermedie di 2 utenti non mostrate)
Riga 1:
require('Module:No globalsstrict')
local getArgs = require('Module:Arguments').getArgs
local mWikidata = require('Module:Wikidata')
Riga 12:
end
 
local function agggetLegenda(tpoints, ...ncols)
local argsdivStyle = {...}
['column-count'] = ncols,
for _, s in ipairs(args) do
['-moz-column-count'] = ncols,
table.insert(t, s)
['-webkit-column-count'] = ncols
end
}
local divNode = mw.html.create('div'):css(divStyle)
local elenco_numcurrNum = 1
local elenco_lettcurrChar = 'A'
 
for _, spoint in ipairs(argspoints) do
local pNode = mw.html.create('p'):css('font-size', '90%')
local codeNode = mw.html.create('code')
:css('font-weight', 'bold')
:css('color', 'white')
:css('border-radius', '6px')
:css('border', '2px solid ' .. point.col)
:css('background', point.col)
if points[i]point.simb:find('-number') == 1 then
codeNode:wikitext(currNum)
currNum = currNum + 1
elseif points[i]point.simb:find('-letter') == 1 then
codeNode:wikitext(currChar)
elenco_lettcurrChar = ('ABCDEFGHIJKLMNOPQRSTUVWXYZA'):match(elenco_lettcurrChar .. '(.)')
elseif points[i]point.simb == '' then
else
codeNode
:css('padding-left', '0')
:css('padding-right', '0')
:css('background', 'white')
aggcodeNode:wikitext(elenco_dati, string.format('[[File:Maki2-%s-18.svg|18px]]',points[i] point.simb))
end
pNode:node(codeNode):wikitext(' ' .. point.nome)
divNode:node(pNode)
end
 
return tostring(divNode)
end
 
Line 27 ⟶ 59:
local gruppo = args.gruppo or ''
local autozoom = args.autozoom or 's'
local elenco = (args.elenco == '1' or args.elenco == '2') and args.elenco or nil
local dsimbolo = 'medium'
--if sinottico == 1 then dsimbolo = 'small' end
Line 32 ⟶ 65:
if args.cornice then cornice = tonumber(args.cornice) or 1 else cornice = 1 end
local lat1, lat2, lon1, lon2 = 400, -400, 400, -400
local elenco = tonumber(args.elenco) or 0
local elenco_dati = {}
local elenco_num = 1
local elenco_lett = 'A'
 
if args.didascalia then agg(elenco_dati, args.didascalia) end
 
if geo == -1 then
Line 69 ⟶ 96:
end
num = num + 1
end
if elenco == 2 then
agg(elenco_dati,'\n{| width="100%" style="font-size:90%"\n|-\n|width=50% valign=top|')
for i=1,#points do
agg(elenco_dati,string.format('<p style="border-left:4px solid %s">',points[i].col))
if points[i].simb:find('-number') == 1 then
agg(elenco_dati, string.format('&nbsp;<b>%d</b>)',elenco_num))
elenco_num = elenco_num+1
elseif points[i].simb:find('-letter') == 1 then
agg(elenco_dati, string.format('&nbsp;<b>%s</b>)',elenco_lett))
elenco_lett = ('ABCDEFGHIJKLMNOPQRSTUVWXYZA'):match(elenco_lett..'(.)')
elseif points[i].simb == '' then
else
agg(elenco_dati, string.format('[[File:Maki2-%s-18.svg|18px]])',points[i].simb))
end
agg(elenco_dati,string.format(' %s</p>',points[i].nome))
if (i == math.floor(#points/2 +0.5)) then agg(elenco_dati,'\n|width=50% valign=top|') end
end
agg(elenco_dati,'\n|}')
elseif elenco == 1 then
for i=1,#points do
agg(elenco_dati,string.format('<p style="font-size:90%%;border-left:4px solid %s">',points[i].col))
if points[i].simb:find('-number') == 1 then
agg(elenco_dati, string.format('&nbsp;<b>%d</b>)',elenco_num))
elenco_num = elenco_num+1
elseif points[i].simb:find('-letter') == 1 then
agg(elenco_dati, string.format('&nbsp;<b>%s</b>)',elenco_lett))
elenco_lett = ('ABCDEFGHIJKLMNOPQRSTUVWXYZA'):match(elenco_lett..'(.)')
elseif points[i].simb == '' then
else
agg(elenco_dati, string.format('[[File:Maki2-%s-18.svg|18px]]',points[i].simb))
end
agg(elenco_dati,string.format(' %s</p>',points[i].nome))
end
end
end
Line 151 ⟶ 144:
-- esclude didascalia per cornice = 0 e per sinottico = 1
if cornice == 1 and sinottico ~= 1 then
m_args.text = (args.didascalia or '') .. (elenco and getLegenda(points, elenco) or '')
m_args.text = mw.getCurrentFrame():preprocess(table.concat(elenco_dati))
end