Module:Sandbox/Gpmat/test

local p = {} local getArgs = require('Module:Arguments').getArgs local colori = { ["1"] = "FFFFBF", ["2"] = "DFDFDF", ["3"] = "FFDF9F", Ret = "EFCFFF", DNQ = "EFCFCF", DNS = "FFFFFF", punti = "DFFFDF", nopunti = "CFCFFF", [0] = "" } local soglia = { [1] = 5, [2] = 6, [3] = 8, [4] = 10 }

function p.tabella(frame) local args = getArgs(frame)

local count = 0 for _ in pairs(args) do count = count + 1 end

local str = "{| class=\"wikitable\" style=\"text-align:center; font-size:85%; width:100%; margin-top:0em; margin-bottom:0em\"\n|-\n"

for i=1,count do str = str .. "!" .. args[i] if i~=count then str = str .. "!" end end

str = str .. "\n|}"

return str end

function p.main(frame) local args = getArgs(frame) local res = args[1] local anno = tonumber(args[2])

if res == nil then res = 0 end

local res2 = string.gsub(res,"'","")

if anno < 1960 then format = 1 elseif anno < 2003 then format = 2 elseif anno < 2010 then format = 3 else format = 4 end

if tonumber(res2) ~= nil and tonumber(res2) > 3 then if tonumber(res2) < soglia[format]+1 then res2 = "punti" else res2 = "nopunti" end end

local colore = colori[res2]

if colore == nil then colore = "" end

return "style=\"padding-left:0px;padding-right:0px;background-color:#" .. colore .. "\"" end

function p.render(frame) local args = getArgs(frame) local res = args[1] local apici = args[2]

if apici == "PG" or apici == "GV" then res = "''" .. res .. "''" end if apici == "PG" or apici == "PP" then res = "'''" .. res .. "'''" end

return res

end

function p.pippo(frame) local div = mw.html.create( 'td' ) div :attr( 'id', 'testdiv' ) :css( 'width', '100%' ) :wikitext( 'Some text' ) return tostring( div ) end

return p