Module:Infobox election/sandbox: Difference between revisions

Content deleted Content added
debug
Fix "ongoing" tests
Line 11:
local function _row(frame, rargs)
local rtype = mw.ustring.lower(rargs.type or '')
local ongoing = rargs.ongoing == 'yes'
local output = {'|-'}
setmetatable(output, {__call = function (t, v) t[#t+1] = v end }) -- Append to array by calling it
Line 37 ⟶ 38:
end
output('|- class="sr-only"')
if rargs.not ongoing ~= "yes" and (
rtype == "parliamentary" or rtype == "legislative"
) and (
Line 82 ⟶ 83:
),
suppressplaceholder = 'yes',
class = notblank(rargs['pageimage' .. i]) and '' or 'notpageimage noresize'),
}
} )
Line 112 ⟶ 113:
threeCells('running_mate')
-- Electoral vote --
if not ongoing then
threeCells('electoral_vote', (rargs.college_voted == 'no' and 'Projected e' or 'E') .. 'lectoral vote')
end
end
-- Delegate count --
threeCells('delegate_count', (rargs.ongoing == 'yes' and 'Estimated d' or 'D') .. 'elegate count')
-- StatesPrimary carriedonly --
threeCells('states_carried',if rtype == 'primary' and 'Contests won' or 'States carried')then
-- Contests won
threeCells('states_carried', 'Contests won')
-- Presidential not ongoing --
elseif not ongoing then
-- States carried --
threeCells('states_carried', 'States carried')
end
end
-- Parliamentary or legislative --
Line 128 ⟶ 138:
threeCells('last_election')
-- Seats before --
threeCells('seats_before', rargs.ongoing == 'yes' and 'Current seats' or 'Seats before')
-- Ongoing --
if rargs.ongoing == 'yes' then
-- Seats needed --
threeCells('seats_needed')
Line 144 ⟶ 154:
end
-- Primary or not ongoing --
if rargs.not ongoing ~= 'yes' or rtype == 'primary' then
-- Popular vote --
threeCells('popular_vote', (rargs.vote_type or 'Popular') .. ' vote')
Line 160 ⟶ 170:
threeCells('counties_won')
-- Counties 25% threshold --
threeCells('counties_threshholdcounties_threshold', 'Counties with 25% vote')
end
end
-- Swing --
if (rtype == 'parliamentary' or rtype == 'legislative') and rargs.not ongoing ~= 'yes' then
threeCells('swing')
end