Halo Esports Wiki

We are currently performing extensive maintenance to this wiki and as a result there will likely be errors. Please be patient while we work to fix all problems.

READ MORE

Halo Esports Wiki
Advertisement

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


local util_args = require('Module:ArgsUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require("Module:ToggleUtil")

local ORDER = {
	'upwith3bye', 'upwith2bye', 'semifinals', 'upwithbye', 'proceed', 'up', 'stayup', 'stay', 'staydown', 'down', 'drop', 'autorelegate', 'clinch-up', 'clinch-down', 'boldtext', 'incomplete', 'specialqualify'
}

local p = {}
local h = {}
function p.main(frame)
	local args = util_args.merge()
	local th = mw.html.create()
	p._main(th, args)
	return th
end

function p._main(th, args)
	local outerdiv = th:tag('div')
		:wikitext(args.display or 'Standings')
		:css({position = 'relative'})
	local button = util_toggle.popupButton(outerdiv)
	button.button:addClass('legend-icon')
		:addClass('table-header-rightcontent')
	button.inner:addClass('legend-table')
		:css({
			['margin-left'] = (((args.legendwidth or 8) - 250) / 2) .. 'px',
			width = '250px'
		 })
	local tbl = button.inner:tag('table')
		:addClass('legend-table')
	
	h.printLegendTable(tbl, args, util_text.splitOrNil(args.legendorder) or ORDER)
	return outerdiv
end

function h.printLegendTable(tbl, args, order)
	h.printTableHeader(tbl)
	for _, v in ipairs(order) do
		h.printLegendRow(tbl, v, args[v], args[v .. 'css'])
	end
end

function h.printTableHeader(tbl)
	local tr = tbl:tag('tr')
	tr:tag('th')
		:addClass('legend-header')
		:wikitext('Legend')
end

function h.printLegendRow(tbl, class, display, css)
	if not display then return end
	local tr = tbl:tag('tr')
	tr:tag('td')
		:addClass('standings-' .. class)
		:cssText(css)
		:wikitext(display)
end

return p
Advertisement