Module:Adjacent stations/sandbox: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 434:
if inline ~= 'box' then
if station then
if inline and mw.ustring.match(inline, 'route') then return '' end
local _Format = data['station format'][station] or data['station format'][1]
station = _Format and getStation(station, _Format) or station or ''
Line 454:
local result
 
if Type and Type ~= '' and inline ~= 'box' and not station then
if line == '' then
line = Type
Line 567:
local system = args[1] or args.system
local data = args.data
if not system and not data then return end
 
if not system and not data then
return
end
 
data = data or getData(system)
local line_typeline, lineN = getLine(data, args[32] or args.typeline)
 
local line, line_nametypeN = getLine(data, args[23] or args.line)type
local icon, icon_format
 
local icon
local icon_format
 
if line then
if not icontypeN then
local line_type = args[3] or args.type
line_typetypeN = data.['aliases'] and data.['aliases'][mw.ustring.lower(line_typetypeN)] or line_typetypeN
if line_type then
line_typelocal Type = line.['types'] and line.['types'][line_typetypeN] -- If there's no type table or entry for this type, then it can't have its own icon
line_type = data.aliases and data.aliases[mw.ustring.lower(line_type)] or line_type
icon_format = lineType['icon format'] or data['linetype icon format']
line_type = line.types and line.types[line_type] -- If there's no type table or entry for this type, then it can't have its own icon
icon_formaticon = line_typeType['icon format'] or data['type icon format']
 
if line_type.icon then
icon = line_type.icon
end
end
 
if not icon then
icon = line.icon
end
 
if not icon then icon = line.['icon'] end
-- Only if there is no icon use the icon_format.
if not icon and not icon_format then icon_format = line['icon format'] or data['line icon format'] end
icon_format = line['icon format'] or data['line icon format']
end
 
local default = data.lines._default or {}
if icon and string.find(icon, "%%1") and default and default.icon then
icon = mw.ustring.gsub(default.icon, '%%1', line_name)
end
 
if icon and string.find(icon, "%%1") andthen defaulticon and= defaultmw.ustring.gsub(icon, then'%%1', lineN) end
if line and= line.['title then']
end
 
if not icon then icon = data['system icon'] end
icon if not icon_format then icon_format = data['system icon format'] end
end
 
if not icon_format then
icon_format = data['system icon format']
end
 
if icon_format then
if icon_format ~= 'image' then
icon = p._box({data = data, [2] = (args[2] or args.line)lineN, [3] = icon_format, type = (args[3] or args.type)typeN, bold = args.bold, link = args.link}, frame)
if require("Module:Yesno")(args.name) then
 
if local station = args.name thenstation
local filter = {yes = true, small = true, dot = true, square = true}
if line and line.title then
if line_type.iconstation then
return icon .. " " .. line.title
local _Format = data['station format'][station] or data['station format'][1]
station = _Format and getStation(station, _Format) or station or ''
if filter[icon_format] then return icon .. ' – ' .. station end
return icon .. " " .. station
else
if not line then return icon .. " " .. data["system title"] end
if filter[icon_format] then return icon end
return icon .. " " .. line.title
end
return icon .. " " .. data["system title"]
end
end
Line 668 ⟶ 653:
end
 
if require("Module:Yesno")(args.name) then
local station = args.station
if line and line.title then
if line_typestation then
return icon .. " " .. line.title
local _Format = data['station format'][station] or data['station format'][1]
station = _Format and getStation(station, _Format) or station or ''
return icon and (icon .. " " .. station) or error(i18n[lang]['error_missing']('icon'))
else
if line then return icon .. " " .. line end
return icon and (icon .. " " .. data["system title"]) or error(i18n[lang]['error_missing']('icon'))
end
return icon .. " " .. data["system title"]
end
return icon
Line 780 ⟶ 770:
return getTerminusText(terminus, data['station format'] or i18n[lang]['error_format'])
else
terminus = frame:expandTemplate{ title = 'S-line/' .. system .. ' ' .. prefix .. '/' .. lineN, args = { ['type'] = typeN} }
return frame:expandTemplate{ title = system .. ' stations', args = {['station'] = terminus, ['line'] = lineN, ['branch'] = typeN} }
end