Module:Election results and Module:Election results/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Per request on talk |
+ |
||
Line 9: | Line 9: | ||
local winner, winner_votes = {0, 0, 0}, {0, 0, 0} |
local winner, winner_votes = {0, 0, 0}, {0, 0, 0} |
||
local valid = {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 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} |
local blank = {tonumber(args.blank) or 0, tonumber(args.blank2) or 0, tonumber(args.blank3) or 0} |
||
Line 75: | Line 76: | ||
local stop_flag = false |
local stop_flag = false |
||
local i = 0 |
local i = 0 |
||
local has_votes = args['invalid'] or args['totalvotes'] or args['electorate'] or args['turnout'] |
local has_votes = args['invalidblank'] or args['invalid'] or args['totalvotes'] or args['electorate'] or args['turnout'] |
||
local has_votes2 = args['invalid2'] or args['totalvotes2'] or args['electorate2'] or args['turnout2'] |
local has_votes2 = args['invalidblank2'] or args['invalid2'] or args['totalvotes2'] or args['electorate2'] or args['turnout2'] |
||
local has_votes3 = args['votes' .. i .. '_3'] or args['ivotes' .. i .. '_3'] |
local has_votes3 = args['votes' .. i .. '_3'] or args['ivotes' .. i .. '_3'] |
||
local has_seats2 = args['seats' .. i .. '_2'] or args['iseats' .. i .. '_2'] |
local has_seats2 = args['seats' .. i .. '_2'] or args['iseats' .. i .. '_2'] |
||
Line 141: | Line 142: | ||
rounds = (rounds < 2) and 2 or rounds |
rounds = (rounds < 2) and 2 or rounds |
||
end |
end |
||
if args['valid2'] or args['invalid2'] or args['totalvotes2'] or args['electorate2'] or args['turnout2'] then |
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 |
rounds = (rounds < 2) and 2 or rounds |
||
end |
end |
||
Line 1,038: | Line 1,039: | ||
end |
end |
||
-- separating line |
-- separating line |
||
if args['valid'] or args['valid2'] or args['valid3'] or args['invalid'] or args['invalid2'] or args['invalid3'] 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 |
if args['valid'] or args['valid2'] or args['valid3'] or args['invalidblank'] or args['invalidblank2'] or args['invalidblank3'] or args['invalid'] or args['invalid2'] or args['invalid3'] 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 |
row = root |
||
:tag('tr') |
:tag('tr') |
||
Line 1,048: | Line 1,049: | ||
end |
end |
||
-- valid votes |
-- valid votes |
||
if args['invalid'] or args['invalid2'] or args['invalid3'] then |
if args['invalidblank'] or args['invalidblank2'] or args['invalidblank3'] or args['invalid'] or args['invalid2'] or args['invalid3'] then |
||
row = root |
row = root |
||
:tag('tr') |
:tag('tr') |
||
Line 1,061: | Line 1,062: | ||
:css('font-weight', 'normal') |
:css('font-weight', 'normal') |
||
:css('background', 'inherit') |
:css('background', 'inherit') |
||
if args['invalid'] then |
if args['invalidblank'] or args['invalid'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[1])) |
:wikitext(fmt(ovalid[1])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(ovalid[1], ovalid[1] + invalid[1] + blank[1])) |
:wikitext(pct(ovalid[1], ovalid[1] + invalidblank[1] + invalid[1] + blank[1])) |
||
elseif not args['invalid'] then |
elseif not args['invalid'] or not args['invalidblank'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,092: | Line 1,093: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if rounds > 1 and args['invalid2'] then |
if rounds > 1 and args['invalidblank2'] or rounds > 1 and args['invalid2'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[2])) |
:wikitext(fmt(ovalid[2])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(ovalid[2], ovalid[2] + invalid[2] + blank[2])) |
:wikitext(pct(ovalid[2], ovalid[2] + invalidblank[2] + invalid[2] + blank[2])) |
||
elseif rounds > 1 and not args['invalid2'] then |
elseif rounds > 1 and not args['invalidblank2'] or rounds > 1 and not args['invalid2'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,123: | Line 1,124: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if args['invalid3'] then |
if args['invalidblank3'] or args['invalid3'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[3])) |
:wikitext(fmt(ovalid[3])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(ovalid[3], ovalid[3] + invalid[3] + blank[3])) |
:wikitext(pct(ovalid[3], ovalid[3] + invalidblank[3] + invalid[3] + blank[3])) |
||
elseif has_seats3 and not args['invalid3'] then |
elseif has_seats3 and not args['invalidblank3'] or has_seats3 and not args['invalid3'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,156: | Line 1,157: | ||
:addClass('sortbottom') |
:addClass('sortbottom') |
||
:css('text-align', 'right') |
:css('text-align', 'right') |
||
if args['invalidblank'] then |
|||
row |
row |
||
:tag('th') |
:tag('th') |
||
:wikitext('Invalid votes') |
:wikitext('Invalid/blank votes') |
||
:wikitext(args.invalidnote) |
|||
:attr('scope', 'row') |
:attr('scope', 'row') |
||
:attr('colspan', cs) |
:attr('colspan', cs) |
||
Line 1,165: | Line 1,167: | ||
:css('font-weight', 'normal') |
:css('font-weight', 'normal') |
||
:css('background', 'inherit') |
:css('background', 'inherit') |
||
elseif args['invalid'] then |
|||
else |
|||
row |
row |
||
:tag('th') |
:tag('th') |
||
:wikitext('Invalid |
:wikitext('Invalid votes') |
||
:wikitext(args.invalidnote) |
:wikitext(args.invalidnote) |
||
:attr('scope', 'row') |
:attr('scope', 'row') |
||
Line 1,176: | Line 1,178: | ||
:css('background', 'inherit') |
:css('background', 'inherit') |
||
end |
end |
||
if args[' |
if args['invalidblank'] then |
||
row |
|||
:tag('td') |
|||
:wikitext(fmt(invalidblank[1])) |
|||
:tag('td') |
|||
:wikitext(pct(invalidblank[1], ovalid[1] + invalidblank[1])) |
|||
elseif args['invalid'] then |
|||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,182: | Line 1,190: | ||
:tag('td') |
:tag('td') |
||
:wikitext(pct(invalid[1], ovalid[1] + invalid[1] + blank[1])) |
:wikitext(pct(invalid[1], ovalid[1] + invalid[1] + blank[1])) |
||
elseif not args['invalid'] then |
elseif not args['invalidblank'] or not args['invalid'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,207: | Line 1,215: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if rounds > 1 and args[' |
if rounds > 1 and args['invalidblank2'] then |
||
row |
|||
:tag('td') |
|||
:wikitext(fmt(invalidblank[2])) |
|||
:tag('td') |
|||
:wikitext(pct(invalidblank[2], ovalid[2] + invalidblank[2])) |
|||
elseif rounds > 1 and args['invalid2'] then |
|||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,213: | Line 1,227: | ||
:tag('td') |
:tag('td') |
||
:wikitext(pct(invalid[2], ovalid[2] + invalid[2] + blank[2])) |
:wikitext(pct(invalid[2], ovalid[2] + invalid[2] + blank[2])) |
||
elseif rounds > 1 and not args['invalid2'] then |
elseif rounds > 1 and not args['invalid2'] or rounds > 1 and not args['invalidblank2'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,238: | Line 1,252: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if has_seats3 and args[' |
if has_seats3 and args['invalidblank3'] or has_votes3 and args['invalidblank3'] then |
||
row |
|||
:tag('td') |
|||
:wikitext(fmt(invalidblank[3])) |
|||
:tag('td') |
|||
:wikitext(pct(invalidblank[3], ovalid[3] + invalidblank[3] + invalid[3] + blank[3])) |
|||
elseif has_seats3 and args['invalid3'] or has_votes3 and args['invalid3'] then |
|||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,244: | Line 1,264: | ||
:tag('td') |
:tag('td') |
||
:wikitext(pct(invalid[3], ovalid[3] + invalid[3] + blank[3])) |
:wikitext(pct(invalid[3], ovalid[3] + invalid[3] + blank[3])) |
||
elseif has_seats3 and not args['invalid3'] then |
elseif has_seats3 and not args['invalidblank3'] or has_seats3 and not args['invalid3'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,364: | Line 1,384: | ||
end |
end |
||
-- total |
-- total |
||
if args['invalid'] or args['totalvotes'] or args['invalid2'] or args['totalvotes2'] then |
if args['invalidblank'] or args['invalid'] or args['totalvotes'] or args['invalidblank2'] or args['invalid2'] or args['totalvotes2'] then |
||
row = root:tag('tr') |
row = root:tag('tr') |
||
:addClass('sortbottom') |
:addClass('sortbottom') |
||
Line 1,377: | Line 1,397: | ||
:css('background', 'inherit') |
:css('background', 'inherit') |
||
:css('color', 'inherit') |
:css('color', 'inherit') |
||
if not args['totalvotes'] and args['invalid'] then |
if not args['totalvotes'] and args['invalid'] or not args['totalvotes'] and args['invalidblank'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[1] + invalid[1] + blank[1])) |
:wikitext(fmt(ovalid[1] + invalidblank[1] + invalid[1] + blank[1])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(1, 1)) |
:wikitext(pct(1, 1)) |
||
Line 1,389: | Line 1,409: | ||
:tag('td') |
:tag('td') |
||
:wikitext('–') |
:wikitext('–') |
||
elseif not args['invalid'] and not args['totalvotes'] then |
elseif not args['invalid'] and not args['totalvotes'] or not args['invalidblank'] and not args['totalvotes']then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
Line 1,414: | Line 1,434: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if rounds > 1 and args['invalid2'] and not args['totalvotes2'] then |
if rounds > 1 and args['invalid2'] and not args['totalvotes2'] or rounds > 1 and args['invalidblank2'] and not args['totalvotes2'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[2] + invalid[2] + blank[2])) |
:wikitext(fmt(ovalid[2] + invalidblank[2] + invalid[2] + blank[2])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(1, 1)) |
:wikitext(pct(1, 1)) |
||
Line 1,451: | Line 1,471: | ||
:wikitext() |
:wikitext() |
||
end |
end |
||
if has_seats3 and not args['totalvotes3'] and args[' |
if has_seats3 and not args['totalvotes3'] and args['invalidblank3'] or has_votes3 and not args['totalvotes3'] and args['invalid3'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(ovalid[3] + invalid[3] + blank[3])) |
:wikitext(fmt(ovalid[3] + invalidblank[3] + invalid[3] + blank[3])) |
||
:tag('td') |
:tag('td') |
||
:wikitext(pct(1, 1)) |
:wikitext(pct(1, 1)) |
||
Line 1,503: | Line 1,523: | ||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(electorate[1])) |
:wikitext(fmt(electorate[1])) |
||
if args['invalid'] and args['electorate'] and not args['totalvotes'] then |
if args['invalidblank'] and args['electorate'] and not args['totalvotes'] or args['invalid'] and args['electorate'] and not args['totalvotes'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(args.turnout or pct(ovalid[1] + invalid[1] + blank[1], electorate[1])) |
:wikitext(args.turnout or pct(ovalid[1] + invalidblank[1] + invalid[1] + blank[1], electorate[1])) |
||
elseif args['totalvotes'] and args['electorate'] then |
elseif args['totalvotes'] and args['electorate'] then |
||
row |
row |
||
Line 1,542: | Line 1,562: | ||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(electorate[2])) |
:wikitext(fmt(electorate[2])) |
||
if args['invalid2'] and args['electorate2'] then |
if args['invalid2'] and args['electorate2'] or args['invalidblank2'] and args['electorate2'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(args.turnout2 or pct(ovalid[2] + invalid[2] + blank[2], electorate[2])) |
:wikitext(args.turnout2 or pct(ovalid[2] + invalidblank[2] + invalid[2] + blank[2], electorate[2])) |
||
elseif args['totalvotes2'] and args['electorate2'] then |
elseif args['totalvotes2'] and args['electorate2'] then |
||
row |
row |
||
Line 1,582: | Line 1,602: | ||
:tag('td') |
:tag('td') |
||
:wikitext(fmt(electorate[3])) |
:wikitext(fmt(electorate[3])) |
||
if args['invalid3'] and args['electorate3'] then |
if args['invalid3'] and args['electorate3'] or args['invalidblank3'] and args['electorate3'] then |
||
row |
row |
||
:tag('td') |
:tag('td') |
||
:wikitext(args.turnout3 or pct(ovalid[3] + invalid[3] + blank[3], electorate[3])) |
:wikitext(args.turnout3 or pct(ovalid[3] + invalidblank[3] + invalid[3] + blank[3], electorate[3])) |
||
elseif args['totalvotes3'] and args['electorate3'] then |
elseif args['totalvotes3'] and args['electorate3'] then |
||
row |
row |