Module:Election results: Difference between revisions

Administrator (talk | contribs)
No edit summary
Administrator (talk | contribs)
Remove final row
Line 34: Line 34:
local lang = mw.getContentLanguage()
local lang = mw.getContentLanguage()
local function fmt(n)
local function fmt(n)
-- Check if vote totals should be hidden
if args.no_percentages == "true" then
return '–'
end
return n and tonumber(n) and lang:formatNum(tonumber(n)) or nil
return n and tonumber(n) and lang:formatNum(tonumber(n)) or nil
end
end
Line 233: Line 229:
end
end


local ovalid = {valid[1], valid[2], valid[3]}
local ovalid = {valid[1], valid[2], valid[3]}
seats = ((args['total_seats'] or '') == 'TOTAL' and seats) or args['total_seats'] or seats
seats = ((args['total_seats'] or '') == 'TOTAL' and seats) or args['total_seats'] or seats
totseats = ((args['total_totseats'] or '') == 'TOTAL' and totseats) or args['total_totseats'] or totseats
totseats = ((args['total_totseats'] or '') == 'TOTAL' and totseats) or args['total_totseats'] or totseats
Line 241: Line 237:
st4t = ((args['total_st4t'] or '') == 'TOTAL' and st4t) or args['total_st4t'] or st4t
st4t = ((args['total_st4t'] or '') == 'TOTAL' and st4t) or args['total_st4t'] or st4t
st5t = ((args['total_st5t'] or '') == 'TOTAL' and st5t) or args['total_st5t'] or st5t
st5t = ((args['total_st5t'] or '') == 'TOTAL' and st5t) or args['total_st5t'] or st5t
if seats or totseats or st1t or st2t or st3t or st4t or st5t or args['total_sc'] or args['total_st1t'] or args['total_st2t'] or args['total_st3t'] or args['total_st4t'] or args['total_st5t'] or args['valid'] or ((rounds > 1) and args['valid2']) or ((rounds > 1) and args['valid3']) then
-- Skip adding total row if no_totals is set to true
if args.no_percentages ~= "true" and (seats or totseats or st1t or st2t or st3t or st4t or st5t or args['total_sc'] or args['total_st1t'] or args['total_st2t'] or args['total_st3t'] or args['total_st4t'] or args['total_st5t'] or args['valid'] or ((rounds > 1) and args['valid2']) or ((rounds > 1) and args['valid3'])) then
max_rows = max_rows + 1
max_rows = max_rows + 1
local i = max_rows
local i = max_rows
Line 269: Line 267:
ovalid[3] = tonumber(args['valid3']) or valid[3]
ovalid[3] = tonumber(args['valid3']) or valid[3]
end
end
-- build the table
-- build the table
local root = mw.html.create(args['embed'] and '' or 'table')
local root = mw.html.create(args['embed'] and '' or 'table')