Implements {{Routelist row}}
local p = { }
local lang = mw.getContentLanguage()
local routeStates = { }
routeStates.current = {row = "|- \n", removed = "present"}
routeStates.future = {row = "|- style=\"background-color:#ffdead;\" title=\"Future route\"\n", removed = "proposed"}
routeStates.former = {row = "|- style=\"background-color:#d3d3d3;\" title=\"Former route\"\n"}
routeStates.unknown = {row = "|- \n", removed = "—"}
function getRouteState(args)
local established = args.established
local decommissioned = args.decommissioned
if established == '' then
return routeStates.unknown
elseif decommissioned ~= '' then
return routeStates.former
elseif lang:formatDate("Y-m-d") < established then
return routeStates.future
else
return routeStates.current
end
end
--This function determines if this is a future route, present route, or decommissioned route, and colors the row appropriately.
function p.rowcolor(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
--Import parameters from template
local established = config[1]
local decommissioned = config[2]
local dates = {["established"] = established, ["decommissioned"] = decommissioned}
local routeState = getRouteState(dates)
return routeState.row
end
--This function determines if this is a beltway or not, and displays the termini columns appropriately.
function p.termini(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
--Import parameters from template
local beltway = config[1]
local terminus_a = config[2]
local terminus_b = config[3]
--The template passes this function an empty string if {{{beltway}}} is not specified by the template user.
if beltway ~= '' then
return "|colspan=2 align=center|" .. beltway
else
return '|' .. terminus_a .. '||' .. terminus_b
end
end
--This function determines the proper value for the removed column, and then displays it.
function p.removed(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
--Import parameters from template
local established = config[1]
local decommissioned = config[2]
local dates = {["established"] = established, ["decommissioned"] = decommissioned}
local routeState = getRouteState(dates)
return routeState.removed or lang:formatDate('Y', decommissioned)
end
return p