Module:Team: Difference between revisions
From eSportsAmaze
More actions
Esportsamaze (talk | contribs) Created page with "local p = {} local cargo = mw.ext.cargo local html = mw.html -- Helper: Currency Formatter local function formatCurrency(amount) if not amount then return "0" end return '<span class="indian-currency">' .. amount .. '</span>' end -- Helper: Logo Logic (Light/Dark/Shield) local function getLogo(teamName, image, imageDark) local lightFile = (image ~= "" and image) or (teamName .. '.png') local darkFile = (imageDark ~= "" and imageDark) or (teamName .. '_d..." |
Esportsamaze (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
-- MAIN 3: Active Roster Table | |||
function p.activeRoster(frame) | |||
-- MAIN | |||
function p. | |||
local args = frame:getParent().args | local args = frame:getParent().args | ||
local team = args.team or mw.title.getCurrentTitle().text | local team = args.team or mw.title.getCurrentTitle().text | ||
-- Query | -- Query the Players table | ||
local tables = " | local tables = "Players" | ||
local fields = " | local fields = "id, real_name, role, nationality, image" | ||
local queryArgs = { | local queryArgs = { | ||
where = " | where = "current_team = '" .. team .. "'", | ||
orderBy = " | orderBy = "role ASC, id ASC" | ||
} | } | ||
local results = cargo.query(tables, fields, queryArgs) | local results = cargo.query(tables, fields, queryArgs) | ||
local root = html.create(' | local root = html.create('table') | ||
root:wikitext(' | root:addClass('wikitable flat-table sortable') | ||
:css('width', '100%') | |||
:css('text-align', 'center') | |||
:css('margin-top', '0px') | |||
-- Table Header | |||
local header = root:tag('tr') | |||
header:tag('th'):wikitext('ID') | |||
header:tag('th'):wikitext('Name') | |||
header:tag('th'):wikitext('Role') | |||
header:tag('th'):wikitext('Nationality') | |||
if #results > 0 then | if #results > 0 then | ||
for _, row in ipairs(results) do | for _, row in ipairs(results) do | ||
local tr = | local tr = root:tag('tr') | ||
-- | -- Cell 1: ID with Image | ||
local | local idCell = tr:tag('td') | ||
:css('text-align', 'left') | |||
:css('font-weight', 'bold') | |||
if row.image and row.image ~= "" then | |||
idCell:wikitext('[[File:' .. row.image .. '|30px|link=' .. row.id .. ']] ') | |||
end | end | ||
idCell:wikitext('[[' .. row.id .. ']]') | |||
-- Cell 2: Real Name | |||
tr:tag('td'):wikitext(row.real_name) | |||
-- Cell 3: Role | |||
tr:tag('td'):wikitext(row.role) | |||
-- Cell 4: Nationality | |||
tr:tag('td'):wikitext(row.nationality) | |||
tr:tag('td | |||
end | end | ||
else | else | ||
root:wikitext( | local tr = root:tag('tr') | ||
tr:tag('td'):attr('colspan', '4'):wikitext('No players currently listed for this team.') | |||
end | end | ||
return tostring(root) | return tostring(root) | ||
end | end | ||
Revision as of 01:22, 25 January 2026
Documentation for this module may be created at Module:Team/doc
-- MAIN 3: Active Roster Table
function p.activeRoster(frame)
local args = frame:getParent().args
local team = args.team or mw.title.getCurrentTitle().text
-- Query the Players table
local tables = "Players"
local fields = "id, real_name, role, nationality, image"
local queryArgs = {
where = "current_team = '" .. team .. "'",
orderBy = "role ASC, id ASC"
}
local results = cargo.query(tables, fields, queryArgs)
local root = html.create('table')
root:addClass('wikitable flat-table sortable')
:css('width', '100%')
:css('text-align', 'center')
:css('margin-top', '0px')
-- Table Header
local header = root:tag('tr')
header:tag('th'):wikitext('ID')
header:tag('th'):wikitext('Name')
header:tag('th'):wikitext('Role')
header:tag('th'):wikitext('Nationality')
if #results > 0 then
for _, row in ipairs(results) do
local tr = root:tag('tr')
-- Cell 1: ID with Image
local idCell = tr:tag('td')
:css('text-align', 'left')
:css('font-weight', 'bold')
if row.image and row.image ~= "" then
idCell:wikitext('[[File:' .. row.image .. '|30px|link=' .. row.id .. ']] ')
end
idCell:wikitext('[[' .. row.id .. ']]')
-- Cell 2: Real Name
tr:tag('td'):wikitext(row.real_name)
-- Cell 3: Role
tr:tag('td'):wikitext(row.role)
-- Cell 4: Nationality
tr:tag('td'):wikitext(row.nationality)
end
else
local tr = root:tag('tr')
tr:tag('td'):attr('colspan', '4'):wikitext('No players currently listed for this team.')
end
return tostring(root)
end