Modul:RO
Die Dokumentation für dieses Modul kann unter Modul:RO/Doku erstellt werden
local p = {}
function p.Anzahl(frame)
local page = frame.args[1]
title = mw.title .new(page)
pt = title:getContent()
local _, rq = string.gsub(pt, '{{:RO', '')
return rq
end
function p.next(frame)
local page = frame.args[1]
title = mw.title .new(page)
pt = title:getContent()
local match = os.date('%y')..'%-%d%d%-(%d%d+)'
local new = 1
for w in string.gmatch(pt, match) do
local num = tonumber(w)
if num >= new then
new = num + 1
end
end
local lv = tonumber(string.match(page, '%d+'))
local out = os.date('%y')..'-'..string.format("%02i", lv)..'-'..string.format("%02i", new)
return out
end
function p.punktesumme(frame)
return p.punktesumme2(frame.args[1], frame.args[2], frame.args[3])
end
function p.punktesumme2(ro,jahr,typ)
local page = 'RO:' .. ro
if jahr == nil or jahr == "" then
jahr = '%w+'
end
if typ == nil or typ == "" then
typ = '%wW'
end
title = mw.title .new(page)
pt = title:getContent()
local punkte = 0
for w in string.gmatch(pt, '| Punkte%s+'..typ..'%s+'..jahr..'%s+=%s+(%d+)') do
local num = tonumber(w)
punkte = punkte + num
end
return punkte
end
function p.bgcolor(frame)
local ro = frame.args[1]
local j = tonumber(frame.args[2])
local ret = ''
local jahr = os.date('%Y')
local alt = tonumber(p.punktesumme2(ro,"alt"))
local vier = tonumber(p.punktesumme2(ro,jahr-4))
local drei = tonumber(p.punktesumme2(ro,jahr-3))
local zwei = tonumber(p.punktesumme2(ro,jahr-2))
local eins = tonumber(p.punktesumme2(ro,jahr-1))
local null = tonumber(p.punktesumme2(ro,jahr))
local style = 'text-align:center;'
if (j == 0 and null > 0) then
if ( null > 5 and eins > 5 and zwei > 5 and drei > 5
or null+eins+zwei+drei >= 20) then
return 'style="'..style..'background:#00ff00" |'
else
return 'style="'..style..'background:#fffa00" |'
end
elseif null == 0 and eins == 0 and zwei == 0 then
if (j == 1 or j == 2) then
return 'style="'..style..'background:#ff0000" |'
end
elseif ((alt > 0 or vier > 0 or drei > 0) and eins+zwei+drei+vier < 20) then
return 'style="'..style..'background:#fffa00" |'
end
return 'style="'..style..'" |'
end
function p.rang(frame)
local ro = frame.args[1]
local style = 'text-align:center;'
local page = 'RO:' .. ro
local title = mw.title .new(page)
local pt = title:getContent()
local match = '|%s*GROI%s*=%s*(%S+)'
for w in string.gmatch(pt, match) do
rang = w
end
local punkte = tonumber(p.punktesumme2(ro))
if (rang == "P" and punkte > 5) then
return 'style="'..style..'background:#ffa500" |'
--elseif (rang == "RO" and punkte > 100 or rang == "CRO" and punkte > 200) then
-- return 'style="'..style..'background:#cc99ff" |'
end
return 'style="'..style..'" |'
end
return p