Module:Sandbox/BrandonXLF/1: Difference between revisions

Content deleted Content added
No edit summary
Restored revision 1241724286 by BrandonXLF (Restorer)
 
(22 intermediate revisions by the same user not shown)
Line 1:
-- Sandbox, do not delete
 
require('strict')
 
local p = {}
 
-- Parameters that can be numbered
local numeredParams = {
service = true,
dest = true,
note = true
}
 
-- Labels for platform types
Line 7 ⟶ 16:
island = 'Island platform',
top = 'Side platform',
buttombottom = 'Side platform'
}
 
-- Generate the HTML to display a service
local function displayService(service, dest, note, dir)
if not service then return '' end
return '<div class="service">' ..
'<div class="' .. (dir ~= 'left' and 'hidden' or '') .. '">←</div>' ..
'<div>' .. service .. (dest and ' toward ' .. dest or '') .. (note and ' ' .. note or '') .. '</div>' ..
(dir == 'right' and '<div>→</div>' or '') ..
'</div>'
Line 23 ⟶ 32:
-- Generate the HTML to display a track (one or more services)
local function displayTrack(floorPart)
localif outnot = displayService(floorPart.service, floorPart.dest, floorPart.dir)then
return ''
end
floorPart.dest = floorPart.dest or {}
-- Add extra (numbered) services
iffloorPart.note = floorPart.extraservicenote or then{}
for i = 1, floorPart.extraservice.max do
local out = ''
out = out .. displayService(floorPart.extraservice[i], floorPart.extradest[i], floorPart.dir)
end
for i = 1, floorPart.extraserviceservice.max do
out = out .. displayService(floorPart.extraserviceservice[i], floorPart.extradestdest[i], floorPart.note[i], floorPart.dir)
end
Line 40 ⟶ 53:
if floorPart.name then
return '<div class="track"><div>' .. floorPart.name .. '</div></div>' ..
'<div class="track"><div class="desc"><div>' .. (floorPart.desc or '') .. '</div>' .. displayTrack(floorPart) .. '</div></div>'
end
Line 50 ⟶ 64:
return '<div class="platform ' .. floorPart.platform .. '">' ..
platformLabels[floorPart.platform] ..
(floorPart.acessibleaccessible and ' ' .. mw.getCurrentFrame():expandTemplate{ title = 'access icon' } or '') ..
(floorPart.note and ', ' .. floorPart.note or '') ..
'</div>'
end
Line 96 ⟶ 111:
level = tonumber(level)
part = tonumber(part)
paramNum = paramNum and tonumber(paramNum) or nil1
addArg(out, level, createArgTable())
addArg(out[level], part, {})
if paramNumnumeredParams[param] then
if not out[level][part]['extra' .. param] = createArgTable()then
addArg( out[level][part]['extra' .. param], paramNum,= valuecreateArgTable()
end
addArg(out[level][part][param], paramNum, value)
else
out[level][part][param] = value