Difference between revisions of "Module:Adjacent stations/Taiwan High Speed Rail"

From blackwiki
Jump to navigation Jump to search
blackwiki>Szqecs
m (Szqecs moved page Module:L-rail/Taiwan HSR to Module:L-rail/Taiwan High Speed Rail without leaving a redirect)
blackwiki>Szqecs
Line 1: Line 1:
local p = {}
+
local function link(s1, s2)
 +
if s2 then
 +
return table.concat({'\[\[', s1, '|', s2, '\]\]'})
 +
elseif s1 then
 +
return table.concat({'\[\[', s1, '\]\]'})
 +
end
 +
end
  
function p.l(frame)
+
return {
local f = frame.args -- 'f' for 'frame'
+
['system title'] = link('Taiwan High Speed Rail')
local THSR = {
+
, ['THSR'] = {
'Nangang',
+
['line title'] = link('Taiwan High Speed Rail#Stations_transportation', 'Taiwan High Speed Rail')
'Taipei',
+
, ['colour'] = 'c35617'
'Banqiao',
+
, ['station link'] = function(s)
'Taoyuan',
+
if s == 'Nangang'
'Hsinchu',
+
or s == 'Taipei'
'Miaoli',
+
or s == 'Banqiao' then
'Taichung',
+
return link(s .. ' station', s)
'Changhua',
 
'Yunlin',
 
'Chiayi',
 
'Tainan',
 
'Zuoying',
 
}
 
local function s_link(x) -- 's' for 'station'
 
if x then
 
if x == 'Nangang' or x == 'Taipei' or x == 'Banqiao' then
 
return '\[\[' .. x .. ' station|' .. x .. '\]\]'
 
 
else
 
else
return '\[\[' .. x .. ' HSR station|' .. x .. '\]\]'
+
return link(s .. ' HSR station', s)
 
end
 
end
 
end
 
end
end
+
, ['left terminus'] = 'Nangang'
+
, ['right terminus'] = 'Zuoying'
local index = tonumber(f[2])
 
 
local function div(x, y) -- Text format shortcut
 
if x == 'i' then -- 'i' for 'italic'
 
return '<div style="font-style: italic">' .. y .. '</div>'
 
elseif x == 's' then -- 's' for 'smaller and italic'
 
return '<br><div style="font-size: smaller; font-style: italic">' .. y .. '</div>'
 
end
 
end
 
 
if index > 1 then
 
left = s_link(THSR[index-1])
 
else
 
left = div('i','Terminus')
 
end
 
 
if index < #THSR then
 
right = s_link(THSR[index+1])
 
else
 
right = div('i','Terminus')
 
end
 
 
if index > 2 then
 
left_toward = div('s','toward ' .. s_link(THSR[1]))
 
elseif index == 1 then
 
left_toward = ''
 
elseif index == 2 then
 
left_toward = div('s','Terminus')
 
end
 
 
if index < #THSR - 1 then
 
right_toward = div('s','toward ' .. s_link(THSR[#THSR]))
 
elseif index == #THSR - 1 then
 
right_toward = div('s','Terminus')
 
elseif index == #THSR then
 
right_toward = ''
 
end
 
 
local style = mw.loadData('Module:L-rail/style')
 
local row = {
 
['start'] = '{| class="wikitable" ' .. style['table']
 
,['header'] = '\n|-'
 
.. '\n! ' .. style['header leftcell'] .. 'Preceding station'
 
.. '\n! ' .. style['header midcell'] .. '\[\[Taiwan High Speed Rail\]\]'
 
.. '\n! ' .. style['header rightcell'] .. 'Following station'
 
,['body'] = '\n|-'
 
.. '\n| ' .. style['body leftcell'] .. left .. left_toward
 
.. '\n| ' .. style['body banner'] .. '#C35617"|'
 
.. '\n| ' .. style['body midcell'] .. '\[\[Taiwan High Speed Rail\]\]'
 
.. '\n| ' .. style['body banner'] .. '#C35617"|'
 
.. '\n| ' .. style['body rightcell'] .. right .. right_toward
 
,['end'] = '\n|}'
 
}
 
local position = {
 
['all'] = row['start'] .. row['header'] .. row['body'] .. row['end']
 
,['top'] = row['start'] .. row['header'] .. row['body']
 
,['mid'] = row['body']
 
,['bottom'] = row['body'] .. row['end']
 
,['header mid'] = row['header'] .. row['body']
 
,['header bottom'] =  row['header'] .. row['body'] .. row['end']
 
 
}
 
}
return position[f[1]]
+
}
end
 
 
 
return p
 

Revision as of 03:30, 22 April 2018

Documentation for this module may be created at Module:Adjacent stations/Taiwan High Speed Rail/doc

local function link(s1, s2)
	if s2 then
		return table.concat({'\[\[', s1, '|', s2, '\]\]'})
	elseif s1 then
		return table.concat({'\[\[', s1, '\]\]'})
	end
end

return {
	['system title'] = link('Taiwan High Speed Rail')
	, ['THSR'] = {
		['line title'] = link('Taiwan High Speed Rail#Stations_transportation', 'Taiwan High Speed Rail')
		, ['colour'] = 'c35617'
		, ['station link'] = function(s)
			if s == 'Nangang'
			or s == 'Taipei'
			or s == 'Banqiao' then
				return link(s .. ' station', s)
			else
				return link(s .. ' HSR station', s)
			end
		end
		, ['left terminus'] = 'Nangang'
		, ['right terminus'] = 'Zuoying'
	}
}