Module:US elections imagemap and Module:US elections imagemap/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
imported>MusikBot II
m Protected "Module:US elections imagemap": High-risk template or module: 419 transclusions (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))
 
imported>Elli
No edit summary
 
Line 1: Line 1:
-- the goal of this module is to standardize creating imagemaps for yearly Senate and Gubernatorial elections in the United States.
-- the goal of this module is to standardize creating imagemaps for yearly Senate and Gubernatorial elections in the United States.
local utils = require("Module:US elections imagemap/utils") -- utilities such as a string splitting function
local utils = require("Module:US elections imagemap/utils") -- utilities such as a string splitting function
local data = require("Module:US elections imagemap/data") -- data such as shapes of states; do NOT change to mw.loadData as that breaks excluded-states
local data = require("Module:US elections imagemap/data") -- data such as shapes of states


local stateshapes = data.stateshapes
local stateshapes = data.stateshapes
Line 9: Line 9:
local p = {}
local p = {}


function p.makeMap(frame)
function p.makeMap(frame) -- limitations: currently no way to add custom shapes, or to add custom states to cycles, or to add custom links not following the general template
local states = cycles[frame.args.cycle] or error("error: invalid/no cycle specified") -- require to specify a cycle
local states = cycles[frame.args.cycle] or error("error: invalid/no cycle specified") -- require to specify a cycle
local extrastates = utils.split(frame.args.extra_states or "", ";") -- extra states to add
local extrastates = utils.split(frame.args.extra_states or "", ";") -- extra states to add