模块:Rail line box
来自RIA | Wiki
更多操作
此模块的文档可以在模块:Rail line box/doc创建
local getArgs = require("Module:Arguments").getArgs
local yesno = require('Module:Yesno')
local data = {
-- 各个系统标识符所对应的线路, 如有需要请自行对照格式添加。
["systemtooltip"] = {
["R"] = "社营轨道交通",
["N"] = "社营下界轨道交通 (即社营地狱铁路)",
["M"] = "抹岚轨道交通",
["T"] = "溯铁",
["S"] = "尚创地铁",
["H"] = "海华铁路",
["HR"] = "后土铁路",
}
}
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local system = args.system or args[1]
local line = args.line or args[2]
local station = args.station or args[3]
local inline = yesno( args.inline ) or false
local tooltip
local extraClass = args.extraclass
local extraStyles = args.extrastyle
local systemBgc = args["bgc-system"] or args.systembgc or args.bgc1
local lineBgc = args["bgc-line"] or args.linebgc or args.bgc2
local stationBgc = args["bgc-station"] or args.stationbgc or args.bgc3
local systemColor = args["color-system"] or args.systemcolor or args.color1
local lineColor = args["color-line"] or args.line or args.color2
local stationColor = args["color-station"] or args.stationcolor or args.color
local systemStyles = args["style-system"] or args.systemstyle or vstyle1
local lineStyles = args["style-line"] or args.linestyle or args.style2
local statonStyles = args["style-station"] or args.stationstyle or args.style3
local routemark
local routemarkChild
if inline then
routemark = mw.html.create( "span" )
routemarkChild = "span"
else
routemark = mw.html.create( "div" )
routemarkChild = "div"
end
for k, v in pairs(data["systemtooltip"]) do
if k == system then
tooltip = v
end
end
routemark
:addClass( "template-routemark")
:addClass( extraClass )
:cssText( extraStyles )
if inline then
routemark:addClass( "inline" )
end
if system then
routemark:tag( routemarkChild )
:attr("title", tooltip)
:addClass( "template-routemark-system" )
:css("background-color", systemBgc)
:css("color", systemColor)
:cssText( systemStyles )
:wikitext( system )
end
if line then
routemark:tag( routemarkChild )
:addClass( "template-routemark-line" )
:css("background-color", lineBgc)
:css("color", lineColor)
:cssText( lineStyles )
:wikitext( line )
end
if station then
routemark:tag( routemarkChild )
:addClass( "template-routemark-station" )
:css("background-color", stationBgc)
:css("color", stationColor)
:cssText( stationStyles )
:wikitext( station )
end
routemark:allDone()
return tostring( routemark )
end
return p