local p = {}
function p.Colour(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 roadclosed = args["uc_former"] or "" -- get special status (closed/uc)
local roadtype = args["type"] or "" -- get road type
roadclosed = string.lower(roadclosed) -- change roadclosed to lower case
roadtype = string.lower(roadtype) -- change roadtype to lower case
roadclosed = string.gsub(roadclosed, "%s+", "_") --remove spaces and replace with underscores for table access
roadtype = string.gsub(roadtype, "%s+", "_") --remove spaces and replace with underscores for table access
local colours = {under_construction = "background-color:#fc6;", uc = "background-color:#fc6;", closed = "background-color:#aaa;",
highway = "background-color:#e9f9d2;", city_highway = "background-color:#e9f9d2;", road = "background-color:#ffffe0;",
rural_road = "background-color:#ffffe0;", street = "background-color:#f9e2d2;", expressway = "background-color:#d2e2f9;",
freeway = "background-color:#d2e2f9;", motorway = "background-color:#d2e2f9;", parkway = "background-color:#d2e2f9;",
track = "background-color:#fee8ab;", junction = "background-color:#f0f0ff;"}
if not(roadtype) and not(roadclosed) then
return "background-color: #e6c4fb;" -- if inputs missing, go purple
elseif roadclosed and colours[roadclosed] then
return colours[roadclosed] -- if road has a special type, and if it makes sense get return colour
elseif roadtype and colours[roadtype] then
return colours[roadtype] -- otherwise check the type makes sense, and get return colour
else
return "background-color: #e6c4fb;" -- all other cases go purple
end
end
return p