模块:LineList:修订间差异

来自临东市服务器Wiki
无编辑摘要
无编辑摘要
 
(未显示同一用户的26个中间版本)
第1行: 第1行:
--
-- 柠檬写的 230909
-- For 临东定制
--
local p = {}
local p = {}


function p.infobox(frame)
function p.infobox(frame)
    local args = frame.args
local args = frame:getParent().args
    local lineName = args.Name or ""
local lineName = args.Name
    local lineColor = args.Color or "gray"
local lineColor = args.Color
    local company = args.Company or ""
local company = args.Company
    local firstTrain = args.FirstTrain or ""
local ticket = args.Ticket
    local lastTrain = args.LastTrain or ""
local firstTrain = args.FirstTrain
 
local lastTrain = args.LastTrain
    local output = mw.html.create("div")
    output:addClass("infobox-card")
local output = mw.html.create("div")
 
output:addClass("infobox-card")
    local header = output:tag("div"):addClass("header")
    header:tag("div"):addClass("line-name"):wikitext(lineName)
if args.Clear ~= nil then
 
output:cssText('clear: unset;')
    local detail = header:tag("div"):addClass("detail")
end
    detail:tag("div"):addClass("company"):wikitext(company)
 
local header = output:tag("div"):addClass("header")
    local time = header:tag("div"):addClass("time")
header:tag("div"):addClass("line-name"):wikitext(lineName)
    time:tag("div"):addClass("first-train"):wikitext(firstTrain)
    time:tag("div"):addClass("last-train"):wikitext(lastTrain)
local detail = header:tag("div"):addClass("detail")
 
detail:tag("div"):addClass("company"):wikitext(company)
    local stationList = output:tag("ul"):addClass("station-list")
 
local time = header:tag("div"):addClass("time")
    local stationIndex = 1
time:tag("div"):addClass("first-train"):wikitext(firstTrain)
    local insertedLine = false
time:tag("div"):addClass("last-train"):wikitext(lastTrain)
    while args["Sta" .. stationIndex] do
time:tag("div"):addClass("ticket"):wikitext(ticket)
        local stationInfo = args["Sta" .. stationIndex]
        local staName = mw.ustring.match(stationInfo, "([^|]+)")
local stationList = output:tag("ul"):addClass("station-list")
       
if args.Direction then
        if staName then
local direction = args.Direction
            local li = stationList:tag("li")
stationList:tag("div"):addClass("direction"):wikitext(direction)
            local stationDiv = li:tag("div"):addClass("name"):wikitext(staName)
end
           
stationList:wikitext("<div class='line' style='background-color:" .. lineColor .. ";'></div>")
            local transferInfo = mw.ustring.match(stationInfo, "|(.+)")
            if transferInfo then
local maxStationIndex = 0
                local transferDiv = stationDiv:tag("div"):addClass("transfer")
for key, _ in pairs(args) do
                local transferCount = 0
local stationIndex = tonumber(key:match("^Sta(%d+)$"))
                for transfer in mw.ustring.gmatch(transferInfo, "([^/]+)") do
if stationIndex and stationIndex > maxStationIndex then
                    transferCount = transferCount + 1
maxStationIndex = stationIndex
                    local line, color = mw.ustring.match(transfer, "(.+)%+(%w+)")
end
                    if line and color then
end
                        local transferLineDiv = transferDiv:tag("div")
                        transferLineDiv:tag("div"):wikitext(line)
for stationIndex = 1, maxStationIndex do
                        transferLineDiv:tag("div"):css("background-color", color)
local stationInfo = args["Sta" .. stationIndex]
                    end
if stationInfo then
                end
local li = stationList:tag("li")
 
local stationDiv = li:tag("div"):addClass("name")
                if not insertedLine then
local stationDivCircle = stationDiv:tag("div"):addClass("circle"):cssText('border: 4px solid ' .. lineColor .. ';')
                    insertedLine = true
local expandedText = frame:preprocess(stationInfo)
                    li:done()
stationDiv:wikitext(expandedText)
                    stationList:wikitext("<div class='line' style='background-color:" .. lineColor .. ";'></div>")
                end
-- 未开放
            end
if args["Sta" .. stationIndex .. "Unopen"] then
        end
stationDiv:cssText('color: var(--color-base--subtle);')
 
stationDivCircle:cssText('border: 4px solid var(--color-surface-4);')
        stationIndex = stationIndex + 1
end
    end
 
-- 单向运营
    return tostring(output)
local way = args["Sta" .. stationIndex .. "Way"]
if way then
if string.lower(way) == "up" then
stationDiv:addClass("dir-tag__up")
elseif string.lower(way) == "down" then
stationDiv:addClass("dir-tag__down")
end
end
end
end
return tostring(output)
end
end


return p
return p

2023年9月12日 (二) 23:44的最新版本


--
-- 柠檬写的 230909
-- 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 maxStationIndex = 0
	for key, _ in pairs(args) do
		local stationIndex = tonumber(key:match("^Sta(%d+)$"))
		if stationIndex and stationIndex > maxStationIndex then
			maxStationIndex = stationIndex
		end
	end
	
	for stationIndex = 1, maxStationIndex do
		local stationInfo = args["Sta" .. stationIndex]
		if stationInfo then
			local li = stationList:tag("li")
			local stationDiv = li:tag("div"):addClass("name")
			local stationDivCircle = stationDiv:tag("div"):addClass("circle"):cssText('border: 4px solid ' .. lineColor .. ';')
			local expandedText = frame:preprocess(stationInfo)
			stationDiv:wikitext(expandedText)
			
			-- 未开放
			if args["Sta" .. stationIndex .. "Unopen"] then
				stationDiv:cssText('color: var(--color-base--subtle);')
				stationDivCircle:cssText('border: 4px solid var(--color-surface-4);')
			end
			
			-- 单向运营
			local way = args["Sta" .. stationIndex .. "Way"]
			if way then
				if string.lower(way) == "up" then
					stationDiv:addClass("dir-tag__up")
				elseif string.lower(way) == "down" then
					stationDiv:addClass("dir-tag__down")
				end
			end
		end
	end
	
	return tostring(output)
end

return p