Module:NPVIC table
| This module is rated as beta. It is considered ready for widespread use, but as it is still relatively new, it should be applied with some caution to ensure results are as expected. |
See {{NPVIC table}} for usage.
See also
local p = {}
local state_links = {
["AL"] = "[[Alabama]]",
["AK"] = "[[Alaska]]",
["AZ"] = "[[Arizona]]",
["AR"] = "[[Arkansas]]",
["CA"] = "[[California]]",
["CO"] = "[[Colorado]]",
["CT"] = "[[Connecticut]]",
["DE"] = "[[Delaware]]",
["DC"] = "[[Washington, D.C.|District of Columbia]]",
["FL"] = "[[Florida]]",
["GA"] = "[[Georgia (U.S. state)|Georgia]]",
["HI"] = "[[Hawaii]]",
["ID"] = "[[Idaho]]",
["IL"] = "[[Illinois]]",
["IN"] = "[[Indiana]]",
["IA"] = "[[Iowa]]",
["KS"] = "[[Kansas]]",
["KY"] = "[[Kentucky]]",
["LA"] = "[[Louisiana]]",
["ME"] = "[[Maine]]",
["MD"] = "[[Maryland]]",
["MA"] = "[[Massachusetts]]",
["MI"] = "[[Michigan]]",
["MN"] = "[[Minnesota]]",
["MS"] = "[[Mississippi]]",
["MO"] = "[[Missouri]]",
["MT"] = "[[Montana]]",
["NE"] = "[[Nebraska]]",
["NV"] = "[[Nevada]]",
["NH"] = "[[New Hampshire]]",
["NJ"] = "[[New Jersey]]",
["NM"] = "[[New Mexico]]",
["NY"] = "[[New York (state)|New York]]",
["NC"] = "[[North Carolina]]",
["ND"] = "[[North Dakota]]",
["OH"] = "[[Ohio]]",
["OK"] = "[[Oklahoma]]",
["OR"] = "[[Oregon]]",
["PA"] = "[[Pennsylvania]]",
["RI"] = "[[Rhode Island]]",
["SC"] = "[[South Carolina]]",
["SD"] = "[[South Dakota]]",
["TN"] = "[[Tennessee]]",
["TX"] = "[[Texas]]",
["UT"] = "[[Utah]]",
["VT"] = "[[Vermont]]",
["VA"] = "[[Virginia]]",
["WA"] = "[[Washington (state)|Washington]]",
["WV"] = "[[West Virginia]]",
["WI"] = "[[Wisconsin]]",
["WY"] = "[[Wyoming]]"
}
function p._showtable(frame, args)
local reference_heading = frame:expandTemplate{title = 'Reference column heading'}
local root = mw.html.create('table')
:addClass('wikitable sortable')
:css('line-height', 1.2)
:css('margin-left', 'auto')
:css('margin-right', 'auto')
-- table title
root:tag('caption'):wikitext('Jurisdictions enacting law to join the National Popular Vote Interstate Compact')
-- header row
local row = root:tag('tr')
row:tag('th'):attr('scope', 'col'):wikitext('No.')
row:tag('th'):attr('scope', 'col'):wikitext('Jurisdiction')
row:tag('th'):attr('scope', 'col'):attr('data-sort-type', 'date'):wikitext('Date adopted')
row:tag('th'):attr('scope', 'col'):attr('class','unsortable'):wikitext('Method of adoption')
row:tag('th'):attr('scope', 'col'):attr('class','unsortable'):wikitext(reference_heading)
row:tag('th'):attr('scope', 'col'):wikitext('Current<br/>electoral<br/>votes')
local k = 1
local EVs = 0
while args['state' .. k] do
local seats = args['state' .. k] == 'DC' and 1 or frame:expandTemplate{ title = 'USHRseats', args = {args['state' .. k]}}
row = root:tag('tr')
row:tag('th'):attr('scope', 'row'):wikitext(k)
row:tag('td'):wikitext(state_links[args['state' .. k]] or args['state' .. k])
row:tag('td'):css('text-align','right'):wikitext(args['date' .. k])
row:tag('td'):wikitext(args['method' .. k])
row:tag('td'):css('text-align','center'):wikitext(args['ref' .. k])
row:tag('td'):css('text-align','center'):wikitext(tonumber(seats) + 2)
EVs = EVs + tonumber(seats) + 2
k = k + 1
end
local percent = frame:expandTemplate{ title = 'percent', args = { EVs, 270, 1} }
row = root:tag('tr'):addClass('sortbottom')
row:tag('th'):attr('colspan', 5):css('text-align', 'right'):wikitext('Total')
row:tag('th'):css('text-align', 'center'):wikitext(EVs)
row = root:tag('tr'):addClass('sortbottom')
row:tag('th'):attr('colspan', 5):css('text-align', 'right'):wikitext('Percentage of the 270 EVs needed')
row:tag('th'):css('text-align', 'center'):wikitext(percent)
return root
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame)
return p._showtable(frame, args)
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.