Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Infobox cabinet members/sandbox
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
require('strict') local p = {} local infobox_image = require('Module:InfoboxImage').InfoboxImage function p._main(args) local root = mw.html.create() root = root :tag('table') :addClass('infobox') :addClass('cabinet-members') :addClass(args.float and ('cabinet-members-' .. args.float:lower()) or 'cabinet-members-right') local columns = args.party_column and 4 or 3 mw.log(columns) if args.topcaption then args.topcaption = tostring( mw.html.create('div') :cssText(args.topcaptionstyle) :wikitext(args.topcaption) ) end if args.topimage then root :tag('tr'):tag('td') :attr('colspan', columns) :addClass('cabinet-members-image') :wikitext(infobox_image{ args = { image = args.topimage, size = args.topimagesize, sizedefault = 'frameless', upright = 1, alt = args.topimagealt } } .. (args.topcaption or '')) end if args.above then root :tag('tr'):tag('th') :attr('colspan', columns) :addClass('cabinet-members-above') :wikitext(args.above) end if args.caption then args.caption = tostring( mw.html.create('div') :cssText(args.captionstyle) :wikitext(args.caption) ) end if args.image then root :tag('tr'):tag('td') :attr('colspan', columns) :addClass('cabinet-members-image') :wikitext(infobox_image{ args = { image = args.image, size = args.imagesize, sizedefault = 'frameless', upright = 1, alt = args.imagealt } } .. (args.caption or '')) end -- Actual table local cabinet = mw.html.create('table') local header = cabinet:tag('tr') header:tag('th') :addClass('cabinet-members-header') :wikitext(args.office_label or 'Office') :attr('scope', 'col') header:tag('th') :wikitext(args.name_label or 'Name') :attr('scope', 'col') if args.party_column then header:tag('th') :wikitext(args.party_label or 'Party') :attr('scope', 'col') end header:tag('th') :wikitext(args.term_label or 'Term') :attr('scope', 'col') local subRows = {} local keys = {} for k, v in pairs(args) do k = tostring(k) local num = k:match('^office(%d+)$') if num and args['name' .. num .. 'a'] then num = tonumber(num) if subRows[num] == nil then subRows[num] = {} table.insert(keys, num) end end local num, l = k:match('^name(%d+)([a-z])$') if num then num = tonumber(num) if subRows[num] == nil then subRows[num] = {} table.insert(keys,num) end subRows[num][l] = l end end table.sort(keys) for _, num in ipairs(keys) do local row_table = {} for _, letter in pairs(subRows[num]) do table.insert(row_table, letter) end table.sort(row_table) for j, letter in pairs(row_table) do local row = mw.html.create('tr') if j == 1 then row:addClass('cabinet-members-office') local office = row:tag('td'):wikitext(args['office' .. num]) office:attr('rowspan', (row_table:size() > 1) and row_table:size() or nil) end row:tag('th') :wikitext(args['name'..num..letter]) :attr('scope', 'row') if args.party_column then row:tag('td') :wikitext(args['party'..num..letter]) end row:tag('td') :wikitext(args['term'..num..letter]) cabinet:node(row) end end if args.below then root:tag('tr') :tag('td') :attr('colspan', columns) :wikitext(args.below) end local frame = mw.getCurrentFrame() local base_templatestyles = frame:extensionTag{ 'templatestyles', args = { src = 'Module:Infobox cabinet members/styles.css' } } local templatestyles = '' if args.templatestyles and mw.text.trim(args.templatestyles) ~= '' then templatestyles = frame:extensionTag{ 'templatestyles', args = { src = 'Module:Infobox cabinet members/styles.css' } } end return base_templatestyles .. templatestyles .. tostring(root) end function main(frame) local args = require('Module:Arguments').getArgs(frame) return p._main(args) end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Infobox cabinet members/sandbox/doc
(
edit
)