Modulo:Partiti: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
aggiungo una funzione specializzata per il template elezioni |
m Modificate le impostazioni di protezione per "Modulo:Partiti": Template o modulo usato in maniera estensiva ([Modifica=Consentito solo agli amministratori] (infinito) [Spostamento=Consentito solo agli amministratori] (infinito)) |
||
(35 versioni intermedie di 5 utenti non mostrate) | |||
Riga 5:
-- corregge un valore di ritorno se questo inizia per '#'
-- vedi bug https://phabricator.wikimedia.org/T14974
--
-- =====================================================
local function fix_return(colore)
Riga 24:
local x2 = mw.ustring.find(b,'%|')
local x3 = mw.ustring.find(b,'%]%]')
local x4 = mw.ustring.find(b,'%<s')
local x5 = mw.ustring.find(b,'%–')
if (x3) then
if (x4) then
a=mw.ustring.sub(a,x1,x3+x1)
end
if (x5) then
a=mw.ustring.sub(a,x1,x3+x1)
end
if (x2) then
a = mw.ustring.sub(a,x1+2,x2+x1)
Line 32 ⟶ 40:
end
end
a = mw.text.decode(a)
return a
end
Line 72 ⟶ 81:
if args.coalizione then
local try_colore_coalizione =_colore(args.coalizione)
if try_colore_coalizione and try_colore_coalizione ~='' then return try_colore_coalizione end
end
if args.partito then return _colore(args.partito) end
if args.gruppo then return _colore(args.gruppo) end
if args.coll then return _colore(args.coll) end
return ''
end
Line 115 ⟶ 126:
cls[3] = 255 - math.floor((255-cls[3])*opac)
return string.format('#%02x%02x%02x',cls[1],cls[2],cls[3])
end
-- ==========================================================
-- Converte codice hex in rgb percentuale
-- ==========================================================
local function codice(frame)
local args = getArgs(frame, {frameOnly = true})
local col = _colore(args[1], args[2])
local rgb = col:sub(6)
return (rgb:sub(1,6))
end
local function cod(frame)
local args = getArgs(frame, {frameOnly = true})
local col = _colore(args[1], args[2])
local rgb = col:sub(6)
local cls = {}
if (rgb:len() == 6) then
cls[1] = tonumber(rgb:sub(1,2),16) or 255
cls[2] = tonumber(rgb:sub(3,4),16) or 255
cls[3] = tonumber(rgb:sub(5,6),16) or 255
end
cls[1] = math.floor(cls[1]/255)
cls[2] = math.floor(cls[2]/255)
cls[3] = math.floor(cls[3]/255)
return string.format('%02x%02x%02x',cls[1],cls[2],cls[3])
end
Line 182 ⟶ 219:
color_table = color_table,
colore_ombra = colore_ombra,
sfondo = sfondo,
codice = codice,
cod = cod
}
|