Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Szqecs/L-rail v2
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local yesno = require("Module:Yesno") local _style = { ['3'] = 'style="width: 30%;', ['c'] = 'style="text-align: center;', ['v'] = 'vertical-align: middle;', ['bd'] = 'border:', ['t'] = 'border-top:', ['bb'] = 'border-bottom:', ['L'] = 'border-left:', ['r'] = 'border-right:', ['n'] = 'none;', ['0'] = '0px none;', ['1'] = '1px solid #aaa;' } local style = { ['table'] = table.concat({'style="width: 55%; max-width: 50em; margin:0.5em auto; font-size:95%; clear:both;', _style['t'], _style['0'], 'border-collapse: separate;" cellspacing="0" cellpadding="-1"' }), ['header leftcell'] = table.concat({_style['3'], _style['v'], _style['bd'], _style['1'], _style['L'], _style['n'], _style['bb'], _style['n'], '"|' }), ['header banner'] = table.concat({'style="', _style['bd'], _style['n'], _style['t'], _style['1'], '"|' }), ['header midcell'] = table.concat({'colspan="3" style="', _style['v'], _style['bd'], _style['n'], _style['t'], _style['1'], '"|' }), ['header rightcell'] = table.concat({_style['3'], _style['v'], _style['bd'], _style['1'], _style['r'], _style['n'], _style['bb'], _style['n'], '"|' }), ['body leftcell'] = table.concat({_style['c'], _style['v'], _style['L'], _style['0'], _style['bb'], _style['0'], _style['r'], _style['1'], _style['t'], _style['1'], '"|' }), ['body banner'] = table.concat({_style['c'], _style['L'], _style['0'], _style['bb'], _style['0'], _style['r'], _style['0'], _style['t'], _style['1'], 'width: 8px; background-color: #' }), ['body midcell'] = table.concat({_style['c'], _style['v'], _style['bb'], _style['0'], '"|' }), ['body rightcell'] = table.concat({_style['c'], _style['v'], _style['L'], _style['1'], _style['bb'], _style['0'], _style['r'], _style['0'], _style['t'], _style['1'], '"|' }) } local function subFormat(s) return '<div style="font-size: smaller; font-style: italic">' .. s .. '</div>' end local p = {} function p.top() return table.concat({'{| class="wikitable" ', style['table']}) end function p.line(data, args) local lineTitle = {} local colour = {} local left = {} local right = {} local note = {} local leftTerminus = {} local rightTerminus = {} local t = {} for i = 1, #args.line do local _line = data[i][args.line[i]] lineTitle[i] = _line['line title'] colour[i] = _line.colour note[i] = args.note[i] or '' if type(_line['left terminus']) == 'string' then _leftTerminus = _line['left terminus'] elseif type(_line['left terminus']) == 'table' then _leftTerminus = _line['left terminus'][args.TypeL[i] 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[i] or 1] end if not args.left[i] then left[i] = "''Terminus''" leftTerminus[i] = '' elseif args.left[i] == _leftTerminus then left[i] = _line['station link'](args.left[i]) leftTerminus[i] = subFormat('Terminus') else left[i] = _line['station link'](args.left[i]) if args.onewayL[i] == true then leftTerminus[i] = subFormat('One-way operation') else leftTerminus[i] = subFormat('towards ' .. _line['station link'](_leftTerminus)) end end if not args.right[i] then right[i] = "''Terminus''" rightTerminus[i] = '' elseif args.right[i] == _rightTerminus then right[i] = _line['station link'](args.right[i]) rightTerminus[i] = subFormat('Terminus') else right[i] = _line['station link'](args.right[i]) if args.onewayR[i] == true then rightTerminus[i] = subFormat('One-way operation') else rightTerminus[i] = subFormat('towards ' .. _line['station link'](_rightTerminus)) end end if args.system[i] then 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({header, '\n|-', '\n|', style['body leftcell'], left[i], leftTerminus[i], '\n|', style['body banner'], colour[i], '"| ', '\n|', style['body midcell'], lineTitle[i], '<div style="font-size: smaller">', note[i], '</div>' , '\n|', style['body banner'], colour[i], '"| ', '\n|', style['body rightcell'], right[i] , rightTerminus[i] })) end return table.concat(t) end function p.bottom() return '\n|}' end function p.main(frame) local args = { ['system'] = {}, ['line'] = {}, ['left'] = {}, ['right'] = {}, ['TypeL'] = {}, ['TypeR'] = {}, ['note'] = {}, ['onewayL'] = {}, ['onewayR'] = {}, ['circular'] = {}, ['circularL'] = {}, ['circularR'] = {} } local _args = frame.args for k, v in pairs(_args) do local a = string.match(k, '(%a+)%d+') if not a then a = k end local b = tonumber(string.match(k, '%a+(%d+)')) if not b then b = 1 end if a == 'system' then args.system[b] = v elseif a == 'line' then args.line[b] = v elseif a == 'left' then args.left[b] = v elseif a == 'right' then args.right[b] = v elseif a == 'typeL' then args.TypeL[b] = v elseif a == 'typeR' then args.TypeR[b] = v elseif a == 'note' then args.note[b] = v elseif a == 'onewayL' then args.onewayL[b] = yesno(v) elseif a == 'onewayR' then args.onewayR[b] = yesno(v) elseif a == 'circular' then args.circular[b] = yesno(v) elseif a == 'circularL' then args.circularL[b] = yesno(v) elseif a == 'circularR' then args.circularR[b] = yesno(v) elseif a == 'throughL' then args.throughL = yesno(v) elseif a == 'throughR' then args.throughR = yesno(v) end end local data = {} for i = 1, #args.line do if args.system[i] then data[i] = require('Module:L-rail/' .. args.system[i]) else data[i] = data[i-1] end end local rows = { -- To be removed. Included for backwards compatibility. ['all'] = table.concat({p.top(), p.line(data, args), p.bottom()}), ['top'] = table.concat({p.top(), p.line(data, args)}), ['mid'] = table.concat({p.line(data, args)}), ['bottom'] = table.concat({p.line(data, args), p.bottom()}) } return rows[_args.rows] or rows['all'] end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Szqecs/L-rail v2/doc
(
edit
)