Content deleted Content added
Rewriting gathering of arguments |
Refactoring route states; adding function for "Removed" column |
||
Line 1:
local p = { }
▲ lang = mw.getContentLanguage()
local routeStates = { }
routeStates.current = {row = "|- \n", removed = "present"}
routeStates.future = {row
routeStates.former = {row =
function getRouteState(args)
local established = args.established
if decommissioned ~= '' then
return routeStates.future
return routeStates.current
end
end
--This function determines if this is a future route, present route, or decommissioned route, and colors the row appropriately.
Line 13 ⟶ 28:
local established = config[1]
local decommissioned = config[2]
local dates = {["established"] = established, ["decommissioned"] = decommissioned}
local routeState = getRouteState(dates)
return routeState.row
▲ if p.lang:formatDate('Y-m-d') < established then --this is a future route
▲ return "|- style=\"background-color:#ffdead;\" title=\"Future route\"\n"
▲ elseif decommissioned ~= '' then --this is a decommissioned route
▲ return '|- style=\"background-color:#d3d3d3;\" title=\"Former route\"\n'
▲ return '|- \n'
▲ end
end
Line 40 ⟶ 52:
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
|