Module:Election results/sandbox: Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile web edit Advanced mobile edit
+
Line 9:
local winner, winner_votes = {0, 0, 0}, {0, 0, 0}
local valid = {0, 0, 0}
local invalidblank = {tonumber(args.invalidblank) or 0, tonumber(args.invalidblank2) or 0, tonumber(args.invalidblank3) or 0}
local invalid = {tonumber(args.invalid) or 0, tonumber(args.invalid2) or 0, tonumber(args.invalid3) or 0}
local blank = {tonumber(args.blank) or 0, tonumber(args.blank2) or 0, tonumber(args.blank3) or 0}
Line 75 ⟶ 76:
local stop_flag = false
local i = 0
local has_votes = args['invalidinvalidblank'] or args['totalvotes'] or args['electorate'] or args['turnout']
local has_votes2 = args['invalid2invalidblank2'] or args['totalvotes2'] or args['electorate2'] or args['turnout2']
local has_votes3 = args['votes' .. i .. '_3'] or args['ivotes' .. i .. '_3']
local has_seats2 = args['seats' .. i .. '_2'] or args['iseats' .. i .. '_2']
Line 141 ⟶ 142:
rounds = (rounds < 2) and 2 or rounds
end
if args['valid2'] or args['invalidblank2'] or args['invalid2'] or args['totalvotes2'] or args['electorate2'] or args['turnout2'] then
rounds = (rounds < 2) and 2 or rounds
end
Line 1,038 ⟶ 1,039:
end
-- separating line
if args['valid'] or args['valid2'] or args['valid3'] or args['invalidinvalidblank'] or args['invalid2invalidblank2'] or args['invalid3invalidblank3'] or args['totalvotes'] or args['totalvotes2'] or args['totalvotes3'] or args['electorate'] or args['electorate2'] or args['electorate3'] or args['turnout'] or args['turnout2'] or args['turnout3'] or args['source'] then
row = root
:tag('tr')
Line 1,048 ⟶ 1,049:
end
-- valid votes
if args['invalidblank'] or args['invalidblank2'] or args['invalidblank3'] or args['invalid'] or args['invalid2'] or args['invalid3'] then
row = root
:tag('tr')
Line 1,061 ⟶ 1,062:
:css('font-weight', 'normal')
:css('background', 'inherit')
if args['invalidblank'] or args['invalid'] then
row
:tag('td')
:wikitext(fmt(ovalid[1]))
:tag('td')
:wikitext(pct(ovalid[1], ovalid[1] + invalidblank[1] + invalid[1] + blank[1]))
elseif not args['invalid'] or not args['invalidblank'] then
row
:tag('td')
Line 1,092 ⟶ 1,093:
:wikitext()
end
if rounds > 1 and args['invalidblank2'] or rounds > 1 and args['invalid2'] then
row
:tag('td')
:wikitext(fmt(ovalid[2]))
:tag('td')
:wikitext(pct(ovalid[2], ovalid[2] + invalidblank[2] + invalid[2] + blank[2]))
elseif rounds > 1 and not args['invalidblank2'] or rounds > 1 and not args['invalid2'] then
row
:tag('td')
Line 1,123 ⟶ 1,124:
:wikitext()
end
if args['invalidblank3'] or args['invalid3'] then
row
:tag('td')
:wikitext(fmt(ovalid[3]))
:tag('td')
:wikitext(pct(ovalid[3], ovalid[3] + invalidblank[3] + invalid[3] + blank[3]))
elseif has_seats3 and not args['invalidblank3'] or has_seats3 and not args['invalid3'] then
row
:tag('td')
Line 1,156 ⟶ 1,157:
:addClass('sortbottom')
:css('text-align', 'right')
if args['invalidonly'] or args['blankinvalidblank'] then
row
:tag('th')
:wikitext('Invalid/blank votes')
:wikitext(args.invalidnote)
:attr('scope', 'row')
:attr('colspan', cs)
Line 1,165 ⟶ 1,167:
:css('font-weight', 'normal')
:css('background', 'inherit')
elseif args['invalid'] then
else
row
:tag('th')
:wikitext('Invalid/blank votes')
:wikitext(args.invalidnote)
:attr('scope', 'row')
Line 1,176 ⟶ 1,178:
:css('background', 'inherit')
end
if args['invalidinvalidblank'] then
row
:tag('td')
:wikitext(fmt(invalid[1]))
:tag('td')
:wikitext(pct(invalid[1], ovalid[1] + invalidblank[1]))
elseif args['invalid'] then
row
:tag('td')
Line 1,182 ⟶ 1,190:
:tag('td')
:wikitext(pct(invalid[1], ovalid[1] + invalid[1] + blank[1]))
elseif not args['invalidblank'] or not args['invalid'] then
row
:tag('td')