跳转到内容

模組:車站構造

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

local getArgs = require('Module:Arguments').getArgs;
local tools = require 'Module:TableTools'
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(frame, args)
end

function p._main(frame, args)
	local out = mw.html.create 'table'
		:addClass 'station-structure-table'
		:addClass(args.class)
		:cssText(args.style)
		-- :css('border-collapse', 'collapse')
		-- :attr('cellpadding', '5')
	local span_now = 0
	local numData = tools.numData(args)
	for i, item in tools.sparseIpairs(numData) do
		local floor   = item.floor or item.f or item['層'] or item['层']
		local span    = tonumber( item.span or (floor and 1 or 0) )
		local label   = item.label or item.l or item['標'] or item['标']
		local content = item.content or item.c or item['文'] or ''
		span_now = span_now > 0 and span_now or span
		if span_now > 0 then
			local tr = out
				:tag 'tr'
				:addClass 'station-structure-table-row'
				-- :cssText("vertical-align:middle;border:solid gray;border-width:1px 0;")
			
			if floor then
				tr:tag 'td'
					:attr('rowspan', span)
					:addClass 'station-structure-floor'
					:wikitext(floor)
			end
			if label then
			tr:tag 'td':addClass 'station-structure-label':wikitext(label) end
			local cc = tr:tag 'td':addClass 'station-structure-content':wikitext(content)
				:attr('colspan', (not label) and '2' or nil)
			if string.find(content, "station%-structure%-platform") then cc:addClass 'station-structure-platform-cell' end
		end
		span_now = span_now - 1
	end
	out:wikitext(frame:extensionTag {name = 'templatestyles', args = {src = 'Template:車站構造/style.css'}})
	return out
end

return p