Jump to content

Module:Sandbox/Julio974fr

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Julio974fr (talk | contribs) at 10:19, 25 January 2023 (getting started). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
local p = {};

function p.main(frame)
	local args = require("Module:Arguments").getArgs(frame)
	return p.makeTable(args)
end

function p.makeTable(args)
	local root = mw.html.create('table')

	-- Table opening
	root
		:addClass('wikitable sortable')
		:tag('caption')
			:wikitext(args.caption)
			:done()

	-- Header
	local topcell = nil
	topcell = root
		:tag('th')
			:wikitext(args['image'] or '')-- or parliament_diagram (by default)
			:css('text-align', 'center')
			:css('background', 'F8F9FA')

	-- Table header
	row = root:tag('tr')
	row -- TODO: Add the cols counter
		:tag('th')
			:wikitext(args.partytitle or 'Party')
			:attr('scope', 'col')
			:attr('colpan', '4')
			:done()
		:tag('th') -- TODO: Have the swings only present if there's a previous election
			:wikitext('Votes')
				:atr('scope', 'col')
				:done()
		:tag('th')
			:wikitext('%')
				:atr('scope', 'col')
				:done()
		:tag('th')
			:wikitext('Seats')
				:atr('scope', 'col')
				:done()
		:tag('th')
			:wikitext('+/−')
				:atr('scope', 'col')
				:done()

	-- Each table row
	-- TODO: Add the rows (duh)


	return root
end

return p