Content deleted Content added
BrandonXLF (talk | contribs) No edit summary |
BrandonXLF (talk | contribs) Support new format, added comments |
||
Line 1:
require('strict')
local p = {}
-- Labels for platform types
local platformLabels = {
island = 'Island platform',
Line 11 ⟶ 10:
}
-- Generate the HTML to display a service
local function displayService(service, dest, dir)
if not service then return '' end
Line 21:
end
-- Generate the HTML to display a track (one or more services)
local function displayTrack(floorPart)
local out = displayService(floorPart.service, floorPart.dest, floorPart.dir)
-- Add extra (numbered) services
for i = 1, floorPart.max do▼
if floorPart.extraservice then
out = out .. displayService(floorPart[i].service, floorPart[i].dest, floorPart.dir)▼
▲ out = out .. displayService(floorPart.extraservice[i]
end
Line 31 ⟶ 35:
end
-- Generate the HTML to generate a "row" of the floor
local function displayFloorPart(floorPart, floorNum, partNum)
local out = ''
Line 54 ⟶ 59:
end
-- Generate the HTML to display a floor
local function displayFloor(stationFloor, num, last)
local out = '<div class="floor' .. (last and ' last' or '') .. '" style="grid-row: span ' .. stationFloor.count .. ';">' .. stationFloor.letter .. '</div>'
Line 64 ⟶ 70:
end
-- Create a table that can hold numbered arguments
local function createArgTable(tbl)
return {▼
tbl = tbl or {}
max = 0,▼
count = 0▼
▲ }
end
-- Add an argument number to a table of numbered arguments
local function addArg(tbl, num, value)
if num > tbl.max then
tbl.max = num
Line 77 ⟶ 87:
if not tbl[num] then
tbl[num] =
tbl.count = tbl.count + 1
end
end
-- Process an argument with the format level_part_param[paramNum]
local function processArg(out, level, part,
level = tonumber(level)
part = tonumber(part)
addArg(out, level, createArgTable())
addArg(out[level], part, {})
if
addArg(out[level][part][
else
out[level][part][param] = value
Line 98 ⟶ 109:
end
-- Process the argument table
local function processArgs(args)
local out = createArgTable()
Line 103 ⟶ 115:
for i, v in pairs(args) do
if type(i) == 'number' then
▲ out[level] = createArgTable()
▲ end
else
local level, part,
if level then
processArg(out, level, part,
end
end
Line 122 ⟶ 128:
end
-- Main function, called by wikitext
function p.main(frame)
local sortedArgs = processArgs(frame.args)
|