Module:Election results/sandbox: Difference between revisions

Content deleted Content added
+
+
 
(44 intermediate revisions by 4 users not shown)
Line 86:
local has_party = args['party' .. i]
local has_rspan = args['vspan' .. i] or args['v2span' .. i]
local has_sspan = args['sspan' .. i] or args['tsspan' .. i]
while stop_flag == false do
stop_flag = true
Line 147:
has_rspan = true
end
if args['sspan' .. i] or args['tsspan' .. i] then
has_sspan = true
end
Line 167:
if args['votes' .. i .. '_3'] then
has_votes = true
rounds = (rounds < 3) and 3 or rounds
if tonumber(args['votes' .. i .. '_3']) then showtotal.votes_3 = 1 end
local votesi = tonumber(args['votes' .. i .. '_3']) or 0
Line 262 ⟶ 263:
-- build the table
local root = mw.html.create(args['embed'] and '' or 'table')
if args['embed'] == nil and args['floatright'] then
root
:addClass('wikitable sortable floatright')
:tag('caption')
:wikitext('+/−'args.caption)
:done()
elseif args['embed'] == nil then
root
:addClass('wikitable sortable')
Line 275 ⟶ 282:
:tag('th')
:css('text-align', 'center')
:css('backgroundcolor', 'var( --color-base, #F8F9FA202122 )')
:css('background', 'var( --background-color-neutral, #F8F9FA )')
:wikitext(args['image'])
end
Line 283 ⟶ 291:
:tag('td')
:css('text-align', 'center')
:css('backgroundcolor', 'var( --color-base, #F8F9FA202122 )')
:css('background', 'var( --background-color-neutral, #F8F9FA )')
end
topcell:tag('div')
Line 337 ⟶ 346:
:attr('rowspan', rowspan)
:attr('colspan', 2)
if headings['vp'] then
row
:tag('th')
:wikitext('+/−Running mate')
:attr('scope', 'col')
:attr('rowspan', rowspan)
:done()
cols = cols + 1
end
row
:tag('th')
Line 364 ⟶ 382:
cols = cols + 1
end
if headings['vp'] and not has_alliance then
row
:tag('th')
Line 492 ⟶ 510:
:done()
:tag('th')
:csswikitext('style', 'white-space:nowrap+/–')
:wikitext('+/−')
:attr('scope', 'col')
:attr('rowspan', rowspan)
Line 526 ⟶ 543:
end
end
if has_votes and not has_seats2 or has_votes3 and not has_seats3 then
for k=1, rounds do
secondrow
Line 545 ⟶ 562:
row
:tag('th')
:csswikitext('style', 'white-space:nowrap+/–')
:wikitext('+/−')
:attr('scope', 'col')
:attr('rowspan', rowspan)
Line 622 ⟶ 638:
row
:tag('th')
:wikitext(args.sctitle or '+/')
:css('style', 'white-space:nowrap')
:wikitext(args.sctitle or '+/−')
:attr('scope', 'col')
:attr('rowspan', rowspan)
Line 690 ⟶ 705:
:css('background-color', rcolor)
:tag('td')
:css('width', args.candwidth)
:attr('rowspan', args['candspan' .. v] or args['aspan' .. v])
:attr('scope', 'row')
:wikitext(args['cand' .. v])
end
Line 697 ⟶ 712:
row
:tag('td')
:attr('rowspan', args['candspan' .. v] or args['aspan' .. v])
:wikitext(args['vp' .. v])
end
Line 703 ⟶ 719:
:tag('td')
:attr('rowspan', args['aspan' .. v])
:attr('scope', 'row')
:wikitext(args['alliance' .. v])
end
Line 717 ⟶ 734:
:attr('rowspan', args['aspan' .. v])
:attr('colspan', 3)
:attr('scope', 'row')
:wikitext(args['alliance' .. v])
end
if args['alliance' .. v] and args['party' .. v] and not has_cand then
row
:tag('td')
:attr('rowspan', args['aspan' .. v])
:attr('scope', 'row')
:wikitext(args['alliance' .. v])
elseif args['alliance' .. v] and args['party' .. v] and args.dsv then
row
:tag('td')
:attr('rowspan', args['aspan' .. v])
:attr('scope', 'row')
:wikitext(args['alliance' .. v])
elseif args['alliance' .. v] and args['party' .. v] then
row
:tag('td')
Line 725 ⟶ 755:
:wikitext(args['alliance' .. v])
end
if args['party' .. v] and not has_alliance orand args['cand' .. v] and has_party and not has_alliancedsv then
row
:tag('td')
:attr('scope', 'row')
:wikitext(args['party' .. v])
elseif args['party' .. v] and not has_cand and not has_alliance then
row
:tag('td')
:attr('scope', 'row')
:wikitext(args['party' .. v])
elseif args['party' .. v] and not has_alliance or args['cand' .. v] and has_party and not has_alliance then
row
:tag('td')
:css('width', args.partywidth)
:wikitext(args['party' .. v])
end
Line 736 ⟶ 775:
:tag('td')
:attr('colspan', cs)
:attr('scope', 'row')
:wikitext(args['row' .. v])
end
Line 756 ⟶ 796:
:tag('td')
:attr('colspan', 2)
:attr('scope', 'row')
:wikitext('Total')
end
Line 762 ⟶ 803:
:css('font-style', 'italic')
:tag('td')
:attr('scope', 'row')
:wikitext('Total')
end
Line 769 ⟶ 811:
:tag('td')
:attr('colspan', 3)
:attr('scope', 'row')
:wikitext('Total')
end
Line 789 ⟶ 832:
:css('text-align', 'right')
:wikitext(pct(args['votes' .. v], valid[1]))
elseif args['avotes' .. v] then
row:tag('td')
:attr('rowspan', args['vspan' .. v])
:css('text-align', 'right')
:css('font-style', 'white-space:nowrapitalic')
:wikitext(fmt(args['avotes' .. v]))
row:tag('td')
:attr('rowspan', args['vspan' .. v])
:css('text-align', 'right')
:css('font-style', 'italic')
:wikitext(pct(args['avotes' .. v], valid[1]))
elseif args['ivotes' .. v] or args ['ipct' .. v] or args['atotal' .. v] then
row:tag('td')
Line 886 ⟶ 940:
:wikitext()
end
if headings['seats'] and args['dsv'] and not has_sspan or headings['seats'] and rounds > 1 and not has_seats2 and not has_sspan or args['seats' .. v] and has_sspan and rounds > 1 and not has_seats2 then
row
:tag('td')
Line 935 ⟶ 989:
row:tag('td')
:attr('colspan', 3)
elseif has_seats3 and not has_votesrow3 and not has_rspan or has_seats3 and args['row' .. v] and has_seatsrow3 and not has_votesrow3 or has_votes3 and not has_votesrow3 and not has_rspan then
row:tag('td')
:attr('colspan', 2)
Line 998 ⟶ 1,052:
:wikitext(args['st5t' .. v] or '–')
end
if headingsargs['totseats'] and not args['itotseats' .. v] and nothas_sspan or args['atotseats' .. v] and has_sspan then
row
:tag('td')
:attr('rowspan', args['tsspan' .. v])
:css('text-align', 'right')
:wikitext(args['totseats' .. v] or args['atotseats' .. v] or '–')
end
if headings['totseats'] and not args['itotseats' .. v] and not args['atotseats' .. v] and not has_sspan then
row
:tag('td')
:css('text-align', 'right')
:wikitext(fmt(args['totseats' .. v]) or '–')
elseif headings['totseats'] and not has_sspan then
row
:tag('td')
Line 1,030 ⟶ 1,091:
row
:tag('td')
:css('backgroundcolor', 'var( --color-base, #eaecf0202122 )')
:css('background', 'var( --background-color-neutral, #eaecf0 )')
:attr('colspan', cols)
end
Line 1,046 ⟶ 1,108:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
if args['invalid'] then
Line 1,150 ⟶ 1,213:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
else
Line 1,160 ⟶ 1,224:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
end
Line 1,254 ⟶ 1,319:
end
-- blank votes
if args['blank'] or args['blank2'] or args['blank3'] then
row = root:tag('tr')
:addClass('sortbottom')
Line 1,265 ⟶ 1,330:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
if args['blank'] then
row
:tag('td')
:wikitext(fmt(blank[1]))
:tag('td')
:wikitext(pct(blank[1], ovalid[1] + invalid[1] + blank[1]))
else
row
:tag('td')
:wikitext()
:tag('td')
:wikitext()
end
if has_seats2 and not headings['sw'] then
row
Line 1,320 ⟶ 1,394:
:wikitext()
end
if has_seats3 and args['blank3'] or has_votes3 and args['blank3'] then
row
:tag('td')
Line 1,326 ⟶ 1,400:
:tag('td')
:wikitext(pct(blank[3], ovalid[3] + invalid[3] + blank[3]))
elseif has_seats3 and args['blank3'] or has_votes3 and args['blank3'] then
row
:tag('td')
Line 1,362 ⟶ 1,436:
:css('text-align', 'left')
:css('background', 'inherit')
:css('color', 'inherit')
if not args['totalvotes'] and args['invalid'] then
row
Line 1,483 ⟶ 1,558:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
row
Line 1,607 ⟶ 1,683:
row
:tag('td')
:css('backgroundcolor', 'var( --color-base, #eaecf0202122 )')
:css('background', 'var( --background-color-neutral, #eaecf0 )')
:attr('colspan', cols)
end
Line 1,621 ⟶ 1,698:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
for k=1, rounds do
Line 1,679 ⟶ 1,757:
:css('text-align', 'left')
:css('font-weight', 'normal')
:css('color', 'inherit')
:css('background', 'inherit')
for k=1, rounds do