Module:Infobox/TeamHist

From Leaguepedia | League of Legends Esports Wiki
Jump to: navigation, search

To edit the documentation or categories for this module, click here.


local m_role = require('Module:Role')
local m_team = require('Module:Team')
local util_args = require('Module:ArgsUtil')

local h = {}

function h.printDate(tr, date)
	tr:tag('td')
		:addClass('teamdate')
		:wikitext(date)
end

function h.printRoleAndTeam(tr, args, i)
	local td = tr:tag('td')
	h.printRole(td, args, i)
	h.printTeam(td, args['teamhist' .. i])
end

function h.printRole(td, args, i)
	local roleArgs = {
		sub = util_args.castAsBool(args['issub' .. i]),
		trainee = util_args.castAsBool(args['istrainee' .. i]),
	}
	td:wikitext(m_role.onlyimage(args['teamrole' .. i], roleArgs))
		:wikitext(' ')
end

function h.printTeam(td, team)
	td:wikitext(m_team.rightmediumlinked(team))
end

local p = {}

function p.teamHist(storeto, args)
	local i = 1
	if args['teamhist' .. 1] then
		local tbl = mw.html.create('table'):addClass('teamhist')
		while args['teamhist' .. i] do
			local tr = tbl:tag('tr')
			h.printDate(tr, args['teamdate' .. i])
			h.printRoleAndTeam(tr, args, i)
			i = i + 1
		end
		storeto.teamhist = tostring(tbl)
		i = i - 1
	end
	return {
		team = args['teamhist' .. i] and m_team.teamlinkname(args['teamhist' .. i]),
		date = args['teamdate' .. i],
		role = args['teamrole' .. i]
	}
end

return p