Module:Infobox road/sandbox

This is an old revision of this page, as edited by Fredddie (talk | contribs) at 05:17, 9 March 2021 (add). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local roadDataModule = require("Module:Road data")
local util = require("Module:Road data/util")
local parserModule = require("Module:Road data/parser")
local parser = parserModule.parser

function p.headerStyle(frame)
	local args = getArgs(frame)
	local deleted = args.decommissioned or args.deleted
	local uc = args.header_type == "under construction" or args.header_type == "const" or args.header_type == "uc"
	local hist = args.header_type == "hist" or args.header_type == "historic" or args.header_type == "historical" or args.header_type == "scenic"
	local color = parser(args, 'color')
	
	if uc then
		return "header-uc"
	elseif hist then
		return "header-hist"
	elseif deleted then
		return "header-deleted"
	elseif color then
		return "header-" .. color
	elseif not args.header_type and not color and not args.state or args.province or args.country then
		return "header-default"
	elseif args.country then
		return "header-" .. country
	else
		local countryModule = mw.loadData("Module:Road data/countrymask")
		country = countryModule[state]
		return "header-" .. country
	end
end

local function browse(args)
	local previousRoute = args.previous_route
	local nextRoute = args.next_route
	local extended = args.browse
		local box = mw.html.create('table'):cssText("width:100%; background:none; border-collapse:collapse")
		if previousRoute or nextRoute then
			local boxModule = require "Module:Road data/browse/sandbox" -- remove "/sandbox" when live!
			local primary = boxModule._browse(args)
			box:wikitext(primary)
		end
		if extended then
			box:wikitext(extended)
		end
		return tostring(box)
end

function p.browse(frame)
	local args = getArgs(frame)
	return browse(args)
end

return p