No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local cargo = mw.ext.cargo | |||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local Links = require('Module:Links') | local Links = require('Module:Links') | ||
Line 4: | Line 6: | ||
local Flags = require('Module:Flags') | local Flags = require('Module:Flags') | ||
local Participants = {} | local Participants = {} | ||
function Participants.main(frame) | function Participants.main(frame) | ||
Line 25: | Line 29: | ||
if pValues.team then | if pValues.team then | ||
local teamName = mw.html.create('div') | local teamName = mw.html.create('div') | ||
:addClass('tc fw-600') | |||
:wikitext('[['.. gameCategory .. '/' .. pValues.team ..']]') | |||
if pValues.notes then | |||
local notesList = mw.text.split(pValues.notes, ',') | |||
for i, v in ipairs (notesList) do | |||
v = mw.text.trim(v) | |||
teamName:node(mw.html.create('sup'):attr('title', 'Note ' .. v):wikitext(v)) | |||
end | |||
end | |||
participant:node(teamName) | participant:node(teamName) | ||
end | end | ||
-- Create list of players | |||
local playerList = mw.html.create('table') | local playerList = mw.html.create('table') | ||
:addClass('table-bordered | :addClass('table-bordered players') | ||
local players = {} | local players = {} | ||
for i = 1, teamsize, 1 do | for i = 1, teamsize, 1 do | ||
if pValues['p'.. i] then | |||
if pValues['p'.. i] then | local playerId = pValues['p'.. i .. 'link'] or pValues['p'.. i] | ||
players['p'.. i] = mw.html.create('tr') | players['p'.. i] = mw.html.create('tr') | ||
:node(mw.html.create('th'):wikitext(i)) | :node(mw.html.create('th'):wikitext(i)) | ||
:node(mw.html.create('td'):wikitext('[['.. | :node(mw.html.create('td'):wikitext('[['.. playerId ..']]')) | ||
playerList:node(players['p'.. i]) | playerList:node(players['p'.. i]) | ||
end | end | ||
end | |||
if pValues.s then | |||
local playerId = pValues['slink'] or pValues.s | |||
local sub = mw.html.create('tr') | |||
:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Substitute'):wikitext('S'))) | |||
:node(mw.html.create('td'):wikitext('[['.. playerId ..']]')) | |||
playerList:node(sub) | |||
end | end | ||
if pValues.c then | if pValues.c then | ||
local playerId = pValues['clink'] or pValues.c | |||
local coach = mw.html.create('tr') | local coach = mw.html.create('tr') | ||
:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', ' | :node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Coach'):wikitext('C'))) | ||
:node(mw.html.create('td'):wikitext( | :node(mw.html.create('td'):wikitext('[['.. playerId ..']]')) | ||
playerList:node(coach) | playerList:node(coach) | ||
end | end | ||
local relativeParent = mw.html.create('div') | |||
:addClass('team-list') | |||
-- Look up Cargo table for team images | |||
local tables = 'Teams' | |||
local fields = '_pageName, image, imagedark' | |||
local cargoArgs = { | |||
where = '_pageName = "' .. gameCategory .. '/' .. pValues.team.. '"' | |||
} | |||
local results = cargo.query(tables, fields, cargoArgs) | |||
local image = '' | |||
local imagedark = '' | |||
if results then | |||
image = results[1].image | |||
imagedark = results[1].imagedark | |||
end | |||
mw.log('image') | |||
mw.log(image) | |||
mw.log(pValues.image) | |||
mw.log('imagedark') | |||
mw.log(image) | |||
mw.log(pValues.imagedark) | |||
imagedark = imagedark or pValues.imagedark or 'Participant_team_placeholder.jpg' | |||
image = image or pValues.image or 'Participant_team_placeholder.jpg' | |||
local logoLight = mw.html.create('div') | |||
:addClass('team-list-logo light') | |||
:node('[[File:' .. image .. '|200px]]') | |||
local logoDark = mw.html.create('div') | |||
:addClass('team-list-logo dark') | |||
:node('[[File:' .. imagedark .. '|200px]]') | |||
relativeParent:node(playerList) | relativeParent:node(playerList):node(logoLight):node(logoDark) | ||
local | participant:node(relativeParent) | ||
if pValues.qualifier then | |||
local qualifier = mw.html.create('div') | |||
:addClass('team-list-qualifier') | |||
:wikitext(pValues.qualifier) | |||
participant:node(qualifier) | |||
end | end | ||
container:node(participant | container:node(participant) | ||
end | end |
Revision as of 12:41, 7 September 2022
Documentation for this module may be created at Module:Participants list team/doc
local cargo = mw.ext.cargo
local getArgs = require('Module:Arguments').getArgs
local Links = require('Module:Links')
local Flags = require('Module:Flags')
local Participants = {}
function Participants.main(frame)
local args = getArgs(frame)
local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/')
local container = mw.html.create('div')
:addClass('p-team-container')
local teamsize = args.teamsize
local currentTitle = mw.title.getCurrentTitle().text
local gameCategory = mw.text.split(currentTitle, '/')[1]
for key, value in ipairs (args) do
local pValues = mw.text.jsonDecode(value)
local participant = mw.html.create('div')
if pValues.team then
local teamName = mw.html.create('div')
:addClass('tc fw-600')
:wikitext('[['.. gameCategory .. '/' .. pValues.team ..']]')
if pValues.notes then
local notesList = mw.text.split(pValues.notes, ',')
for i, v in ipairs (notesList) do
v = mw.text.trim(v)
teamName:node(mw.html.create('sup'):attr('title', 'Note ' .. v):wikitext(v))
end
end
participant:node(teamName)
end
-- Create list of players
local playerList = mw.html.create('table')
:addClass('table-bordered players')
local players = {}
for i = 1, teamsize, 1 do
if pValues['p'.. i] then
local playerId = pValues['p'.. i .. 'link'] or pValues['p'.. i]
players['p'.. i] = mw.html.create('tr')
:node(mw.html.create('th'):wikitext(i))
:node(mw.html.create('td'):wikitext('[['.. playerId ..']]'))
playerList:node(players['p'.. i])
end
end
if pValues.s then
local playerId = pValues['slink'] or pValues.s
local sub = mw.html.create('tr')
:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Substitute'):wikitext('S')))
:node(mw.html.create('td'):wikitext('[['.. playerId ..']]'))
playerList:node(sub)
end
if pValues.c then
local playerId = pValues['clink'] or pValues.c
local coach = mw.html.create('tr')
:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Coach'):wikitext('C')))
:node(mw.html.create('td'):wikitext('[['.. playerId ..']]'))
playerList:node(coach)
end
local relativeParent = mw.html.create('div')
:addClass('team-list')
-- Look up Cargo table for team images
local tables = 'Teams'
local fields = '_pageName, image, imagedark'
local cargoArgs = {
where = '_pageName = "' .. gameCategory .. '/' .. pValues.team.. '"'
}
local results = cargo.query(tables, fields, cargoArgs)
local image = ''
local imagedark = ''
if results then
image = results[1].image
imagedark = results[1].imagedark
end
mw.log('image')
mw.log(image)
mw.log(pValues.image)
mw.log('imagedark')
mw.log(image)
mw.log(pValues.imagedark)
imagedark = imagedark or pValues.imagedark or 'Participant_team_placeholder.jpg'
image = image or pValues.image or 'Participant_team_placeholder.jpg'
local logoLight = mw.html.create('div')
:addClass('team-list-logo light')
:node('[[File:' .. image .. '|200px]]')
local logoDark = mw.html.create('div')
:addClass('team-list-logo dark')
:node('[[File:' .. imagedark .. '|200px]]')
relativeParent:node(playerList):node(logoLight):node(logoDark)
participant:node(relativeParent)
if pValues.qualifier then
local qualifier = mw.html.create('div')
:addClass('team-list-qualifier')
:wikitext(pValues.qualifier)
participant:node(qualifier)
end
container:node(participant)
end
return container
end
return Participants