Module:Infobox cabinet members
Appearance
Documentation for this module may be created at Module:Infobox cabinet members/doc
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 columns = '4'
-- 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('infobox')
:css('width', 'auto')
:css('text-align', 'left')
:css('line-height', '1.2em')
:css('margin-left', '1em')
:css('margin-right', '0em')
:css('float', 'right')
:css('clear', 'right')
root
:tag('tr'):tag('td')
:attr('colspan', columns)
:css('text-align', 'center')
:wikitext(args['topimage'])
:tag('tr'):tag('td')
:attr('colspan', columns)
:css('text-align', 'center')
:wikitext(args['topcaption'])
:tag('tr'):tag('th')
:attr('colspan', columns)
:css('line-height','1.5em')
:css('font-size','110%')
:css('background','#DCDCDC')
:css('text-align', 'center')
:wikitext(args['above'])
--TODO: Use infobox image!
:tag('tr'):tag('td')
:attr('colspan', columns)
:css('text-align', 'center')
:wikitext(args['image'])
:tag('tr'):tag('td')
:attr('colspan', columns)
:css('text-align', 'center')
:wikitext(args['caption'])
:tag('tr')
:tag('th')
:wikitext('Office')
:tag('th')
:wikitext('Name')
:tag('th')
:wikitext('Party')
:tag('th')
:wikitext('Term')
:tag('tr')
:tag('td')
:attr('colspan', columns)
:css('background', '#000')
local officeNums = {}
for k,v in pairs(args) do
k = ''..k
local num = k:match('^office(%d+)$')
if num then table.insert(officeNums, tonumber(num)) end
end
mw.logObject(officeNums)
for i, num in ipairs(officeNums) do
if num > 1 then
root:tag('tr')
:tag('td')
:attr('colspan',columns)
:css('background','#D1D1D1')
end
root:tag('tr')
:tag('td')
-- :attr('rowspan','5')
:wikitext(args['office' .. num])
:tag('th')
:css('font-weight', 'bold')
:wikitext(args['name'..num..'a'])
:tag('td')
:wikitext(args['party'..num..'a'])
:tag('td')
:wikitext(args['term'..num..'a'])
end
return tostring(root)
end
return p