Module:Zandbak/Hole1988
Uiterlijk
Documentatie voor deze module kan aangemaakt worden op de volgende pagina: Module:Zandbak/Hole1988/doc
local p = {}
function nul(nr)
if nr == nil then
return 0
else
return nr
end
end
function parse(time)
if(time == nil or string.len(time) == 0) then return 0 end
s, h = string.match(time, "(%d+),(%d+)")
m = string.match(time, "(%d+)%.")
m = nul(m)
s = nul(s)
h = nul(h)
return ((m*60)+s) .. "." .. h
end
dbpos = {
["500"] = 1,
["1000"] = 2,
["1500"] = 3,
["3000"] = 4,
["5000"] = 5,
["10000"] = 6,
["Achtervolging"] = 10,
["2X500"] = 20,
["Sprint"] = 30,
["Mini"] = 40,
["Kleine"] = 50,
["Grote"] = 60
}
punt = {}
punt.V = 0
punt.M = 0
function creattable(t,a,g,frame)
table.insert(t,"{| class=\"wikitable\"\n")
if g == "V" then table.insert(t,"|+ vrouwen\n")
elseif g == "M" then table.insert(t,"|+ mannen\n")
end
table.insert(t,"!Afstand || Schaatser || Land || Tijd || Datum\n")
local d = {}
local c = {}
for key,value in pairs(a) do
if dbpos[key] then table.insert(d, key)
else table.insert(c, key) end
end
table.sort(d,function(a,b)
return tonumber(dbpos[b]) > tonumber(dbpos[a])
end)
table.sort(c)
for i,n in ipairs(c) do table.insert(d,n) end
for i,n in ipairs(d) do
if (g == "V" and n == "10000") or (g == "M" and n == "3000") then
table.insert(t,"|- bgcolor=FF4500\n")
else
table.insert(t,"|-\n")
if a[n].Tijd and tonumber(n) and n%500 == 0 then
punt[g] = punt[g]+(parse(a[n].Tijd)/(n/500))
end
end
if tonumber(n) and n%500 == 0 then table.insert(t,"| "..n.." m || ")
else table.insert(t,"| "..n.." || ")
end
if a[n].Naam then table.insert(t,a[n].Naam) end
table.insert(t," || ")
if a[n].Land then table.insert(t,frame:preprocess("{{"..a[n].Land.."}}")) end
table.insert(t," || ")
if a[n].Tijd then table.insert(t,a[n].Tijd) end
table.insert(t," || ")
if a[n].Datum then table.insert(t,a[n].Datum) end
table.insert(t,"\n")
end
if Args.punten then table.insert(t,"|-\n|colspan=\"3\"| '''puntentotaal\n|colspan=\"2\"| '''"..string.format("%.3f",punt[g]).."\n") end
table.insert(t,"|}\n")
return t
end
Args = {}
function p.main(frame)
Args = frame.args
t = {}
local r = {}
r.V = {}
r.M = {}
for key,value in pairs(Args) do
g,a,p = string.match(key, "([^_]*)_(.*)_([^_]*)")
if g and a and p then
if r[g][a] == nil then
r[g][a] = {}
--table.insert(v,a)
end
r[g][a][p] = value
end
end
table.insert(t,"{|\n|\n")
if table.getn(r.V) then t = creattable(t,r.V,"V",frame) end
if table.getn(r.V) and table.getn(r.M) then table.insert(t,"| width=\"50px\" |\n|\n") end
if table.getn(r.M) then t = creattable(t,r.M,"M",frame) end
if table.getn(r.V) and table.getn(r.M) and Args.punten then
table.insert(t,"|-\n|colspan=\"2\"| '''gezamenlijk puntentotaal || '''"..string.format("%.3f",punt.V+punt.M).."\n")
end
return table.concat(t).."|}"
end
return p