Module:Sandbox/Sameboat/m1: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(171 intermediate revisions by the same user not shown)
Line 1:
local getArgs = require('Module:Arguments').getArgs
local data = mw.loadData('Module:HK-MTR stations/data')
local p = {}
 
function p._stationnavbar(argsframe)
local navbar = require('Module:Navbar').navbar
return navbar('asd')
end
 
p.lengthcheck = function()
local asd = '123456789'
return string.len(asd)
end
 
p.indextable = function()
local result = ''
local t={}
t[#t+1]='odin'.. 1 + 0
t[#t+1]='dva'.. '1 + 1'
t[#t+1]='tri'.. 1.5 * 2
return table.concat(t, ', ') .. '.'
end
local function makeInvokeFunction(funcName)
Line 13 ⟶ 31:
end
p.stationlink = makeInvokeFunction('_station_link')
local function errorTextp._link(messageargs)
local result='{|class="wikitable"\n|-'
return '<strong class="error">' .. message .. '</strong>'
local t = {
end
{h='a', d='1a'},
{h='b', d='2b'},
local function getStation(code)
{h='c', d='3c'},
local station = data.stations[code]
{h='d', d='4d'},
if not station then
}
local alias = data.aliases[code]
t[5] = {h = 'e', d = '5e'}
if alias then
t[6] = {h = 'f', d = '6f'}
code = alias
t[7] = {h = 'g', d = '7g'}
station = data.stations[code]
for i,v in ipairs(t) do
if aliasi==5 then break
else
result=result..'\n!'..v.h
end
end
result=result..'\n|-'
-- The returned code is what should be used (target of any alias).
for i,v in ipairs(t) do
return station, code
result=result..'\n|'..v.d
end
result=result..'\n|-'
local t = {
{h='aa', d='1aa'},
{h='bb', d='2bb'},
{h='cc', d='3cc'},
{h='dd', d='4dd'},
}
for i,v in ipairs(t) do
result=result..'\n!'..v.h
end
result=result..'\n|-'
for i,v in ipairs(t) do
result=result..'\n|'..v.d
end
return result .. '\n|}'
end
p.row = makeInvokeFunction('_row')
function p._station(args)
function p._row(args)
local code = args[1] or args.station -- arguments have been trimmed
local somelist = args[1]
if code == nil or code == '' then
local link, text, result
return errorText('Need station or stop name')
result = ''
end
for k1, v1 in ipairs(mw.text.split(somelist, '\n')) do
local station, code = getStation(code)
for k2, v2 in ipairs(mw.text.split(v1 .. '\\', '\\')) do
local link, text, result
if stationk2 > 2 then break
if elseif (k2 % 2 station.link==nil 1) then
if (k1 % 2 == 0) then
return station.text
result = result .. '\n|-style="background:#888"\n!' .. k1 .. '\n|' .. v2
else link = station.link or code
else result = result .. '\n|-\n!' .. k1 .. '\n|' .. v2
end
elseif (k2 % 2 == 0) then result = result .. '||' .. v2
end
end
text = station.text or code
else
link = code .. ' Stop'
text = code
end
result = '[[{|class="wikitable"' .. linkresult .. '\n|' .. text .. ']]}'
return result
end