Module:Participants list team: Difference between revisions
From TwogPedia
             (Created page with "local getArgs = require('Module:Arguments').getArgs local Links = require('Module:Links') local Subheader = require('Module:Infobox/Widget/Subheader') local ListWidget = require('Module:Infobox/Widget/List')  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-te...")  | 
				No edit summary  | 
				||
| Line 1: | Line 1: | ||
local getArgs = require('Module:Arguments').getArgs  | local getArgs = require('Module:Arguments').getArgs  | ||
local Links = require('Module:Links')  | local Links = require('Module:Links')  | ||
local Flags = require('Module:Flags')  | local Flags = require('Module:Flags')  | ||
| Line 15: | Line 13: | ||
		:addClass('p-team-container')  | 		:addClass('p-team-container')  | ||
	for key, value in   | 	local teamsize = args.teamsize  | ||
		mw.  | |||
		mw.  | 	local currentTitle = mw.title.getCurrentTitle().text  | ||
	local gameCategory = mw.text.split(currentTitle, '/')[1]  | |||
		mw.  | |||
		mw.  | 	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')  | |||
			:wikitext('[['.. gameCategory .. '/' .. pValues.team ..']]')  | |||
			participant:node(teamName)  | |||
		end  | |||
		local relativeParent = mw.html.create('div')  | |||
			:addClass('team-list')  | |||
		local playerList = mw.html.create('table')  | |||
			:addClass('table-bordered list')  | |||
		local players = {}  | |||
		for i = 1, teamsize, 1 do  | |||
			if pValues['p'.. i] then  | |||
				players['p'.. i] = mw.html.create('tr')  | |||
					:node(mw.html.create('th'):wikitext(i))  | |||
					:node(mw.html.create('td'):wikitext('[['.. pValues['p'.. i] ..']]'))  | |||
				playerList:node(players['p'.. i])  | |||
			end  | |||
		end  | |||
		if pValues.c then  | |||
			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(pValues.c))  | |||
			playerList:node(coach)  | |||
		end  | |||
		relativeParent:node(playerList)  | |||
		local logo = mw.html.create('div')  | |||
		if pValues.image then  | |||
			logo:node('[[File:' .. pValues.image .. '|]]')  | |||
		else  | |||
			logo:node('[[File:Participant_team_placeholder.jpg]]')  | |||
		end  | |||
		container:node(participant:node(relativeParent)):node(logo)  | |||
	end  | 	end  | ||
	return container  | 	return container  | ||
end  | end  | ||
return Participants  | return Participants  | ||
Revision as of 02:31, 6 September 2022
Documentation for this module may be created at Module:Participants list team/doc
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')
			:wikitext('[['.. gameCategory .. '/' .. pValues.team ..']]')
			participant:node(teamName)
		end
		
		local relativeParent = mw.html.create('div')
			:addClass('team-list')
			
		
		
		local playerList = mw.html.create('table')
			:addClass('table-bordered list')
		
		local players = {}
		for i = 1, teamsize, 1 do
			
			if pValues['p'.. i] then
				players['p'.. i] = mw.html.create('tr')
					:node(mw.html.create('th'):wikitext(i))
					:node(mw.html.create('td'):wikitext('[['.. pValues['p'.. i] ..']]'))
				playerList:node(players['p'.. i])
			end
		end
		
		if pValues.c then
			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(pValues.c))
			playerList:node(coach)
		end
		
		relativeParent:node(playerList)
		local logo = mw.html.create('div')
		if pValues.image then
			logo:node('[[File:' .. pValues.image .. '|]]')
		else
			logo:node('[[File:Participant_team_placeholder.jpg]]')
		end
			
		container:node(participant:node(relativeParent)):node(logo)
	end
	
	return container
end
return Participants
No categories