Module:Infobox road/color explained

local p =

Country =

function Country:new(obj) obj = obj or setmetatable(obj, self) self.__index = self return objend

function Country:color(args) local type = args.type return self[type] or self.defaultend

function Country:addTypesAsColor(types, color) for i,type in pairs(types) do self[type] = color endend

local colors = do function colors:color(args) local headerType = args.headerType local countryArg = args.country local headerTypeColor = self[headerType] if headerTypeColor then return headerTypeColor end local success, country = pcall(self.country, self, countryArg) if not(success) then return 'background:#cedff2;' else return country:color(args) end end function colors:country(name) local color = self[name] if color then return color end if name

'CAN' then local module = require(string.format("Module:Infobox road/color/%s", name)) return module.colors else error("Country not included", 0) end end do -- Single-color countries colors.ARG = Country:new colors.BEL = Country:new colors.BGD = Country:new colors.BOL = Country:new colors.CHL = Country:new colors.CHN = Country:new colors.CRI = Country:new colors.ECU = Country:new colors.EST = Country:new colors.EUR = Country:new colors.IND = Country:new colors.JOR = Country:new colors.HKG = Country:new colors.ISL = Country:new colors.MEX = Country:new colors.NZL = Country:new colors.SWE = Country:new colors.URY = Country:new colors.VNM = Country:new end -- Single-color countries do -- Multi-color countries do -- Albania local ALB = Country:new ALB:addTypesAsColor("background:#08842C; color:#fff;") colors.ALB = ALB end -- Albania do -- UAE local ARE = Country:new ARE:addTypesAsColor("background:#0044aa; color:#fff;") colors.ARE = ARE end -- UAE do -- Asian Highway Network local ASIA = Country:new ASIA:addTypesAsColor("background:#1e2c76; color:#fff;") colors.ASIA = ASIA end -- Asian Highway Network do -- Australia local AUS = Country:new AUS:addTypesAsColor("background:#D2E2F9;") AUS:addTypesAsColor("background:#E9F9D2;") AUS:addTypesAsColor("background:#FFFFE0;") AUS:addTypesAsColor("background:#F9E2D2;") AUS:addTypesAsColor("background:#fee8ab;") colors.AUS = AUS end -- Australia do -- Austria local AUT = Country:new AUT:addTypesAsColor("background:#276FB7; color:#fff;") colors.AUT = AUT end -- Austria do -- Bosnia and Herzegovina local BIH = Country:new BIH:addTypesAsColor("background:#0066CC; color:#fff;") BIH:addTypesAsColor("background:#FFCC33; border:2px solid #000;") colors.BIH = BIH end -- Bulgaria do -- Bulgaria local BGR = Country:new BGR:addTypesAsColor("background:#006A4D; color:#fff;") colors.BGR = BGR end -- Bulgaria do -- Croatia local HRV = Country:new HRV:addTypesAsColor("background:#08842C; color:#fff;") HRV:addTypesAsColor("background:#0066CC; color:#fff;") HRV:addTypesAsColor("background:#FFCC33;") colors.HRV = HRV end -- Croatia do -- Cyprus local CYP = Country:new CYP:addTypesAsColor("background:#005024; color:#FFC000;") colors.CYP = CYP end -- Cyprus do -- Czech Republic local CZE = Country:new CZE:addTypesAsColor("background:#006A4D; color:#fff;") colors.CZE = CZE end -- Czech Republic do -- Denmark local DNK = Country:new DNK:addTypesAsColor("background:#006A4D; color:#fff;") DNK:addTypesAsColor("background:#fff; border:2px solid #af1e2d; color:#af1e2d;") colors.DNK = DNK end -- Denmark do -- Finland local FIN = Country:new FIN:addTypesAsColor("background:#009775; color:#fff;") colors.FIN = FIN end -- Finland do -- France local FRA = Country:new FRA:addTypesAsColor("background:#0079C1; color:#fff;") FRA:addTypesAsColor("background:#006A4D; color:#fff;") FRA:addTypesAsColor("background:#28961e; color:#fff;") colors.FRA = FRA colors.MTQ = FRA colors.DZA = FRA end -- France do -- Georgia local GEO = Country:new GEO:addTypesAsColor("background:#039; color:#fff;") colors.GEO = GEO end -- Georgia do -- Germany local DEU = Country:new DEU:addTypesAsColor("background:#003ABD; color:#fff;") DEU:addTypesAsColor("background:#FC3;") DEU:addTypesAsColor("background:#08842C; color:#fff;") DEU:addTypesAsColor("background:#633A34; color:#fff;") colors.DEU = DEU end -- Germany do -- Ghana local GHA = Country:new GHA:addTypesAsColor("background:#0079C1; color:#fff;") colors.GHA = GHA end -- Ghana do -- Greece local GRC = Country:new GRC:addTypesAsColor("background:#006A4D; color:#fff;") colors.GRC = GRC end -- Greece do -- Hungary local HUN = Country:new HUN:addTypesAsColor("background:#0079C1; color:#fff;") colors.HUN = HUN end -- Hungary do -- Iran local IRN = Country:new IRN:addTypesAsColor("background:#0079C1; color:#fff;") IRN:addTypesAsColor("background:#00703C; color:#fff;") IRN:addTypesAsColor("background:#fff; color:#000;") colors.IRN = IRN end -- Iran do -- Republic of Ireland local IRL = Country:new IRL:addTypesAsColor("background:#0079C1; color:#fff;") IRL:addTypesAsColor("background:#00703C; color:#FFD200;") IRL:addTypesAsColor("background:#fff; border:2px solid #000;") colors.IRL = IRL end -- Republic of Ireland do -- Isle of Man local IMN = Country:new IMN:addTypesAsColor("background:#00703C; color:#FFD200;") colors.IMN = IMN end -- Isle of Man do -- Israel local ISR = Country:new ISR:addTypesAsColor("background:#0000FE; color:#fff;") colors.ISR = ISR end -- Israel do -- Italy local ITA = Country:new ITA:addTypesAsColor("background:#08842C; color:#fff;") ITA:addTypesAsColor("background:#08842C; color:#fff;") ITA:addTypesAsColor("background:#003F87; color:#fff;") ITA:addTypesAsColor("background:#08842C; color:#fff;") colors.ITA = ITA end -- Italy do -- Jamaica local JAM = Country:new JAM:addTypesAsColor("background:#0079C1; color:#fff;") colors.JAM = JAM end -- Jamaica do -- Kosovo local KOS = Country:new KOS:addTypesAsColor("background:#009933; color:#fff;") KOS:addTypesAsColor("background:#08842C; color:#fff;") colors.KOS = KOS end -- Kosovo do -- Nepal local NPL = Country:new -- NPL:addTypesAsColor("background:#0079C1; color:#fff;") NPL:addTypesAsColor("background:#00703C; color:#fff;") colors.NPL = NPL end -- Nepal do -- Netherlands local NLD = Country:new NLD:addTypesAsColor("background:#08842C; color:#fff;") colors.NLD = NLD end -- Netherlands do -- Norway local NOR = Country:new NOR:addTypesAsColor("background:#00965E; color:#fff;") colors.NOR = NOR end -- Norway do -- Northern Ireland local NIR = Country:new NIR:addTypesAsColor("background:#0079C1; color:#fff;") NIR:addTypesAsColor("background:#00703C; color:#FFD200;") colors.NIR = NIR end -- Northern Ireland do -- Malaysia local MYS = Country:new MYS:addTypesAsColor("background:#006A4D; color:#fff;") colors.MYS = MYS end -- Malaysia do -- Morocco local MAR = Country:new MAR:addTypesAsColor("background:#0079C1; color:#fff;") MAR:addTypesAsColor("background:#0079C1; color:#fff;") colors.MAR = MAR end -- Morocco do -- Pakistan local PAK = Country:new PAK:addTypesAsColor("background:#22B14C; color:#fff;") PAK:addTypesAsColor("background:#F5C31D; color:#000;") colors.PAK = PAK end -- Pakistan do -- Philippines local PHL = Country:new PHL:addTypesAsColor("background:#1e2c76; color:#fff;") colors.PHL = PHL end -- Philippines do -- Poland local POL = Country:new POL:addTypesAsColor("background:#0079C1; color:#fff;") colors.POL = POL end --Poland do -- Russia local RUS = Country:new RUS:addTypesAsColor("background:#00a500; color:#fff;") RUS:addTypesAsColor("background:#00004e; color:#fff;") colors.RUS = RUS end --Russia do -- Slovakia local SVK = Country:new SVK:addTypesAsColor("background:#006A4D; color:#fff;") colors.SVK = SVK end -- Slovakia do -- South Africa local ZAF = Country:new ZAF:addTypesAsColor("background:#0079C1; color:#fff;") colors.ZAF = ZAF end -- South Africa do -- Spain local ESP = Country:new ESP:addTypesAsColor("background:#13926C; color:#fff;") ESP:addTypesAsColor("background:#19408B; color:#fff;") ESP:addTypesAsColor("background:#bf0411; color:#fff;") ESP:addTypesAsColor("background:#E96310; color:#000;") ESP:addTypesAsColor("background:#5D3F0F; color:#fff;") ESP:addTypesAsColor("background:#F4B70D; color:#000;") colors.ESP = ESP end -- Spain do -- Sri Lanka local LKA = Country:new LKA:addTypesAsColor("background:#0079C1; color:#fff;") LKA:addTypesAsColor("background:#006A4D; color:#fff;") colors.LKA = LKA end -- Sri Lanka do -- Switzerland local CHE = Country:new CHE:addTypesAsColor("background:#08842C; color:#fff;") colors.CHE = CHE end -- Switzerland do -- Thailand local THA = Country:new THA:addTypesAsColor("background:#003F87; color:#fff;") colors.THA = THA end -- Thailand do -- Turkey local TUR = Country:new TUR:addTypesAsColor("background:#003F87; color:#fff;") TUR:addTypesAsColor("background:#08842C; color:#fff;") colors.TUR = TUR end -- Turkey do -- Ukraine local UKR = Country:new UKR:addTypesAsColor("background:#009900; color:#fff;") colors.UKR = UKR end -- Ukraine do -- United Kingdom local GBR = Country:new GBR:addTypesAsColor("background:#0079C1; color:#fff;") GBR:addTypesAsColor("background:#00703C; color:#FFD200;") colors.GBR = GBR end -- United Kingdom do -- United States local USA = Country:new USA:addTypesAsColor("background:#704214; color:#fff;") colors.USA = USA end -- United States end -- Multi-color countries do -- Built-in header types colors["under construction"] = "background:#fc6;" colors["const"] = "background:#fc6;" colors["uc"] = "background:#fc6;" colors["historic"] = "background:#704214; color:#fff;" colors["historical"] = "background:#704214; color:#fff;" colors["hist"] = "background:#704214; color:#fff;" colors["scenic"] = "background:#704214; color:#fff;" colors["decommissioned"] = "background:#AAA;" colors["former"] = "background:#AAA;" colors["motorway"] = "background:#003DA5; color:#fff;" --for Norway only end -- Built-in header typesend

function p._color(args) return colors:color(args)end

function p.color(frame) local pframe = frame:getParent local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template local function emptyParam(param) local empty = if not(param) or empty[param] then return nil else return param end end local state = config.state or args.state state = emptyParam(state) local province = config.province or args.province province = emptyParam(province) local type = config.type or args.type local subtype = config.subtype or args.subtype or nil local headerType = args.header_type or config.header_type headerType = emptyParam(headerType) if headerType then headerType = string.lower(headerType) end local countryArg = config.country or args.country countryArg = emptyParam(countryArg) local country = countryArg if not(country) then if colors[headerType] then country = else local stateParam = state or province if not(stateParam) then country = else local countryMask = require "Module:Infobox road/meta/mask/country" country = countryMask._country(stateParam, countryArg) end end end return p._colorend

return p