跳转到内容

模組:LACMTA

维基百科,自由的百科全书
local getArgs = require('Module:Arguments').getArgs
 
local p = {}
 
local function makeInvokeFunction(funcName)
	-- makes a function that can be returned from #invoke, using
	-- [[Module:Arguments]].
	return function (frame)
		local args = getArgs(frame, {parentOnly = true})
		return p[funcName](args)
	end
end
 
local function colorbox(color,text,link)
	return '[['..link..'|<span style="border:1px solid darkgray;background-color:'..color..'" title="'..text..'">&nbsp;&nbsp;&nbsp;&nbsp;</span>]]&nbsp;'
end
 
local t1 = {
	['A Line'] = { 'a', 'a line', 'line a', 'blue', 'blue line','蓝线', icon='img_circle', dab=true, },
	['B Line'] = { 'b', 'b line', 'line b', 'red', 'red line','红线', icon='img_circle', dab=true, },
	['C Line'] = { 'c', 'c line', 'line c', 'green', 'green line','绿线', icon='img_circle', dab=true, },	
	['D Line'] = { 'd', 'd line', 'line d', 'purple', 'purple line','紫线', icon='img_circle', dab=true, },
	['E Line'] = { 'e', 'e line', 'line e', 'expo', 'expo line','博览线', icon='img_circle', dab=true, },	
	['G Line'] = { 'g', 'g line', 'line g', 'orange', 'orange line', '橙线', icon='img_square', dab=true, },	
	['J Line'] = { 'j', 'j line', 'line j', 'silver', 'silver line', '银线', icon='img_square', dab=true, },	
	['K Line'] = { 'k', 'k line', 'line k', 'crenshaw', 'crenshaw line', 'crenshaw/lax', 'crenshaw/lax line', '克伦肖/洛杉矶国际机场线',icon='img_circle', dab=true, },
	['L Line'] = { 'l', 'l line', 'line l', 'gold', 'gold line','金线', icon='img_circle', dab=true, },	
	['Harbor Transitway'] = { 'harbor', 'harbor transitway', color='#B8860B', icon='colorbox', },
	['El Monte Busway'] = { 'el monte', 'el monte busway', color='#B8AD93', icon='colorbox', },
	['Regional Connector'] = { 'regional', 'regional connector', 'regional connector transit corridor', color='#604020', icon='colorbox', },
}

p.icon = makeInvokeFunction('_icon')
 
function p._icon(args)
	local link
	local code = args[1] or ''
	local text = args[2]
	if text then text = '('..text..')' else text = '' end
	local showtext = args.showtext
	for k, v in pairs(t1) do
		for _, name in ipairs(v) do
			if mw.ustring.lower(code) == name then
				if v.dab == true then
					if k=='A Line' then
						Mode='轻轨'
						CName= 'A线'
					elseif k=='B Line' then 
						Mode='地铁'
						CName= 'B線'
					elseif k=='C Line' then
						Mode='轻轨'
						CName= 'C线'
					elseif k=='D Line' then
						Mode='地鐵'
						CName= 'D線'
					elseif k=='E Line' then
						Mode='轻轨'
						CName= 'E线'
					elseif k=='G Line' then
						Mode= '快速公交'
						CName= 'G线'
					elseif k=='J Line' then
						Mode='快速公交'
						CName= 'J线'
					elseif k=='K Line' then 
						Mode='轻轨'
						CName= 'K线'
					elseif k=='L Line' then CName= '克伦肖/洛杉矶国际机场线'
					else
						CNAME = k 	-- 	Someone Finish THis
					end
				
					if Mode == '快速公交' or Mode == '轻轨' then
						link = '洛杉矶'..Mode..CName
					else
						link = '洛杉矶地铁'..CName
					end
							
					if showtext then showtext = '[['..link..'|'..CName..']]&nbsp;' else showtext = '' end
				else
					link = k
					if showtext then showtext = '[['..k..']]&nbsp;' else showtext = '' end
				end
				if v.icon == 'colorbox' then
					return colorbox(v.color,k,k)..showtext..text
				elseif v.icon == 'crenshaw' then
					return '[[File:LACMTA Circle Crenshaw Line.svg|'..(args.size or 17)..'px|link='..link..'|alt='..k..'|'..k..']]&nbsp;'..showtext..text
				elseif v.icon == 'img_circle' then
					return '[[File:LACMTA Circle '..k..'.svg|'..(args.size or 17)..'px|link='..link..'|alt='..k..'|'..k..']]&nbsp;'..showtext..text
				elseif v.icon == 'img_square' then
					return '[[File:LACMTA Square '..k..'.svg|'..(args.size or 17)..'px|link='..link..'|alt='..k..'|'..k..']]&nbsp;'..showtext..text
				end
			end
		end
	end
	return colorbox('#fff',code..' Line',code..' Line (Los Angeles Metro)')..text
end
 
return p