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
db = {
pos = {["500"] = 1,
["1000"] = 2,
["1500"] = 3,
["3000"] = 4,
["5000"] = 5,
["10000"] = 6,
["Achtervolging"] = 10,
["2X500"] = 20,
["Sprint"] = 30,
["Mini"] = 40,
["Kleine"] = 50,
["Grote"] = 60
},
links = {["500"] = "500_meter_(schaatsen)",
["1000"] = "1000_meter_(schaatsen)",
["1500"] = "1500_meter_(schaatsen)",
["3000"] = "3000_meter_(schaatsen)",
["5000"] = "5000_meter_(schaatsen)",
["10000"] = "10.000_meter_(schaatsen)",
["Achtervolging"] = "Ploegenachtervolging_(schaatsen)",
["2X500"] = nil,
["Sprint"] = nil,
["Mini"] = nil,
["Kleine"] = "Kleine_vierkamp",
["Grote"] = "Grote_vierkamp"
},
name = {["500"] = "500 m",
["1000"] = "1000 m",
["1500"] = "1500 m",
["3000"] = "3000 m",
["5000"] = "5000 m",
["10000"] = "10.000 m",
["Achtervolging"] = "Ploegenachtervolging",
["2X500"] = nil,
["Sprint"] = nil,
["Mini"] = nil,
["Kleine"] = "Kleine Vierkamp",
["Grote"] = "Grote Vierkamp"
}
}
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 db.pos[key] then table.insert(d, key)
else table.insert(c, key) end
end
table.sort(d,function(a,b)
return tonumber(db.pos[b]) > tonumber(db.pos[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 Args.show_links and db.links[n] then table.insert(t,"| [["..db.name[n].."|"..db.links[n].."]] || ")
elseif db.name[n] then table.insert(t,"| "..db.name[n].." || ")
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
s = string.match(key, "show_(.*)")
if s and value ~= 1 then Args[key] = nil end
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