Module:NPVIC status and Module:NPVIC status/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Brainiac242 (talk | contribs) Avoided redirect for Georgia. Clean-up. |
No edit summary |
||
Line 2: | Line 2: | ||
function getstates(frame) |
function getstates(frame) |
||
local states = frame:expandTemplate{ title = 'section transclude', args = { frame.args[ |
local states = frame:expandTemplate{ title = 'section transclude', args = { frame.args['section'] } } |
||
if states == '' then |
if states == '' then |
||
states = frame.args[1] |
|||
end |
|||
return states |
return states |
||
end |
end |
||
Line 15: | Line 17: | ||
for state in mw.ustring.gmatch( states, "%a%a" ) do |
for state in mw.ustring.gmatch( states, "%a%a" ) do |
||
seats = frame:expandTemplate{ title = 'USHRseats', args = { state } } |
seats = frame:expandTemplate{ title = 'USHRseats', args = { state } } |
||
if state |
if state=='DC' then seats=1 end |
||
if type(tonumber(seats)) |
if type(tonumber(seats))=='nil' then |
||
total = error("Unrecognized state") |
total = error("Unrecognized state") |
||
break |
break |
||
Line 29: | Line 31: | ||
function p.percent(frame) |
function p.percent(frame) |
||
local EVs = p.EVs(frame) |
local EVs = p.EVs(frame) |
||
⚫ | |||
⚫ | |||
denom = frame.args[1] |
|||
⚫ | |||
else |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
places = frame.args[2] |
|||
else |
|||
⚫ | |||
end |
|||
percent = frame:expandTemplate{ title = 'percent', args = { EVs, denom, places} } |
percent = frame:expandTemplate{ title = 'percent', args = { EVs, denom, places} } |
||
return percent |
return percent |
||
Line 41: | Line 49: | ||
local total = 0 |
local total = 0 |
||
for state in mw.ustring.gmatch( states, "%a%a" ) do |
for state in mw.ustring.gmatch( states, "%a%a" ) do |
||
if state |
if state~='DC' then |
||
total = total + 1 |
|||
end |
|||
end |
end |
||
if total |
if total==0 then |
||
return frame:expandTemplate{ title = 'error', args = { 'Value not available when editing this section in isolation.' } } |
return frame:expandTemplate{ title = 'error', args = { 'Value not available when editing this section in isolation.' } } |
||
else |
else |
||
if frame.args[ |
if frame.args[1]=='spell' then |
||
total = frame:expandTemplate{ title = 'spellnum per MOS', args = { total } } |
total = frame:expandTemplate{ title = 'spellnum per MOS', args = { total } } |
||
end |
end |
||
Line 56: | Line 66: | ||
local states = getstates(frame) |
local states = getstates(frame) |
||
local size = frame.args['size'] or '325px' |
local size = frame.args['size'] or '325px' |
||
if frame.args[ |
if frame.args['section']=='passed' then |
||
color = 'green' |
color = 'green' |
||
elseif frame.args[ |
elseif frame.args['section']=='pending' then |
||
color = 'yellow' |
color = 'yellow' |
||
end |
end |
||
local overlays = '' |
local overlays = '' |
||
for state in mw.ustring.gmatch( states, "%a%a" ) do |
for state in mw.ustring.gmatch( states, "%a%a" ) do |
||
Line 76: | Line 86: | ||
for state in mw.ustring.gmatch( states, "%a%a" ) do |
for state in mw.ustring.gmatch( states, "%a%a" ) do |
||
state_name = frame:expandTemplate{ title = 'US State Abbrev', args = { state } } |
state_name = frame:expandTemplate{ title = 'US State Abbrev', args = { state } } |
||
local |
local dab = '' |
||
if |
if state_name=='New York' or state_name=='Washington' then |
||
dab=' (state)' |
|||
link_target = 'Washington, D.C.' |
|||
elseif state == 'GA' then |
|||
link_target = 'Georgia (U.S. state)' |
|||
elseif state == 'NY' then |
|||
link_target = 'New York (state)' |
|||
elseif state == 'WA' then |
|||
link_target = 'Washington (state)' |
|||
end |
end |
||
signatories = signatories .. '\n* ' .. ' [[' .. |
signatories = signatories .. '\n* ' .. ' [[' .. state_name .. dab .. '|' .. state_name .. ']]' |
||
end |
end |
||
return signatories |
return signatories |
||
Line 95: | Line 99: | ||
-- |
-- |
||
--end |
--end |
||
return p |
return p |