https://en.wikipedia.org/w/index.php?action=history&feed=atom&title=Module%3AElection_results-STV%2Fsandbox
Module:Election results-STV/sandbox - Revision history
2025-06-11T00:48:15Z
Revision history for this page on the wiki
MediaWiki 1.45.0-wmf.4
https://en.wikipedia.org/w/index.php?title=Module:Election_results-STV/sandbox&diff=1225688521&oldid=prev
Closed Limelike Curves: Accept with numbers with commas
2024-05-26T02:37:21Z
<p>Accept with numbers with commas</p>
<p><b>New page</b></p><div>require('strict')<br />
local p = {}<br />
local political_party = require('Module:Political party')<br />
<br />
function p.main(frame)<br />
local function parsenum(x)<br />
return parsenum(x.gsub(",", ""))<br />
end<br />
local args = require('Module:Arguments').getArgs(frame)<br />
local index, headings, showtotal = {}, {}, {}<br />
local cols, rounds = 0, 1<br />
local valid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}<br />
local invalidblank = {parsenum(args.invalidblank) or 0,}<br />
local invalid = {parsenum(args.invalid) or 0}<br />
local blank = {parsenum(args.blank) or 0}<br />
local totalvotes = {parsenum(args.totalvotes)}<br />
local electorate = {parsenum(args.electorate)}<br />
local turnout = {parsenum(args.turnout)}<br />
local row, secondrow<br />
local tracking = ''<br />
local max_rows = 0<br />
<br />
-- helper functions<br />
local lang = mw.getContentLanguage()<br />
local function fmt(n)<br />
return n and parsenum(n) and lang:formatNum(parsenum(n)) or nil<br />
end<br />
local function pct(n, d)<br />
n, d = parsenum(n), parsenum(d)<br />
if n and d and d > 0 then<br />
return string.format('%.2f', n / d * 100)<br />
end<br />
return '&ndash;'<br />
end<br />
local function tonumdash(s)<br />
if s then<br />
s = mw.ustring.gsub(s, '&[MmNn][Dd][Aa][Ss][Hh];', '-')<br />
s = mw.ustring.gsub(s, '&[Mm][Ii][Nn][Uu][Ss];', '-')<br />
s = mw.ustring.gsub(s, '[—–−]', '-')<br />
return parsenum(s) or 0<br />
end<br />
end<br />
local function unlink(s)<br />
if s then<br />
s = s:match("^[^%[]-%[%[([^%]]-)|[^%]]-%]%].*$") or s<br />
s = s:match("^[^%[]-%[%[([^%]]-)%]%].*$") or s<br />
end<br />
return s<br />
end<br />
local function get_color(color, party)<br />
if color == nil then<br />
local party = unlink(party) or ''<br />
if party ~= '' then<br />
color = political_party._fetch({party, 'color'})<br />
end<br />
end<br />
<br />
if color ~= nil then<br />
color = mw.ustring.gsub(color, '&(#)35;', '%1')<br />
end<br />
return color<br />
end<br />
<br />
-- preprocess the input<br />
local stop_flag = false<br />
local i = 0<br />
local has_votes = args['votes' .. i]<br />
local has_votes2 = args['votes' .. i .. '_2']<br />
local has_votes3 = args['votes' .. i .. '_3']<br />
local has_votes4 = args['votes' .. i .. '_4']<br />
local has_votes5 = args['votes' .. i .. '_5']<br />
local has_votes6 = args['votes' .. i .. '_6']<br />
local has_votes7 = args['votes' .. i .. '_7']<br />
local has_votes8 = args['votes' .. i .. '_8']<br />
local has_votes9 = args['votes' .. i .. '_9']<br />
local has_votes10 = args['votes' .. i .. '_10']<br />
local has_votes11 = args['votes' .. i .. '_11']<br />
local has_votes12 = args['votes' .. i .. '_12']<br />
local has_votes13 = args['votes' .. i .. '_13']<br />
local has_party = args['party' .. i]<br />
local has_nopercentage = args['nopercentage']<br />
while stop_flag == false do<br />
stop_flag = true<br />
for kk = 1, 20 do<br />
i = i + 1<br />
for k, key in ipairs({'cand', 'party', 'ivotes', 'ipct', 'totalvotes', 'acolor', 'rcolor'}) do<br />
if args[key .. i] then<br />
headings[key] = true<br />
stop_flag = false<br />
max_rows = i > max_rows and i or max_rows<br />
end<br />
end<br />
if args['row' .. i] then<br />
stop_flag = false<br />
max_rows = i > max_rows and i or max_rows<br />
end<br />
if args['row' .. i] or args['cand' .. i] or args['header' .. i] then<br />
table.insert(index, i)<br />
if args['votes' .. i] then<br />
if parsenum(args['votes' .. i]) then showtotal.votes = 1 end<br />
local votesi = parsenum(args['votes' .. i]) or 0<br />
args['votes' .. i] = votesi<br />
valid[1] = valid[1] + votesi<br />
has_votes = true<br />
end<br />
if args['party' .. i] then<br />
has_party = true<br />
end<br />
if args['votes' .. i .. '_2'] then<br />
has_votes2 = true<br />
end<br />
if args['votes' .. i .. '_3'] then<br />
has_votes3 = true<br />
end<br />
if args['votes' .. i .. '_4'] then<br />
has_votes4 = true<br />
end<br />
if args['votes' .. i .. '_5'] then<br />
has_votes5 = true<br />
end<br />
if args['votes' .. i .. '_6'] then<br />
has_votes6 = true<br />
end<br />
if args['votes' .. i .. '_7'] then<br />
has_votes7 = true<br />
end<br />
if args['votes' .. i .. '_8'] then<br />
has_votes8 = true<br />
end<br />
if args['votes' .. i .. '_9'] then<br />
has_votes9 = true<br />
end<br />
if args['votes' .. i .. '_10'] then<br />
has_votes10 = true<br />
end<br />
if args['votes' .. i .. '_11'] then<br />
has_votes11 = true<br />
end<br />
if args['votes' .. i .. '_12'] then<br />
has_votes12 = true<br />
end<br />
if args['votes' .. i .. '_13'] then<br />
has_votes13 = true<br />
end<br />
if args['nopercentage'] then<br />
has_nopercentage = true<br />
end<br />
if args['votes' .. i .. '_2'] then<br />
if parsenum(args['votes' .. i .. '_2']) then showtotal.votes_2 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_2']) or 0<br />
args['votes' .. i .. '_2'] = votesi<br />
valid[2] = valid[2] + votesi<br />
end<br />
if args['votes' .. i .. '_3'] then<br />
if parsenum(args['votes' .. i .. '_3']) then showtotal.votes_3 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_3']) or 0<br />
args['votes' .. i .. '_3'] = votesi<br />
valid[3] = valid[3] + votesi<br />
end<br />
if args['votes' .. i .. '_4'] then<br />
if parsenum(args['votes' .. i .. '_4']) then showtotal.votes_4 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_4']) or 0<br />
args['votes' .. i .. '_4'] = votesi<br />
valid[4] = valid[4] + votesi<br />
end<br />
if args['votes' .. i .. '_5'] then<br />
if parsenum(args['votes' .. i .. '_5']) then showtotal.votes_5 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_5']) or 0<br />
args['votes' .. i .. '_5'] = votesi<br />
valid[5] = valid[5] + votesi<br />
end<br />
if args['votes' .. i .. '_6'] then<br />
if parsenum(args['votes' .. i .. '_6']) then showtotal.votes_6 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_6']) or 0<br />
args['votes' .. i .. '_6'] = votesi<br />
valid[6] = valid[6] + votesi<br />
end<br />
if args['votes' .. i .. '_7'] then<br />
if parsenum(args['votes' .. i .. '_7']) then showtotal.votes_7 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_7']) or 0<br />
args['votes' .. i .. '_7'] = votesi<br />
valid[7] = valid[7] + votesi<br />
end<br />
if args['votes' .. i .. '_8'] then<br />
if parsenum(args['votes' .. i .. '_8']) then showtotal.votes_8 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_8']) or 0<br />
args['votes' .. i .. '_8'] = votesi<br />
valid[8] = valid[8] + votesi<br />
end<br />
if args['votes' .. i .. '_9'] then<br />
if parsenum(args['votes' .. i .. '_9']) then showtotal.votes_9 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_9']) or 0<br />
args['votes' .. i .. '_9'] = votesi<br />
valid[9] = valid[9] + votesi<br />
end<br />
if args['votes' .. i .. '_10'] then<br />
if parsenum(args['votes' .. i .. '_10']) then showtotal.votes_10 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_10']) or 0<br />
args['votes' .. i .. '_10'] = votesi<br />
valid[10] = valid[10] + votesi<br />
end<br />
if args['votes' .. i .. '_11'] then<br />
if parsenum(args['votes' .. i .. '_11']) then showtotal.votes_11 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_11']) or 0<br />
args['votes' .. i .. '_11'] = votesi<br />
valid[11] = valid[11] + votesi<br />
end<br />
if args['votes' .. i .. '_12'] then<br />
if parsenum(args['votes' .. i .. '_12']) then showtotal.votes_12 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_12']) or 0<br />
args['votes' .. i .. '_12'] = votesi<br />
valid[12] = valid[12] + votesi<br />
end<br />
if args['votes' .. i .. '_13'] then<br />
if parsenum(args['votes' .. i .. '_13']) then showtotal.votes_13 = 1 end<br />
local votesi = parsenum(args['votes' .. i .. '_13']) or 0<br />
args['votes' .. i .. '_13'] = votesi<br />
valid[13] = valid[13] + votesi<br />
end<br />
end<br />
end<br />
end<br />
<br />
local ovalid = {valid[1], valid[2], valid[3], valid[4], valid[5], valid[6], valid[7], valid[8], valid[9], valid[10], valid[11], valid[12], valid[13]}<br />
if has_votes or args['valid'] then<br />
max_rows = max_rows + 1<br />
local i = max_rows<br />
table.insert(index, i)<br />
args['row' .. i] = 'Total'<br />
args['votes' .. i] = showtotal.votes and valid[1] or nil<br />
args['votes' .. i .. '_2'] = showtotal.votes_2 and valid[2] or nil<br />
args['votes' .. i .. '_3'] = showtotal.votes_3 and valid[3] or nil<br />
args['votes' .. i .. '_4'] = showtotal.votes_4 and valid[4] or nil<br />
args['votes' .. i .. '_5'] = showtotal.votes_5 and valid[5] or nil<br />
args['votes' .. i .. '_6'] = showtotal.votes_6 and valid[6] or nil<br />
args['votes' .. i .. '_7'] = showtotal.votes_7 and valid[7] or nil<br />
args['votes' .. i .. '_8'] = showtotal.votes_8 and valid[8] or nil<br />
args['votes' .. i .. '_9'] = showtotal.votes_9 and valid[9] or nil<br />
args['votes' .. i .. '_10'] = showtotal.votes_10 and valid[10] or nil<br />
args['votes' .. i .. '_11'] = showtotal.votes_11 and valid[11] or nil<br />
args['votes' .. i .. '_12'] = showtotal.votes_12 and valid[12] or nil<br />
args['votes' .. i .. '_13'] = showtotal.votes_13 and valid[13] or nil<br />
args['colour' .. i] = 'inherit'<br />
args['color' .. i] = 'inherit'<br />
args['font-weight' .. i] = 'bold'<br />
args['class' .. i] = 'sortbottom'<br />
ovalid[1] = parsenum(args['valid']) or valid[1]<br />
ovalid[2] = parsenum(args['valid2']) or valid[2]<br />
ovalid[3] = parsenum(args['valid3']) or valid[3]<br />
ovalid[4] = parsenum(args['valid4']) or valid[4]<br />
ovalid[5] = parsenum(args['valid5']) or valid[5]<br />
ovalid[6] = parsenum(args['valid6']) or valid[6]<br />
ovalid[7] = parsenum(args['valid7']) or valid[7]<br />
ovalid[8] = parsenum(args['valid8']) or valid[8]<br />
ovalid[9] = parsenum(args['valid9']) or valid[9]<br />
ovalid[10] = parsenum(args['valid10']) or valid[10]<br />
ovalid[11] = parsenum(args['valid11']) or valid[11]<br />
ovalid[12] = parsenum(args['valid12']) or valid[12]<br />
ovalid[13] = parsenum(args['valid3']) or valid[13]<br />
end<br />
<br />
-- build the table<br />
local root = mw.html.create(args['embed'] and '' or 'table')<br />
if args['embed'] == nil then<br />
root<br />
:addClass('wikitable sortable')<br />
:tag('caption')<br />
:wikitext(args.caption)<br />
:done()<br />
end<br />
<br />
local topcell = nil<br />
if args['image'] then<br />
topcell = root<br />
:tag('th')<br />
:css('text-align', 'center')<br />
:css('background', '#F8F9FA')<br />
:wikitext(args['image'])<br />
end<br />
if args['reporting'] then<br />
if (topcell == nil) then<br />
topcell = root<br />
:tag('td')<br />
:css('text-align', 'center')<br />
:css('background', '#F8F9FA')<br />
end<br />
topcell:tag('div')<br />
:addClass('center')<br />
:wikitext(frame:expandTemplate{<br />
title = 'percentage bar',<br />
args = {args.reporting, <br />
args.reporting .. '% reporting',<br />
['width'] = '200px',<br />
['hex'] = '1BCE0E'<br />
}})<br />
end<br />
<br />
row = args['embed'] and mw.html.create('') or root:tag('tr')<br />
if not has_party then<br />
row<br />
:tag('th')<br />
:wikitext('Candidate' or args.candtitle)<br />
:attr('scope', 'col')<br />
:attr('rowspan', 2)<br />
:done()<br />
cols = cols + 1<br />
else<br />
row<br />
:tag('th')<br />
:wikitext('Candidate' or args.candtitle)<br />
:attr('scope', 'col')<br />
:attr('rowspan', 2)<br />
:attr('colspan', 2)<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_party then<br />
row<br />
:tag('th')<br />
:wikitext('Party' or args.partytitle)<br />
:attr('rowspan', 2)<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
secondrow = args['embed'] and mw.html.create('') or root:tag('tr')<br />
if not has_nopercentage then<br />
row<br />
:tag('th')<br />
:wikitext('First count')<br />
:attr('colspan', 2)<br />
if has_votes2 then<br />
row<br />
:tag('th')<br />
:wikitext('Second count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes3 then<br />
row<br />
:tag('th')<br />
:wikitext('Third count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes4 then<br />
row<br />
:tag('th')<br />
:wikitext('Fourth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes5 then<br />
row<br />
:tag('th')<br />
:wikitext('Fifth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes6 then<br />
row<br />
:tag('th')<br />
:wikitext('Sixth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes7 then<br />
row<br />
:tag('th')<br />
:wikitext('Seventh count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes8 then<br />
row<br />
:tag('th')<br />
:wikitext('Eighth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes9 then<br />
row<br />
:tag('th')<br />
:wikitext('Ninth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes10 then<br />
row<br />
:tag('th')<br />
:wikitext('Tenth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes11 then<br />
row<br />
:tag('th')<br />
:wikitext('Eleventh count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes12 then<br />
row<br />
:tag('th')<br />
:wikitext('Twelfth count')<br />
:attr('colspan', 2)<br />
end<br />
if has_votes13 then<br />
row<br />
:tag('th')<br />
:wikitext('Thirteenth count')<br />
:attr('colspan', 2)<br />
end<br />
elseif has_nopercentage then<br />
row<br />
:tag('th')<br />
:wikitext('First<br>preferences')<br />
:attr('colspan', 2)<br />
:attr('rowspan', 2)<br />
cols = cols + 2<br />
if has_votes2 then<br />
row<br />
:tag('th')<br />
:wikitext('Subsequent counts')<br />
:attr('colspan', 15)<br />
end<br />
end<br />
if not has_nopercentage then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
if has_votes2 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes3 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes4 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes5 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes6 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes7 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes8 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes9 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes10 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes11 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes12 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
if has_votes13 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('Votes')<br />
:attr('scope', 'col')<br />
:done()<br />
:tag('th')<br />
:wikitext('%')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 2<br />
end<br />
elseif has_nopercentage then<br />
if has_votes2 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('2')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes3 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('3')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes4 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('4')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes5 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('5')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes6 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('6')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes7 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('7')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes8 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('8')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes9 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('9')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes10 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('10')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes11 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('11')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes12 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('12')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
if has_votes13 then<br />
secondrow<br />
:tag('th')<br />
:wikitext('13')<br />
:attr('scope', 'col')<br />
:done()<br />
cols = cols + 1<br />
end<br />
end<br />
<br />
if topcell then<br />
topcell:attr('colspan', cols)<br />
end<br />
<br />
local rsuff = (rounds > 1) and {'', '_2'} or (rounds > 2) and {'', '_3'} or (rounds > 3) and {'', '_4'} or (rounds > 4) and {'', '_5'} or (rounds > 5) and {'', '_6'} or (rounds > 6) and {'', '_7'} or (rounds > 7) and {'', '_8'} or (rounds > 8) and {'', '_9'} or (rounds > 9) and {'', '_10'} or (rounds > 10) and {'', '_11'} or (rounds > 11) and {'', '_12'} or (rounds > 12) and {'', '_13'} or {''}<br />
for i, v in ipairs(index) do<br />
local has_votesrow = args['votes' .. v] or args['ivotes' .. v] or args['avotes' .. v] or args['ipct' .. v] or args['apct' .. v] or args['atotal' .. v]<br />
local has_votesrow2 = args['votes' .. v .. '_2'] or args['ivotes' .. v .. '_2'] or args['avotes' .. v .. '_2'] or args['ipct' .. v .. '_2']<br />
local has_votesrow3 = args['votes' .. v .. '_3'] or args['ivotes' .. v .. '_3'] or args['avotes' .. v .. '_3'] or args['ipct' .. v .. '_3']<br />
local has_votesrow4 = args['votes' .. v .. '_4'] or args['ivotes' .. v .. '_4'] or args['avotes' .. v .. '_4'] or args['ipct' .. v .. '_4']<br />
local has_votesrow5 = args['votes' .. v .. '_5'] or args['ivotes' .. v .. '_5'] or args['avotes' .. v .. '_5'] or args['ipct' .. v .. '_5']<br />
local has_votesrow6 = args['votes' .. v .. '_6'] or args['ivotes' .. v .. '_6'] or args['avotes' .. v .. '_6'] or args['ipct' .. v .. '_6']<br />
local has_votesrow7 = args['votes' .. v .. '_7'] or args['ivotes' .. v .. '_7'] or args['avotes' .. v .. '_7'] or args['ipct' .. v .. '_7']<br />
local has_votesrow8 = args['votes' .. v .. '_8'] or args['ivotes' .. v .. '_8'] or args['avotes' .. v .. '_8'] or args['ipct' .. v .. '_8']<br />
local has_votesrow9 = args['votes' .. v .. '_9'] or args['ivotes' .. v .. '_9'] or args['avotes' .. v .. '_9'] or args['ipct' .. v .. '_9']<br />
local has_votesrow10 = args['votes' .. v .. '_10'] or args['ivotes' .. v .. '_10'] or args['avotes' .. v .. '_10'] or args['ipct' .. v .. '_10']<br />
local has_votesrow11 = args['votes' .. v .. '_11'] or args['ivotes' .. v .. '_11'] or args['avotes' .. v .. '_11'] or args['ipct' .. v .. '_11']<br />
local has_votesrow12 = args['votes' .. v .. '_12'] or args['ivotes' .. v .. '_12'] or args['avotes' .. v .. '_12'] or args['ipct' .. v .. '_12']<br />
local has_votesrow13 = args['votes' .. v .. '_13'] or args['ivotes' .. v .. '_13'] or args['avotes' .. v .. '_13'] or args['ipct' .. v .. '_13']<br />
row = root:tag('tr')<br />
:addClass(args['class' .. v])<br />
:css('font-weight', args['font-weight' .. v])<br />
<br />
-- determine the colors<br />
local color = get_color(args['colour' .. v] or args['color' .. v] or nil, args['party' .. v])<br />
local rcolor = get_color(args['rcolour' .. v] or args['rcolor' .. v] or nil)<br />
<br />
if args['row' .. v] and has_party then<br />
row<br />
:css('background-color', rcolor)<br />
:tag('td')<br />
:attr('colspan', 3)<br />
:wikitext(args['row' .. v])<br />
end<br />
if has_party and not args['row' .. v] then<br />
row<br />
:tag('td')<br />
:css('width', '0px')<br />
:css('background-color', color)<br />
end<br />
if args['cand' .. v] then<br />
row<br />
:css('background-color', rcolor)<br />
:tag('td')<br />
:attr('rowspan', args['candspan' .. v] or args['aspan' .. v])<br />
:wikitext(args['cand' .. v])<br />
end<br />
if has_party and not args['row' .. v] then<br />
row<br />
:tag('td')<br />
:wikitext(args['party' .. v])<br />
end<br />
if has_votes then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v]))<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v], valid[1]))<br />
end<br />
if args['votes' .. v .. '_2'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_2']))<br />
end<br />
if args['votes' .. v .. '_2'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_2'], valid[2]))<br />
end<br />
if args['votes' .. v .. '_3'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_3']))<br />
end<br />
if args['votes' .. v .. '_3'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_3'], valid[3]))<br />
end<br />
if args['votes' .. v .. '_4'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_4']))<br />
end<br />
if args['votes' .. v .. '_4'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_4'], valid[4]))<br />
end<br />
if args['votes' .. v .. '_5'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_5']))<br />
end<br />
if args['votes' .. v .. '_5'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_5'], valid[5]))<br />
end<br />
if args['votes' .. v .. '_6'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_6']))<br />
end<br />
if args['votes' .. v .. '_6'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_6'], valid[6]))<br />
end<br />
if args['votes' .. v .. '_7'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_7']))<br />
end<br />
if args['votes' .. v .. '_7'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_7'], valid[7]))<br />
end<br />
if args['votes' .. v .. '_8'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_8']))<br />
end<br />
if args['votes' .. v .. '_8'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_8'], valid[8]))<br />
end<br />
if args['votes' .. v .. '_9'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_9']))<br />
end<br />
if args['votes' .. v .. '_9'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_9'], valid[9]))<br />
end<br />
if args['votes' .. v .. '_10'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_10']))<br />
end<br />
if args['votes' .. v .. '_10'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_10'], valid[10]))<br />
end<br />
if args['votes' .. v .. '_11'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_11']))<br />
end<br />
if args['votes' .. v .. '_11'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_11'], valid[11]))<br />
end<br />
if args['votes' .. v .. '_12'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_12']))<br />
end<br />
if args['votes' .. v .. '_12'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_12'], valid[12]))<br />
end<br />
if args['votes' .. v .. '_13'] then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(fmt(args['votes' .. v .. '_13']))<br />
end<br />
if args['votes' .. v .. '_13'] and not has_nopercentage then<br />
row:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(pct(args['votes' .. v .. '_13'], valid[13]))<br />
end<br />
end<br />
<br />
-- separating line<br />
if args['valid'] or args['invalidblank'] or args['invalid'] or args['totalvotes'] or args['electorate'] or args['turnout'] or args['source'] then<br />
row = root<br />
:tag('tr')<br />
:addClass('sortbottom')<br />
row<br />
:tag('td')<br />
:css('background', '#eaecf0')<br />
:attr('colspan', cols)<br />
end<br />
-- valid votes<br />
<br />
local cs = 3 - (has_party and 0 or 2)<br />
<br />
if args['invalidblank'] or args['invalid'] then<br />
row = root<br />
:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Valid votes')<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('background', 'inherit')<br />
:tag('td')<br />
:wikitext(fmt(ovalid[1]))<br />
:tag('td')<br />
:wikitext(pct(ovalid[1], ovalid[1] + invalidblank[1] + invalid[1] + blank[1]))<br />
end<br />
-- invalid votes<br />
if args['invalidblank'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Invalid/blank votes')<br />
:wikitext(args.invalidnote)<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('background', 'inherit')<br />
:tag('td')<br />
:wikitext(fmt(invalidblank[1]))<br />
:tag('td')<br />
:wikitext(pct(invalidblank[1], ovalid[1] + invalidblank[1]))<br />
end<br />
if args['invalid'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Invalid votes')<br />
:wikitext(args.invalidnote)<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('background', 'inherit')<br />
:tag('td')<br />
:wikitext(fmt(invalid[1]))<br />
:tag('td')<br />
:wikitext(pct(invalid[1], ovalid[1] + invalid[1] + blank[1]))<br />
end<br />
-- blank votes<br />
if args['blank'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Blank votes')<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('background', 'inherit')<br />
row<br />
:tag('td')<br />
:wikitext(fmt(blank[1]))<br />
:tag('td')<br />
:wikitext(pct(blank[1], ovalid[1] + invalid[1] + blank[1]))<br />
end<br />
-- total<br />
if args['invalidblank'] or args['invalid'] or args['totalvotes'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('font-weight', 'bold')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext(args.tvtitle or 'Total votes')<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('background', 'inherit')<br />
:css('color', 'inherit')<br />
if not args['totalvotes'] and args['invalid'] or not args['totalvotes'] and args['invalidblank'] then<br />
row<br />
:tag('td')<br />
:wikitext(fmt(ovalid[1] + invalidblank[1] + invalid[1] + blank[1]))<br />
:tag('td')<br />
:wikitext(pct(1, 1))<br />
elseif args['totalvotes'] then<br />
row<br />
:tag('td')<br />
:wikitext(fmt(args.totalvotes))<br />
:tag('td')<br />
:wikitext('–')<br />
end<br />
end<br />
-- registered<br />
if args['electorate'] or args['turnout'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Registered voters/turnout')<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('color', 'inherit')<br />
:css('background', 'inherit')<br />
row<br />
:tag('td')<br />
:wikitext(fmt(electorate[1]))<br />
if args['invalidblank'] and args['electorate'] and not args['totalvotes'] or args['invalid'] and args['electorate'] and not args['totalvotes'] then<br />
row<br />
:tag('td')<br />
:wikitext(args.turnout or pct(ovalid[1] + invalidblank[1] + invalid[1] + blank[1], electorate[1]))<br />
elseif args['totalvotes'] and args['electorate'] then<br />
row<br />
:tag('td')<br />
:wikitext(args.turnout or pct(totalvotes[1], electorate[1]))<br />
elseif args['electorate'] then<br />
row<br />
:tag('td')<br />
:wikitext(args.turnout or '–')<br />
else<br />
row<br />
:tag('td')<br />
:wikitext(args.turnout)<br />
end<br />
if args['majority'] then<br />
if args['invalid'] or args['electorate'] then<br />
row = root<br />
:tag('tr')<br />
:addClass('sortbottom')<br />
row<br />
:tag('td')<br />
:css('background', '#eaecf0')<br />
:attr('colspan', cols)<br />
end<br />
row = root<br />
:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row<br />
:tag('th')<br />
:wikitext('Majority')<br />
:attr('scope', 'row')<br />
:attr('colspan', cs)<br />
:css('text-align', 'left')<br />
:css('font-weight', 'normal')<br />
:css('background', 'inherit')<br />
:tag('td')<br />
:wikitext(fmt(majority[k]))<br />
:tag('td')<br />
:wikitext(fmt(majoritypct[k]))<br />
end<br />
end<br />
if args['result'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
-- determine the color<br />
local color = get_color(args['resultcolour'] or nil, args['result'])<br />
if args['resultsw'] then<br />
row<br />
:tag('td')<br />
:css('background-color', color)<br />
row<br />
:tag('td')<br />
:attr('colspan', 2)<br />
:wikitext(args['result'])<br />
row<br />
:tag('td')<br />
:attr('colspan', 2)<br />
:css('text-align', 'right')<br />
:wikitext('Swing')<br />
row<br />
:tag('td')<br />
:css('text-align', 'right')<br />
:wikitext(args['resultsw'])<br />
else<br />
row<br />
:tag('td')<br />
:css('background-color', color)<br />
row<br />
:tag('td')<br />
:attr('colspan', cols - 1)<br />
:wikitext(args['result'])<br />
end<br />
end<br />
if args['source'] then<br />
row = root:tag('tr')<br />
:addClass('sortbottom')<br />
:css('text-align', 'right')<br />
row:tag('td')<br />
:wikitext('Source: ', args.source)<br />
:attr('colspan', cols)<br />
:css('text-align', 'left')<br />
end<br />
if args['embedded'] then<br />
root:wikitext(args['embedded'])<br />
end<br />
return tostring(root) .. tracking<br />
end<br />
<br />
return p</div>
Closed Limelike Curves