<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AUS_elections_imagemap</id>
	<title>Module:US elections imagemap - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AUS_elections_imagemap"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:US_elections_imagemap&amp;action=history"/>
	<updated>2026-04-21T01:55:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:US_elections_imagemap&amp;diff=479840&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:US_elections_imagemap&amp;diff=479840&amp;oldid=prev"/>
		<updated>2021-07-16T07:43:58Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- the goal of this module is to standardize creating imagemaps for yearly Senate and Gubernatorial elections in the United States.&lt;br /&gt;
local utils = require(&amp;quot;Module:US elections imagemap/utils&amp;quot;) -- utilities such as a string splitting function&lt;br /&gt;
local data = require(&amp;quot;Module:US elections imagemap/data&amp;quot;) -- data such as shapes of states; do NOT change to mw.loadData as that breaks excluded-states&lt;br /&gt;
&lt;br /&gt;
local stateshapes = data.stateshapes&lt;br /&gt;
local cycles = data.cycles&lt;br /&gt;
local statenames = data.statenames&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.makeMap(frame)&lt;br /&gt;
	local states = cycles[frame.args.cycle] or error(&amp;quot;error: invalid/no cycle specified&amp;quot;) -- require to specify a cycle&lt;br /&gt;
	local extrastates = utils.split(frame.args.extra_states or &amp;quot;&amp;quot;, &amp;quot;;&amp;quot;) -- extra states to add&lt;br /&gt;
	local extralines = utils.split(frame.args.extra_lines or &amp;quot;&amp;quot;, &amp;quot;;&amp;quot;) -- extra raw lines to add&lt;br /&gt;
	local excludedstates = utils.split(frame.args.excluded_states or &amp;quot;&amp;quot;, &amp;quot;;&amp;quot;) -- states to EXCLUDE&lt;br /&gt;
	for _, excludedstate in ipairs(excludedstates) do&lt;br /&gt;
		for k, state in ipairs(states) do&lt;br /&gt;
			if state == excludedstate then&lt;br /&gt;
		        table.remove(states, k) -- remove the state from the table. this doesn't remove it if it's included in extra_states&lt;br /&gt;
		    end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local stateoverrides = utils.split(frame.args.state_overrides or &amp;quot;&amp;quot;, &amp;quot;;&amp;quot;) -- state overrides for links (for example, linking to a recall election)&lt;br /&gt;
	local overrides = {} -- overrides should be an array of STATE=&amp;quot;Override&amp;quot;&lt;br /&gt;
	for _, override in ipairs(stateoverrides) do&lt;br /&gt;
		local overridear = utils.split(override,&amp;quot;=&amp;quot;)&lt;br /&gt;
		overrides[overridear[1]] = &amp;quot; [[&amp;quot; .. overridear[2] .. &amp;quot;]]\r\n\r\n&amp;quot; -- format the same as normal links&lt;br /&gt;
	end&lt;br /&gt;
	local linktemplatearg = frame.args.link_template or error(&amp;quot;error: no link template specified&amp;quot;) -- require a link template&lt;br /&gt;
	local linktemplate = &amp;quot; [[&amp;quot; .. linktemplatearg .. &amp;quot;]]\r\n\r\n&amp;quot; -- make it a wikilink, also the space is necessary to separate from the shape data&lt;br /&gt;
	local imagemap = &amp;quot;\r\n\r\n&amp;quot; -- start the imagemap&lt;br /&gt;
	for _, line in ipairs(extralines) do -- for each extra line. these have to come before normal lines to override them (otherwise, special elections for example don't work)&lt;br /&gt;
		imagemap = imagemap .. line .. &amp;quot;\r\n\r\n&amp;quot; -- append the extra line&lt;br /&gt;
	end&lt;br /&gt;
	for _, state in ipairs(extrastates) do -- for each extrastate - do first, in case of conflicts (like special elections, see above)&lt;br /&gt;
		statename = statenames[state] or error (state) -- if a state isn't in the list for some reason, this will tell which one&lt;br /&gt;
		local link = overrides[state] or string.gsub(linktemplate, &amp;quot;STATE&amp;quot;, statenames[state]) -- check for individual state override, if not, swap the state name into the link template&lt;br /&gt;
		imagemap = imagemap .. stateshapes[state] .. link -- add the link (which already contains the needed newline)&lt;br /&gt;
	end&lt;br /&gt;
	for _, state in ipairs(states) do -- for each state&lt;br /&gt;
		statename = statenames[state] or error (state) -- if a state isn't in the list for some reason, this will tell which one&lt;br /&gt;
		local link = overrides[state] or string.gsub(linktemplate, &amp;quot;STATE&amp;quot;, statenames[state]) -- check for individual state override, if not, swap the state name into the link template&lt;br /&gt;
		imagemap = imagemap .. stateshapes[state] .. link -- add the link (which already contains the needed newline)&lt;br /&gt;
	end&lt;br /&gt;
	return imagemap&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Zoran</name></author>
	</entry>
</feed>