Module:Tournament: Difference between revisions
From eSportsAmaze
More actions
Esportsamaze (talk | contribs) Undo revision 2637 by Esportsamaze (talk) Tags: Undo Reverted |
Esportsamaze (talk | contribs) No edit summary Tag: Manual revert |
||
| Line 4: | Line 4: | ||
local lang = mw.getContentLanguage() | local lang = mw.getContentLanguage() | ||
-- | -- ... (Keep existing formatCurrency, formatDateRange, getCleanTitle, getSmallTeamLogo, getTeamFromPrizeMoney, getSocials, getSeriesNav, getInfoboxLogo, getTourneyLogo, listRow, listRowMain, infobox) ... | ||
-- (Paste all the helper functions and the other main functions here. I will only show the changed function below to save space, but YOU MUST KEEP THE FULL MODULE) | |||
-- ============================================================ | -- ============================================================ | ||
-- | -- HELPER: Get Tier Class | ||
-- ============================================================ | -- ============================================================ | ||
function | local function getTierClass(tier) | ||
if not tier then return "tier-misc" end | |||
local t = tier:lower() | |||
if string.find(t, "s") and string.find(t, "tier") then return "tier-s" end | |||
if string.find(t, "a") and string.find(t, "tier") then return "tier-a" end | |||
if string.find(t, "b") and string.find(t, "tier") then return "tier-b" end | |||
if string.find(t, "c") and string.find(t, "tier") then return "tier-c" end | |||
return "tier-misc" | |||
if not | |||
local | |||
if | |||
if | |||
return | |||
end | end | ||
-- ============================================================ | -- ============================================================ | ||
-- MAIN 2: TABLE ROW ( | -- MAIN 2: TABLE ROW (UPDATED FOR HYBRID DESIGN) | ||
-- ============================================================ | -- ============================================================ | ||
function p.tableRow(frame) | function p.tableRow(frame) | ||
| Line 272: | Line 30: | ||
local endDate = args.end_date or "" | local endDate = args.end_date or "" | ||
local prize = args.prize_pool or "0" | local prize = args.prize_pool or "0" | ||
local tier = args.tier or "-" | |||
-- | -- Auto-Fetch Winners | ||
local winner = args.winner | local winner = args.winner | ||
if not winner or winner == "" then | if not winner or winner == "" then winner = getTeamFromPrizeMoney(page, name, "1") end | ||
local runnerUp = args.runner_up | local runnerUp = args.runner_up | ||
if not runnerUp or runnerUp == "" then | if not runnerUp or runnerUp == "" then runnerUp = getTeamFromPrizeMoney(page, name, "2") end | ||
local row = html.create('tr') | local row = html.create('tr') | ||
-- 1. Date ( | -- 1. Date (Desktop: Box, Mobile: Label) | ||
row:tag('td') | row:tag('td') | ||
:attr('data-label', 'Date') -- For Mobile | |||
:attr('data-sort-value', startDate) | :attr('data-sort-value', startDate) | ||
:tag('div'):addClass('tr-date'):wikitext(formatDateRange(startDate, endDate)) | :tag('div'):addClass('tr-date'):wikitext(formatDateRange(startDate, endDate)) | ||
-- 2. Tier | -- 2. Tier (Color Coded Pill) | ||
row:tag('td'):css('text-align', 'center'): | row:tag('td') | ||
:attr('data-label', 'Tier') | |||
:css('text-align', 'center') | |||
:tag('span'):addClass('tier-badge'):addClass(getTierClass(tier)):wikitext(tier) | |||
-- 3. Tournament Name | -- 3. Tournament Name | ||
row:tag('td'):css('font-weight', 'bold'):wikitext('[[' .. page .. '|' .. name .. ']]') | row:tag('td') | ||
:attr('data-label', 'Tournament') | |||
:css('font-weight', 'bold'):wikitext('[[' .. page .. '|' .. name .. ']]') | |||
-- 4. Location | -- 4. Location | ||
row:tag('td'):wikitext(args.location or '-') | row:tag('td') | ||
:attr('data-label', 'Location') | |||
:wikitext(args.location or '-') | |||
-- 5. Prize | -- 5. Prize | ||
row:tag('td') | row:tag('td') | ||
:attr('data-label', 'Prize') | |||
:attr('data-sort-value', prize) | :attr('data-sort-value', prize) | ||
:addClass('tr-prize') | :addClass('tr-prize') | ||
:css('text-align', 'right') | :css('text-align', 'right') | ||
:wikitext(formatCurrency(prize)) | :wikitext(formatCurrency(prize)) | ||
-- 6. Winner | -- 6. Winner (Gold Background on Desktop) | ||
local winCell = row:tag('td') | local winCell = row:tag('td') | ||
:attr('data-label', 'Winner') | |||
:addClass('cell-winner') -- For Gold Background | |||
if winner and winner ~= "" then | if winner and winner ~= "" then | ||
winCell:wikitext(getSmallTeamLogo(winner) .. '[[' .. winner .. ']]') | |||
winCell:wikitext( | |||
else | else | ||
winCell:css('text-align', 'center'):wikitext('-') | winCell:css('text-align', 'center'):wikitext('-') | ||
| Line 317: | Line 83: | ||
-- 7. Runner Up | -- 7. Runner Up | ||
local runCell = row:tag('td') | local runCell = row:tag('td'):attr('data-label', 'Runner Up') | ||
if runnerUp and runnerUp ~= "" then | if runnerUp and runnerUp ~= "" then | ||
runCell:wikitext( | runCell:wikitext(getSmallTeamLogo(runnerUp) .. '[[' .. runnerUp .. ']]') | ||
else | else | ||
runCell:css('text-align', 'center'):wikitext('-') | runCell:css('text-align', 'center'):wikitext('-') | ||
end | end | ||
return tostring(row) | return tostring(row) | ||
end | end | ||
return p | return p | ||
Revision as of 04:27, 28 January 2026
Documentation for this module may be created at Module:Tournament/doc
local p = {}
local html = mw.html
local cargo = mw.ext.cargo
local lang = mw.getContentLanguage()
-- ... (Keep existing formatCurrency, formatDateRange, getCleanTitle, getSmallTeamLogo, getTeamFromPrizeMoney, getSocials, getSeriesNav, getInfoboxLogo, getTourneyLogo, listRow, listRowMain, infobox) ...
-- (Paste all the helper functions and the other main functions here. I will only show the changed function below to save space, but YOU MUST KEEP THE FULL MODULE)
-- ============================================================
-- HELPER: Get Tier Class
-- ============================================================
local function getTierClass(tier)
if not tier then return "tier-misc" end
local t = tier:lower()
if string.find(t, "s") and string.find(t, "tier") then return "tier-s" end
if string.find(t, "a") and string.find(t, "tier") then return "tier-a" end
if string.find(t, "b") and string.find(t, "tier") then return "tier-b" end
if string.find(t, "c") and string.find(t, "tier") then return "tier-c" end
return "tier-misc"
end
-- ============================================================
-- MAIN 2: TABLE ROW (UPDATED FOR HYBRID DESIGN)
-- ============================================================
function p.tableRow(frame)
local args = frame.args
local page = args.Page or ""
local name = getCleanTitle(page)
local startDate = args.start_date or ""
local endDate = args.end_date or ""
local prize = args.prize_pool or "0"
local tier = args.tier or "-"
-- Auto-Fetch Winners
local winner = args.winner
if not winner or winner == "" then winner = getTeamFromPrizeMoney(page, name, "1") end
local runnerUp = args.runner_up
if not runnerUp or runnerUp == "" then runnerUp = getTeamFromPrizeMoney(page, name, "2") end
local row = html.create('tr')
-- 1. Date (Desktop: Box, Mobile: Label)
row:tag('td')
:attr('data-label', 'Date') -- For Mobile
:attr('data-sort-value', startDate)
:tag('div'):addClass('tr-date'):wikitext(formatDateRange(startDate, endDate))
-- 2. Tier (Color Coded Pill)
row:tag('td')
:attr('data-label', 'Tier')
:css('text-align', 'center')
:tag('span'):addClass('tier-badge'):addClass(getTierClass(tier)):wikitext(tier)
-- 3. Tournament Name
row:tag('td')
:attr('data-label', 'Tournament')
:css('font-weight', 'bold'):wikitext('[[' .. page .. '|' .. name .. ']]')
-- 4. Location
row:tag('td')
:attr('data-label', 'Location')
:wikitext(args.location or '-')
-- 5. Prize
row:tag('td')
:attr('data-label', 'Prize')
:attr('data-sort-value', prize)
:addClass('tr-prize')
:css('text-align', 'right')
:wikitext(formatCurrency(prize))
-- 6. Winner (Gold Background on Desktop)
local winCell = row:tag('td')
:attr('data-label', 'Winner')
:addClass('cell-winner') -- For Gold Background
if winner and winner ~= "" then
winCell:wikitext(getSmallTeamLogo(winner) .. '[[' .. winner .. ']]')
else
winCell:css('text-align', 'center'):wikitext('-')
end
-- 7. Runner Up
local runCell = row:tag('td'):attr('data-label', 'Runner Up')
if runnerUp and runnerUp ~= "" then
runCell:wikitext(getSmallTeamLogo(runnerUp) .. '[[' .. runnerUp .. ']]')
else
runCell:css('text-align', 'center'):wikitext('-')
end
return tostring(row)
end
return p