AurLemonCN(讨论 | 贡献) 小无编辑摘要 |
AurLemonCN(讨论 | 贡献) 小 (改个缩进) |
||
| 第1行: | 第1行: | ||
-- | -- | ||
-- 柠檬写的 | -- 柠檬写的 230910 | ||
-- For 临东定制 | -- For 临东定制 | ||
-- | -- | ||
| 第8行: | 第7行: | ||
function p.infobox(frame) | function p.infobox(frame) | ||
local args = frame:getParent().args | |||
local lineName = args.Name | |||
local lineColor = args.Color | |||
local company = args.Company | |||
local ticket = args.Ticket | |||
local firstTrain = args.FirstTrain | |||
local lastTrain = args.LastTrain | |||
local output = mw.html.create("div") | |||
output:addClass("infobox-card") | |||
if args.Clear ~= nil then | if args.Clear ~= nil then | ||
output:cssText('clear: unset;') | output:cssText('clear: unset;') | ||
end | end | ||
local header = output:tag("div"):addClass("header") | |||
header:tag("div"):addClass("line-name"):wikitext(lineName) | |||
local detail = header:tag("div"):addClass("detail") | |||
detail:tag("div"):addClass("company"):wikitext(company) | |||
local time = header:tag("div"):addClass("time") | |||
time:tag("div"):addClass("first-train"):wikitext(firstTrain) | |||
time:tag("div"):addClass("last-train"):wikitext(lastTrain) | |||
time:tag("div"):addClass("ticket"):wikitext(ticket) | |||
local stationList = output:tag("ul"):addClass("station-list") | |||
if args.Direction then | if args.Direction then | ||
local direction = args.Direction | local direction = args.Direction | ||
| 第40行: | 第39行: | ||
end | end | ||
stationList:wikitext("<div class='line' style='background-color:" .. lineColor .. ";'></div>") | stationList:wikitext("<div class='line' style='background-color:" .. lineColor .. ";'></div>") | ||
local stationIndex = 1 | |||
while args["Sta" .. stationIndex] do | |||
local stationInfo = args["Sta" .. stationIndex] | |||
if stationInfo then | |||
local li = stationList:tag("li") | |||
local stationDiv = li:tag("div"):addClass("name") | |||
stationDiv:tag("div"):addClass("circle"):cssText('border: 4px solid ' .. lineColor .. ';') | |||
local expandedText = frame:preprocess(stationInfo) | |||
stationDiv:wikitext(expandedText) | |||
end | |||
stationIndex = stationIndex + 1 | |||
end | |||
return tostring(output) | |||
end | end | ||
return p | return p | ||
2023年9月10日 (日) 21:27的版本
--
-- 柠檬写的 230910
-- For 临东定制
--
local p = {}
function p.infobox(frame)
local args = frame:getParent().args
local lineName = args.Name
local lineColor = args.Color
local company = args.Company
local ticket = args.Ticket
local firstTrain = args.FirstTrain
local lastTrain = args.LastTrain
local output = mw.html.create("div")
output:addClass("infobox-card")
if args.Clear ~= nil then
output:cssText('clear: unset;')
end
local header = output:tag("div"):addClass("header")
header:tag("div"):addClass("line-name"):wikitext(lineName)
local detail = header:tag("div"):addClass("detail")
detail:tag("div"):addClass("company"):wikitext(company)
local time = header:tag("div"):addClass("time")
time:tag("div"):addClass("first-train"):wikitext(firstTrain)
time:tag("div"):addClass("last-train"):wikitext(lastTrain)
time:tag("div"):addClass("ticket"):wikitext(ticket)
local stationList = output:tag("ul"):addClass("station-list")
if args.Direction then
local direction = args.Direction
stationList:tag("div"):addClass("direction"):wikitext(direction)
end
stationList:wikitext("<div class='line' style='background-color:" .. lineColor .. ";'></div>")
local stationIndex = 1
while args["Sta" .. stationIndex] do
local stationInfo = args["Sta" .. stationIndex]
if stationInfo then
local li = stationList:tag("li")
local stationDiv = li:tag("div"):addClass("name")
stationDiv:tag("div"):addClass("circle"):cssText('border: 4px solid ' .. lineColor .. ';')
local expandedText = frame:preprocess(stationInfo)
stationDiv:wikitext(expandedText)
end
stationIndex = stationIndex + 1
end
return tostring(output)
end
return p