Jump to content

Module:Infobox road/color/sandbox

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Fredddie (talk | contribs) at 06:57, 13 February 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {} 

local format = mw.ustring.format
local insert = table.insert
local concat = table.concat
local lower = mw.ustring.lower
local getArgs = require('Module:Arguments').getArgs	
local parserModule = require "Module:Road data/parser"
local parser = parserModule.parser

local function location(args)
	local state = args.state or args.province or ''
	args.state = state
	local country
	if args.country and args.country ~= '' then
		country = upper(args.country)
	else
		local countryModule = mw.loadData("Module:Road data/countrymask")
		country = countryModule[state] or 'UNK'
	end
	args.country = country
end

local uc = "under construction" or "const" or "uc"
local hist = "hist" or "historic" or "historical"
local deleted = "decommissioned" or "deleted" or "former"

function p.header(args, frame)
	local color = parser(args, 'color')
	if color == '' or color == nil then
		return tostring("background:#cedff2;")
	elseif lower(args.header_type) == uc then
		return tostring("background:#fc6;")
	elseif lower(args.header_type) == hist then
		return tostring("background:#704214; color:#fff;")
	elseif lower(args.header_type) == deleted then
		return tostring("background:#AAA;")
	else return color
	end
end

function p.border(args, frame)
	local border = parser(args, 'border')
	if border == '' or border == nil then
		return tostring("#cedff2;")
		else return border
	end
end

return p