Module:Standings: Difference between revisions
From eSportsAmaze
More actions
Esportsamaze (talk | contribs) Created page with "local p = {} function p.main(frame) local args = frame:getParent().args local tournament = args.tournament or "" local stage = args.stage or "" local group = args.group or "" local qlimit = tonumber(args.qlimit) or tonumber(frame:callParserFunction('#var', 'qlimit')) or 8 local estart = tonumber(args.estart) or tonumber(frame:callParserFunction('#var', 'estart')) or 13 -- Query Cargo Data local tables = "StageStandings" local fields = "team, teamshort, matchesplayed, w..." |
Esportsamaze (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local cargo = mw.ext.cargo | |||
function p.main(frame) | function p.main(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local tournament = args.tournament or "" | local tournament = args.tournament or "" | ||
local stage = args.stage or "" | local stage = args.stage or "" | ||
local qlimit = tonumber(args.qlimit) or 8 | |||
local qlimit = tonumber(args.qlimit | local estart = tonumber(args.estart) or 13 | ||
local estart = tonumber(args.estart | |||
-- Query | -- Query | ||
local tables = "StageStandings" | local tables = "StageStandings" | ||
local fields = "team, teamshort, matchesplayed, wwcd, placepts, elimpts, totalpts, | local fields = "team, teamshort, matchesplayed, wwcd, placepts, elimpts, totalpts, groupname" | ||
local queryArgs = { | local queryArgs = { | ||
where = "tournament = '" .. tournament .. "' AND stage = '" .. stage .. "'", | where = "tournament = '" .. tournament .. "' AND stage = '" .. stage .. "'", | ||
orderBy = "totalpts DESC, wwcd DESC, placepts DESC, elimpts DESC | orderBy = "totalpts DESC, wwcd DESC, placepts DESC, elimpts DESC" | ||
} | } | ||
local results = cargo.query(tables, fields, queryArgs) | |||
-- Build Table | |||
local root = mw.html.create('table') | |||
root:addClass('match-card-table standings-table') | |||
:css('width', '100%') | |||
:css('border-collapse', 'collapse') | |||
local | -- Headers | ||
local header = root:tag('tr') | |||
header:tag('th'):wikitext('#') | |||
header:tag('th'):wikitext('Team') | |||
header:tag('th'):wikitext('MP') | |||
header:tag('th'):wikitext('WWCD') | |||
header:tag('th'):addClass('nomobile'):wikitext('Place') | |||
header:tag('th'):wikitext('Elims') | |||
header:tag('th'):wikitext('Total') | |||
-- | -- Rows | ||
local root | for i, row in ipairs(results) do | ||
local rowClass = "qual-mid" | |||
:css(' | if i <= qlimit then rowClass = "qual-yes" | ||
:css(' | elseif i >= estart then rowClass = "qual-no" end | ||
local tr = root:tag('tr') | |||
tr:addClass('match-card-row ' .. rowClass) | |||
tr:attr('data-value', row.groupname) -- Crucial for your JS Filter! | |||
-- Rank | |||
tr:tag('td'):addClass('rank-cell') | |||
-- Team | |||
local teamTD = tr:tag('td'):addClass('team-cell') | |||
teamTD:wikitext('[[' .. row.team .. ']]') | |||
-- Stats | |||
tr:tag('td'):css('text-align', 'center'):wikitext(row.matchesplayed) | |||
tr:tag('td'):css('text-align', 'center'):wikitext(row.wwcd) | |||
tr:tag('td'):addClass('nomobile'):css('text-align', 'center'):wikitext(row.placepts) | |||
tr:tag('td'):css('text-align', 'center'):wikitext(row.elimpts) | |||
tr:tag('td'):addClass('total-cell'):wikitext(row.totalpts) | |||
end | |||
return tostring(root) | |||
return tostring(root) | |||
end | end | ||
return p | return p | ||
Revision as of 00:18, 25 January 2026
Documentation for this module may be created at Module:Standings/doc
local p = {}
local cargo = mw.ext.cargo
function p.main(frame)
local args = frame:getParent().args
local tournament = args.tournament or ""
local stage = args.stage or ""
local qlimit = tonumber(args.qlimit) or 8
local estart = tonumber(args.estart) or 13
-- Query
local tables = "StageStandings"
local fields = "team, teamshort, matchesplayed, wwcd, placepts, elimpts, totalpts, groupname"
local queryArgs = {
where = "tournament = '" .. tournament .. "' AND stage = '" .. stage .. "'",
orderBy = "totalpts DESC, wwcd DESC, placepts DESC, elimpts DESC"
}
local results = cargo.query(tables, fields, queryArgs)
-- Build Table
local root = mw.html.create('table')
root:addClass('match-card-table standings-table')
:css('width', '100%')
:css('border-collapse', 'collapse')
-- Headers
local header = root:tag('tr')
header:tag('th'):wikitext('#')
header:tag('th'):wikitext('Team')
header:tag('th'):wikitext('MP')
header:tag('th'):wikitext('WWCD')
header:tag('th'):addClass('nomobile'):wikitext('Place')
header:tag('th'):wikitext('Elims')
header:tag('th'):wikitext('Total')
-- Rows
for i, row in ipairs(results) do
local rowClass = "qual-mid"
if i <= qlimit then rowClass = "qual-yes"
elseif i >= estart then rowClass = "qual-no" end
local tr = root:tag('tr')
tr:addClass('match-card-row ' .. rowClass)
tr:attr('data-value', row.groupname) -- Crucial for your JS Filter!
-- Rank
tr:tag('td'):addClass('rank-cell')
-- Team
local teamTD = tr:tag('td'):addClass('team-cell')
teamTD:wikitext('[[' .. row.team .. ']]')
-- Stats
tr:tag('td'):css('text-align', 'center'):wikitext(row.matchesplayed)
tr:tag('td'):css('text-align', 'center'):wikitext(row.wwcd)
tr:tag('td'):addClass('nomobile'):css('text-align', 'center'):wikitext(row.placepts)
tr:tag('td'):css('text-align', 'center'):wikitext(row.elimpts)
tr:tag('td'):addClass('total-cell'):wikitext(row.totalpts)
end
return tostring(root)
end
return p