Module:Adjacent stations: Difference between revisions

Content deleted Content added
Undid revision 838011693 by Szqecs (talk)
No edit summary
Line 1:
-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.
 
local yesno = require("Module:Yesno")
 
local _style = {
['3'] = 'style="width: 30%;',
Line 79 ⟶ 75:
function p.top()
return table.concat({'{| class="wikitable" ', style['table']})
end
 
function p.rail(data)
return table.concat({'\n|-',
'\n!', style['header leftcell'], 'Preceding station',
'\n!', style['header midcell'], data['system title'],
'\n!', style['header rightcell'], 'Following station'
})
end
 
Line 101 ⟶ 89:
for i = 1, #args.line do
local _line = data[i][args.line[i]]
lineTitle[i] = _line['line title']
Line 147 ⟶ 135:
end
end
table.insert(t, table.concat({'\n|-',
if args.system[i] then
return header = table.concat({'\n|-',
'\n!', style['header leftcell'], 'Preceding station',
'\n!', style['header midcell'], data[i]['system title'],
'\n!', style['header rightcell'], 'Following station'})
else
header = ''
end
table.insert(t, table.concat({'\n|-'header,
'\n|-',
'\n|', style['body leftcell'], left[i], leftTerminus[i],
'\n|', style['body banner'], colour[i], '"| ',
Line 165 ⟶ 164:
function p.main(frame)
local args = {
['system'] = frame:getParent().args.system{},
['line'] = {},
['left'] = {},
Line 178 ⟶ 177:
['circularR'] = {}
}
local data = require('Module:L-rail/' .. args.system)
 
for k, v in pairs(frame:getParent().args) do
Line 190 ⟶ 188:
end
if a == 'linesystem' then
args.system[b] = v
elseif a == 'line' then
args.line[b] = v
elseif a == 'left' then
Line 219:
end
local rowsdata = {}
local _rows = frame:getParent().args.rows or 'all'
for i = 1, #args.line do
local rows = {
if args.system[i] then
['all'] = table.concat({p.top(), p.rail(data), p.line(data, args), p.bottom()}),
data['top'i] = table.concatrequire({p.top(), p.'Module:L-rail(data),/' p.line(data,. args.system[i])}),
else
['mid'] = table.concat({p.rail(data), p.line(data, args)}),
data[i] = data[i-1]
['bottom'] = table.concat({p.rail(data), p.line(data, args), p.bottom()})
end
end
local rows = { -- To be removed. Included for backwards compatibility.
['all'] = table.concat({p.top(), p.rail(data), p.line(data, args), p.bottom()}),
['midtop'] = table.concat({p.railtop(data), p.line(data, args)}),
['mid'] = table.concat({p.line(data, args)}),
['bottom'] = table.concat({p.rail(data), p.line(data, args), p.bottom()})
}
return rows[_rows]
local _rows =if frame:getParent().args.rows or 'all'then
return rows[frame:getParent().args.rows]
else
return rows[_rows'all']
end
end