Modul:RO: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Krd (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Krd (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
(33 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
local p = {} | 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) | function p.next(frame) | ||
Zeile 10: | Zeile 18: | ||
local num = tonumber(w) | local num = tonumber(w) | ||
if num >= new then | if num >= new then | ||
new = num | new = num | ||
end | end | ||
end | end | ||
local lv = tonumber(string.match(page, '%d+')) | local lv = tonumber(string.match(page, '%d+')) | ||
local out = os.date('%y')..'-'..string.format("%02i", lv)..'-'..string.format("%02i", new) | local out | ||
local t | |||
repeat | |||
new = new + 1 | |||
out = os.date('%y')..'-'..string.format("%02i", lv)..'-'..string.format("%02i", new) | |||
t = mw.title.new("RO:"..out) | |||
until not t.exists | |||
return out | return out | ||
end | end | ||
Zeile 42: | Zeile 56: | ||
function p.bgcolor(frame) | function p.bgcolor(frame) | ||
local ro = frame.args[1] | local ro = frame.args[1] | ||
local j = tonumber(frame.args[2]) | |||
local ret = '' | local ret = '' | ||
local jahr = os.date('% | local jahr = os.date('%Y') | ||
local alt = tonumber(p.punktesumme2(ro,"alt")) | |||
local vier = tonumber(p.punktesumme2(ro,jahr-4)) | local vier = tonumber(p.punktesumme2(ro,jahr-4)) | ||
local drei = tonumber(p.punktesumme2(ro,jahr-3)) | local drei = tonumber(p.punktesumme2(ro,jahr-3)) | ||
Zeile 49: | Zeile 65: | ||
local eins = tonumber(p.punktesumme2(ro,jahr-1)) | local eins = tonumber(p.punktesumme2(ro,jahr-1)) | ||
local null = tonumber(p.punktesumme2(ro,jahr)) | local null = tonumber(p.punktesumme2(ro,jahr)) | ||
if null == 0 and eins == 0 and zwei == 0 then | 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 | end | ||
return | return 'style="'..style..'" |' | ||
end | end | ||
return p | return p |
Aktuelle Version vom 25. November 2021, 12:45 Uhr
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
end
end
local lv = tonumber(string.match(page, '%d+'))
local out
local t
repeat
new = new + 1
out = os.date('%y')..'-'..string.format("%02i", lv)..'-'..string.format("%02i", new)
t = mw.title.new("RO:"..out)
until not t.exists
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