יחידה:Election results – הבדלי גרסאות

totalvotes paramter for when invalid/valid split isn't known (e.g. 2013 Caymanian general election)
(Switch Invalid/blank votes to Invalid votes for cases where blank votes are valid)
(totalvotes paramter for when invalid/valid split isn't known (e.g. 2013 Caymanian general election))
local valid = {0, 0}
local invalid = {tonumber(args.invalid) or 0, tonumber(args.invalid2) or 0}
local totalvotes = {tonumber(args.totalvotes) or 0, tonumber(args.totalvotes2) or tonumber(args.totalvotes) or 0}
local electorate = {tonumber(args.electorate) or 0, tonumber(args.electorate2) or tonumber(args.electorate) or 0}
local turnout = {tonumber(args.turnout) or 0, tonumber(args.turnout2) or 0}
for kk = 1, 20 do
i = i + 1
for k, key in ipairs({'cand', 'vp', 'party', 'sc', 'sw', 'seats', 'totalvotes'}) do
if args[key .. i] then
headings[key] = true
local cspan = (headings['sw'] and 1 or 0) + (headings['seats'] and 1 or 0) + (headings['sc'] and 1 or 0)
row
:tag('td')
:attr('colspan', cspan > 1 and cspan or nil)
end
end
if args['totalvotes'] then
row = root:tag('tr')
:addClass('sortbottom')
:css('font-weight', 'bold')
:css('text-align', 'right')
row
:tag('th')
:wikitext('Total votes')
:attr('scope', 'row')
:attr('colspan', cs)
:css('text-align', 'left')
:css('background', 'inherit')
for k=1,rounds do
row
:tag('td')
:wikitext(fmt(totalvotes[k]))
:tag('td')
:wikitext('–')
end
if headings['sw'] or headings['seats'] or headings['sc'] then
local cspan = (headings['sw'] and 1 or 0) + (headings['seats'] and 1 or 0) + (headings['sc'] and 1 or 0)
row
:tag('td')
:attr('colspan', cspan > 1 and cspan or nil)
row:tag('td')
:wikitext(pct(ovalid[k] + invalid[k], electorate[k]))
end
elseif args['totalvotes'] then
for k=1,rounds do
row:tag('td')
:wikitext(fmt(electorate[k]))
row:tag('td')
:wikitext(pct(totalvotes[k], electorate[k]))
end
else