Content deleted Content added
No edit summary |
Implemented new version |
||
Line 8:
['bb'] = 'border-bottom:',
['L'] = 'border-left:',
['
['n'] = 'none;',
['0'] = '0px none;',
Line 36:
['header rightcell'] = table.concat({_style['3'], _style['v'],
_style['bd'], _style['1'],
_style['
_style['bb'], _style['n'],
'"|'
Line 43:
_style['L'], _style['0'],
_style['bb'], _style['0'],
_style['
_style['t'], _style['1'],
'"|'
Line 50:
_style['L'], _style['0'],
_style['bb'], _style['0'],
_style['
_style['t'], _style['1'],
'width: 8px; min-width: 8px; background-color: #'
Line 61:
_style['L'], _style['1'],
_style['bb'], _style['0'],
_style['
_style['t'], _style['1'],
'"|'
Line 92:
table.insert(t, table.concat({'\n|-',
'\n!', style['header leftcell'], 'Preceding station',
'\n!', style['header midcell'], (data[v]['system title'] or ('[['..args.system[v]..']]')),
'\n!', style['header rightcell'], 'Following station'
}))
Line 102:
if args.line[v] or args.left[v] or args.right[v] then
if not args.line[v] then args.line[v] = args.line[index[i-1]] end
local _line = data[v]['lines'][args.line[v]]
lineTitle[v] = _line['line title']
colour[v] = _line.colour or _line.color
note[v] = args.note[v] or ''
Line 110:
_leftTerminus = _line['left terminus']
elseif type(_line['left terminus']) == 'table' then
_leftTerminus = _line['left terminus'][args.TypeL[v] or args.Type[v] or 1]
end
if type(_line['right terminus']) == 'string' then
_rightTerminus = _line['right terminus']
elseif type(_line['right terminus']) == 'table' then
_rightTerminus = _line['right terminus'][args.TypeR[v] or args.Type[v] or 1]
end
local function station(var)
local function
if s then
if string.match(s, '%[%[') then
return mw.ustring.gsub(s, '%%1', var)
elseif type(var) == 'string' then
return table.concat({'[[', mw.ustring.gsub(s, '%%1', var), '|', var, ']]'})
elseif type(var) == 'table' and #var > 0 then
local function _subst(k)
return table.concat({mw.ustring.gsub(s, '%%1', var[k]), '|', var[k]})
end
local t = {}
t[1] = table.concat({'[[', _subst(1), ']]'})
for i = 2, #var - 1 do
t[i] = table.concat({', [[', _subst(i), ']]'})
end
if #var > 1 then
t[#var] = table.concat({' or [[', _subst(#var), ']]'})
end
if var['via'] then
t[#var + 1] = table.concat({' via [[', _subst('via'), ']]'})
end
return table.concat(t)
end
end
end
if data[v]['station format'] then
return subst(data[v]['station format'][var] or data[v]['station format'][1]) or ''
else
return var or ''
end
end
if not args.left[v] then
left[v] = "''Terminus''"
leftTerminus[v] = ''
else
left[v] =
if args.onewayL[v] == true then
leftTerminus[v] = subFormat('One-way operation')
elseif args.left[v] == _leftTerminus then
leftTerminus[v] = subFormat('Terminus')
else
leftTerminus[v] = subFormat('towards ' ..
end
end
Line 142 ⟶ 175:
right[v] = "''Terminus''"
rightTerminus[v] = ''
else
right[v] =
if args.onewayR[v] == true then
rightTerminus[v] = subFormat('One-way operation')
elseif args.right[v] == _rightTerminus then
rightTerminus[v] = subFormat('Terminus')
else
rightTerminus[v] = subFormat('towards ' ..
end
end
table.insert(t, '\n|-')
table.insert(t, table.concat({'\n|', style['body leftcell'], left[v], leftTerminus[v]}))
Line 163 ⟶ 196:
local function combine(t, i)
if t[i + 4] ~= '' and t[i + 4] == t[i] then
t[i + 4] = '' -- The cell in the next row is deleted
local rowspan = 2
while t[
t[
rowspan = rowspan + 1
end
t[i] = mw.ustring.gsub(t[i], '\n|style="', table.concat({'\n|rowspan="', rowspan, '" style="'}))
Line 177 ⟶ 208:
local max = #t
for i = 2, max - 2, 4 do combine(t, i) end
for i = 3, max - 1, 4 do combine(t, i) end
for i = 4, max, 4 do combine(t, i) end
Line 195 ⟶ 226:
left = {},
right = {},
Type = {},
TypeL = {},
TypeR = {},
Line 204 ⟶ 236:
circularR = {}
}
-- to do: add rest of S-line parameters
local _index = {}
local parameters = {
['strings'] = {
['system'] = 'system',
['line'] = 'line',
['left'] = 'left',
['right'] = 'right'
},
['optional strings'] = {
['note-mid'] = 'note',
['type'] = 'Type',
['type-left'] = 'TypeL',
['type-right'] = 'TypeR',
-- ['through'] = 'through', -- The way this would work is that it would replace either "Terminus" cell, rather than just one of them in particular.
-- ['through-left'] = 'throughL',
-- ['through-right'] = 'throughR',
-- ['branch'] = 'branch',
-- ['transfer'] = 'transfer'
},
['optional boolean'] = {
['oneway-left'] = 'onewayL',
['oneway-right'] = 'onewayR',
-- ['round-left'] = 'roundL',
-- ['round-right'] = 'roundR',
['circular'] = 'circular',
['circular-left'] = 'circularL',
['circular-right'] = 'circularR',
['through-left'] = 'throughL',
['through-right'] = 'throughR'
}
}
for k, v in pairs(_args) do
if
local a = string.match(k, '^(.*%D)%d+$') or k
local b = tonumber(string.match(k, '^.*%D(%d+)$')) or 1
if
args[parameters['strings'][a]][b] = v
_index[b] = true
elseif args[parameters['optional strings'][a]] then
args[parameters['optional strings'][a]][b] = v
elseif args[parameters['optional boolean'][a]] then
args[parameters['optional boolean'][a]][b] = yesno(v)
end
end
end
local index = {}
for k, v in pairs(_index) do
Line 260 ⟶ 295:
for i, v in ipairs(index) do
if args.system[v] then
-- data[v] = require('Module:Adjacent stations/' .. args.system[v])
data[v] = require('Module:Adjacent stations/' .. args.system[v] .. '/sandbox')
else
data[v] = data[index[i-1]]
Line 266 ⟶ 302:
end
local rows = { --
['all'] = table.concat({p.top(), p.line(args, index, data), p.bottom()}),
['top'] = table.concat({p.top(), p.line(args, index, data)}),
|