Jump to content

Module:NPVIC status

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Swpb (talk | contribs) at 16:12, 4 January 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}

function p.states(frame)
	local states = frame.args[1] or frame:expandTemplate{ title = 'section transpose', args = { frame.args['section'] } }
	local total = 0
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		if state~='DC' then
			total = total + 1
		end
	end
	return total
end

function p.EVs(frame)
	local states = frame.args[1] or frame:expandTemplate{ title = 'section transpose', args = { frame.args['section'] } }
	local total = 0
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		seats = frame:expandTemplate{ title = 'USHRseats', args = { state } }
		if type(tonumber(seats))=='nil' then
			total = error("Unrecognized state")
			break
		else
			total = total + seats + 2
		end
	end
	return total
end

function p.overlays(frame)
	local states = frame.args[1] or frame:expandTemplate{ title = 'section transpose', args = { frame.args['section'] } }
	local color = frame.args[2] or frame.args['color']
	local size = frame.args[3] or frame.args['size']
	local overlays = ''
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		state_overlay = '<div style=\"position: absolute; left: 0px; top: 0px\">[[File:' .. state .. ' ' .. color .. '.svg|' .. size .. ']]</div>'
		overlays = overlays .. state_overlay
	end
	return overlays
end

function p.signatories(frame)
	local states = frame.args[1] or frame:expandTemplate{ title = 'section transpose', args = { frame.args['section'] } }
	local signatories = ''
	for state in mw.ustring.gmatch( states, "%a%a" ) do
		state_name = frame:expandTemplate{ title = 'US State Abbrev', args = { state } }
		local dab = ''
		if state_name=='New York' or state_name=='Washington' then
			dab=' (state)'
		end
		signatories = signatories .. '\n* ' .. frame:expandTemplate{ title = 'flagicon', args = { state_name } } .. '&nbsp;[[' ..  state_name .. dab .. '|' ..  state_name .. ']]'
	end
	return signatories
end

return p