Module:NPVIC table explained

local p =

local state_links =

function p._showtable(frame, args) local reference_heading = frame:expandTemplate 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
electoral
votes (EVs)') local k = 1 local EVs = 0 while args['state' .. k] do local seats = args['state' .. k]

'DC' and 1 or frame:expandTemplate 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 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 rootend

function p.main(frame) local args = require('Module:Arguments').getArgs(frame) return p._showtable(frame, args)end

return p