Module:Infobox cabinet members

require('Module:No globals') local getArgs = require('Module:Arguments').getArgs

local p = {} function p.infobox(frame, args) if not args then args = getArgs(frame) end mw.logObject(args) -- local root = mw.html.create -- local host = args['host'] -- local hostColor = '#ccccff' -- local defaultRowColor = '#f8f9fa' -- local flagTemplate = args['flag_template'] or 'flagteam' -- local event = args['event'] -- local totalGold = 0 -- local totalSilver = 0 -- local totalBronze = 0

-- root = root -- 	:tag('table') -- 	:addClass('wikitable') -- 	:addClass('sortable') -- 	:addClass('plainrowheaders') -- 	:addClass('jquery-tablesorter') -- 	:css('text-align', 'center') -- root:tag('caption') -- 	:wikitext(args['caption']) -- -- add the header row -- root:tag('tr') -- 		:tag('th') -- 			:wikitext('Rank') -- 		:tag('th') -- 			:wikitext('Nation') -- 		:tag('th') -- 			:addClass('headerSort') -- 			:css('width', '6em') -- 			:css('background-color', 'gold') -- 			:wikitext('Gold') -- 		:tag('th') -- 			:addClass('headerSort') -- 			:css('width', '6em') -- 			:css('background-color', 'silver') -- 			:wikitext('Silver') -- 		:tag('th') -- 			:addClass('headerSort') -- 			:css('width', '6em') -- 			:css('background-color', '#c96') -- 			:wikitext('Bronze') -- 		:tag('th') -- 			:css('width', '6em') -- 			:wikitext('Total') -- -- enumerate the rows -- local rowNums = {} -- for k,v in pairs(args) do	-- 	k = ''..k	-- 	local nation = k:match('^gold_([A-Z][A-Z][A-Z])$') -- 	if nation then -- 		local total = tonumber(args['total' .. nation]) or (	-- 			(tonumber(args['gold_' .. nation]) or 0) + 	-- 			(tonumber(args['silver_' .. nation]) or 0) +	-- 			(tonumber(args['bronze_' .. nation]) or 0)) -- 		table.insert(rowNums, {total, nation}) -- 	end -- end -- mw.logObject(rowNums) -- table.sort(rowNums, function (a, b) return a[1] > b[1] end) -- local lasttotal, lastspan, lastrankcell = -1, 1, nil -- for i, anum in ipairs(rowNums) do	-- 	local IOC = anum[2] -- 	local name  = args['name_' .. IOC] -- 	local gold  = args['gold_' .. IOC] -- 	local silver = args['silver_' .. IOC] -- 	local bronze = args['bronze_' .. IOC] -- 	local isHost = args['host_' .. IOC] -- 	-- this is mainly for the parameter names example so you can override it. -- 	local total = args['total_' .. IOC] or gold + silver + bronze -- 	local color -- 	if isHost then color = hostColor else color = defaultRowColor end

-- 	if args['grand_total'] then else -- 			totalGold = totalGold + gold -- 			totalSilver = totalSilver + silver -- 			totalBronze = totalBronze + bronze -- 	end -- 	local nation -- 	if name then -- 		nation = name -- 	else -- 		nation = mw.getCurrentFrame:expandTemplate({title = flagTemplate, args = { IOC, event } }) -- 	end

-- 	local row = root:tag('tr'):css('background-color', color) -- 	-- if (flagTemplate and event) then -- 	-- 	nation = mw.getCurrentFrame:expandTemplate({title = flagTemplate, args = { nation, event } }) -- 	-- end -- 	if total == lasttotal then -- 		lastspan = lastspan + 1 -- 		lastrankcell:attr('rowspan',lastspan) -- 	else -- 		lastspan = 1 -- 		lastrankcell = row:tag('td'):wikitext(i) -- 		lasttotal = total -- 	end -- 	row:tag('td') -- 			:css('text-align','left') -- 			:wikitext(nation) -- 		:tag('td') -- 			:wikitext(gold) -- 		:tag('td') -- 			:wikitext(silver) -- 		:tag('td') -- 			:wikitext(bronze) -- 		:tag('td') -- 			:wikitext(total) -- end

-- root:tag('tr') -- 	:addClass('sortbottom') -- 	:tag('th') -- 		:wikitext('Totals') -- 		:attr('colspan',2) -- 	:tag('th') -- 		:wikitext(args['total_gold'] or totalGold) -- 	:tag('th') -- 		:wikitext(args['total_silver'] or totalSilver) -- 	:tag('th') -- 		:wikitext(args['total_bronze'] or totalBronze) -- 	:tag('th') -- 		:wikitext(args['grand_total'] or totalGold+totalSilver+totalBronze)

-- if host then -- 	root -- 		:tag('p') -- 			:wikitext(host) -- 			:tag('span') -- 				:css('background-color', hostColor) -- 				:css('text-align', 'center') -- 				:css('padding', '2px') -- 				:css('margin', '2px') -- 				:css('border', '1px solid darkgray') -- 				:css('float', 'left') -- 				:css('height', '1em') -- 				:wikitext('  ') -- end

return tostring(root) end return p