-- Sandbox, do not delete
require('strict')
local p =
-- Parameters that can be numberedlocal numeredParams =
-- Labels for platform typeslocal platformLabels =
-- Generate the HTML to display a servicelocal function displayService(service, dest, note, dir) if not service then return end return '
' .. '
←
' .. '
' .. service .. (dest and ' toward ' .. dest or ) .. (note and ' ' .. note or ) .. '
' .. (dir
→
' or ) .. '
'end
-- Generate the HTML to display a track (one or more services)local function displayTrack(floorPart) if not floorPart.service then return end floorPart.dest = floorPart.dest or floorPart.note = floorPart.note or local out = for i = 1, floorPart.service.max do out = out .. displayService(floorPart.service[i], floorPart.dest[i], floorPart.note[i], floorPart.dir) end return outend
-- Generate the HTML to generate a "row" of the floorlocal function displayFloorPart(floorPart, floorNum, partNum) local out = if floorPart.name then return '
' .. floorPart.name .. '
' .. '
' .. (floorPart.desc or ) .. '
' .. displayTrack(floorPart) .. '
' end if floorPart.platform then if not platformLabels[floorPart.platform] then return '
Invalid platform type!
' end return '
' .. platformLabels[floorPart.platform] .. (floorPart.accessible and ' ' .. mw.getCurrentFrame:expandTemplate or ) .. (floorPart.note and ', ' .. floorPart.note or ) .. '
' end
local prefix = floorNum .. '_' .. partNum .. '_' return '
Invalid floor part! Must have either ' .. prefix .. 'name
or ' .. prefix .. 'platform
.'end
-- Generate the HTML to display a floorlocal function displayFloor(stationFloor, num, last) local out = '
' .. stationFloor.letter .. '
'
for i = 1, stationFloor.max do out = out .. displayFloorPart(stationFloor[i], num, i) end return outend
-- Create a table that can hold numbered argumentslocal function createArgTable(tbl) tbl = tbl or tbl.max = 0 tbl.count = 0 return tblend
-- Add an argument number to a table of numbered argumentslocal function addArg(tbl, num, value) if num > tbl.max then tbl.max = num end if not tbl[num] then tbl[num] = value tbl.count = tbl.count + 1 endend -- Process an argument with the format level_part_param[paramNum]local function processArg(out, level, part, param, paramNum, value) level = tonumber(level) part = tonumber(part) paramNum = paramNum and tonumber(paramNum) or 1 addArg(out, level, createArgTable) addArg(out[level], part,) if numeredParams[param] then if not out[level][part][param] then out[level][part][param] = createArgTable end addArg(out[level][part][param], paramNum, value) else out[level][part][param] = value endend -- Process the argument tablelocal function processArgs(args) local out = createArgTable for i, v in pairs(args) do if type(i)
-- Main function, called by wikitextfunction p.main(frame) local sortedArgs = processArgs(frame.args) local out = frame:extensionTag out = out .. '
' for i = 1, sortedArgs.max do out = out .. displayFloor(sortedArgs[i], i, i
'end
return p