Module:SAFF Club Championship progression
-- Module:SAFF Club Championship progression
local p = {}
local function trim(s) if not s then return "" end return mw.ustring.gsub(s,"^%s*(.-)%s*$","%1") end
local function getArgs(frame)
local parent=frame:getParent()
local args={}
for k,v in pairs(parent.args) do args[k]=v end
for k,v in pairs(frame.args) do args[k]=v end
return args
end
local function renderPlayoffs(args,stageDefs)
local html=mw.html.create()
local tbl=html:tag("table"):addClass("wikitable"):css("text-align","center")
local head=tbl:tag("tr")
head:tag("th"):wikitext("Team")
for _,s in ipairs(stageDefs) do head:tag("th"):wikitext(s.name) end
local teamCodes={}
local seen={}
for _,s in ipairs(stageDefs) do
for _,m in ipairs(s.matches) do
local w=args[m.winner] and trim(args[m.winner]) or nil
local l=args[m.loser] and trim(args[m.loser]) or nil
if w and not seen[w] then table.insert(teamCodes,w); seen[w]=true end
if l and not seen[l] then table.insert(teamCodes,l); seen[l]=true end
end
end
table.sort(teamCodes)
for _,team in ipairs(teamCodes) do
local row=tbl:tag("tr")
row:tag("th"):wikitext(team)
for _,s in ipairs(stageDefs) do
local cell=row:tag("td")
local status=""
for _,m in ipairs(s.matches) do
local w=args[m.winner] and trim(args[m.winner]) or nil
local l=args[m.loser] and trim(args[m.loser]) or nil
if w==team then status="W"; break
elseif l==team then status="L"; break
end
end
if status=="W" then cell:css("background-color","#c9f7c9"):wikitext("W")
elseif status=="L" then cell:css("background-color","#f7c9c9"):wikitext("L")
else cell:css("background-color","#EEEEEE"):wikitext(" ") end
end
end
return tostring(html)
end
local playoffs_standard={
{ name="Semi-final 1", matches={{winner="SF1W", loser="SF1L"}} },
{ name="Semi-final 2", matches={{winner="SF2W", loser="SF2L"}} },
{ name="Final", matches={{winner="FW", loser="FL"}} }
}
function p.SAFF(frame)
local args=getArgs(frame)
return renderPlayoffs(args,playoffs_standard)
end
function p.SAFF_SF(frame)
local args=getArgs(frame)
return renderPlayoffs(args,playoffs_standard)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.