มอดูล:Infobox road

จากวิกิพีเดีย สารานุกรมเสรี
Documentation icon คู่มือการใช้งานมอดูล[สร้าง]
local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.headerStyle(frame)
	local args = getArgs(frame)
	local deleted = args.decommissioned or args.deleted
	if deleted then
		return "background:#AAA;"
	end
	local colors = require"Module:Infobox road/color"
	return colors.color(frame)
end

--RING ROADS

local function loop(args)
	local ring_road = args.ring_road or ''
	if ring_road ~= '' then
		return "[[Ring road]] around " .. ring_road
	end
	local beltway_city = args.beltway_city or ''
	if beltway_city ~= '' then
		return "[[Beltway]] around " .. beltway_city
	end
	local orbital = args.orbital or ''
	if orbital ~= '' then
		return "[[Orbital road|Orbital]] around " .. orbital
	end
	local loop = args.loop or ''
	if loop ~= '' then
		return "[[Loop road|Loop]] around " .. loop
	end
	local tloop = args.tloop or ''
	if tloop == 'none' then
		return "Tourist loop"
	elseif tloop ~= '' then
		return "Tourist loop around " .. tloop
	end
	return nil
end

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

--BROWSE LINKS

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

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

local function extended(args)
	local extended = args.browse
	if args.nobrowse or extended == nil then
		return nil 
	else
		local box = mw.html.create('table'):cssText("width:100%; background:none; border-collapse:collapse; display:inline-table;")
		box:wikitext(extended)
		return tostring(box)
	end
end

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

return p