Module:Sandbox/BrandonXLF/3: Difference between revisions

Content deleted Content added
Clear
Tag: Replaced
No edit summary
Tag: Reverted
Line 1:
-- Sandbox, do not delete
require('strict')
 
local p = {}
 
local getArgs = require('Module:Arguments').getArgs
local parserModule = require('Module:Road data/parser')
local parser = parserModule.parser
 
local function showRoute(route, routeType, routeLoc)
local out = ''
local parserArgs = {
[1] = routeType,
[2] = route,
province = routeLoc
}
local shield = parser(parserArgs, 'shieldmain') or parser(parserArgs, 'shield') or ''
local label = parser(parserArgs, 'name') or parser(parserArgs, 'abbr') or ''
local alt = label .. ' marker'
if type(shield) == 'table' then
local res = {}
 
for i,v in ipairs(shield) do
res[i] = string.format('[[File:%s|15px|alt=%s]]', v, alt)
end
 
out = out .. table.concat(res, ' ')
else
out = out .. string.format('[[File:%s|15px|alt=%s]]', shield, alt)
end
out = out .. (routeLoc ~= currProvince and (' ' .. routeLoc) or '') .. label
return out
end
 
local function edgeColumn(prefix, currProvince, args)
local index = 1
local out = ''
repeat
local route = args[prefix .. index] or (index == 1 and args[prefix] or false)
local routeType = args[prefix .. '_type' .. index] or (index == 1 and args[prefix .. '_type'] or false)
local routeLoc = args[prefix .. '_province' .. index] or (index == 1 and args[prefix .. '_province'] or false)
if index ~= 1 then
out = out .. '<hr>'
end
out = out .. showRoute(route, routeType, routeLoc)
index = index + 1
until not args[prefix .. index]
return out
end
 
function p.main(frame)
local args = getArgs(frame)
local route = args.curr
local routeType = args.curr_type
local routeLoc = args.curr_province
return edgeColumn('prev', routeLoc, args)
.. showRoute(route, routeType, routeLoc)
.. edgeColumn('next', routeLoc, args)
end