跳转到内容

模組:劇集列表

维基百科,自由的百科全书

这是本页的一个历史版本,由HelloYu0910留言 | 贡献2024年7月19日 (五) 09:31 建立内容为“ local p = {} local episodes = {} local titleList = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} local localColSpan = 1 local localRowSpan = 1 function episodes.headerRow(text, style, rowStyle, colspan, rowspan) local row = mw.html.create("th") if text ~= "" then localColSpan = localColSpan + 1 localRowSpan = localRowSpan + 1 row :attr("colspan", (colspan or "1"))…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local p = {}
local episodes = {}

local titleList = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
local localColSpan = 1
local localRowSpan = 1

function episodes.headerRow(text, style, rowStyle, colspan, rowspan)
	local row = mw.html.create("th")
	
	if text ~= "" then
		localColSpan = localColSpan + 1
		localRowSpan = localRowSpan + 1
		row
		   :attr("colspan", (colspan or "1"))
		   :attr("rowspan", (rowspan or localRowSpan))
		   :cssText("padding:.2em .5em;"..(rowStyle or "")..(style or ""))
		   :wikitext(text)
		return row
	end
	
	return
end

function episodes.baseSummaryRow(text, lineColor)
	local row = mw.html.create("td")
	
	if text ~= "" then
		row:attr("colspan", localColSpan)
		   :css("padding", ".5em")
		   :css("text-align", "left")
		   :css("background", "white")
		   :css("white-space", "normal")
		   :css("border-bottom", ".3em solid "..(lineColor or "#aaa"))
		   :wikitext(text)
		return row
	end

	return
end

function episodes.titleRow(text, rowStyle, style)
	local row = mw.html.create("td")
	
	if text ~= "" then
		row:attr("rowspan", 1)
		   :css("text-align", "left")
		   :css("padding", ".2em .5em")
		   :css("line-height", "1.2")
		   :cssText((rowStyle or "")..(style or ""))
		   :wikitext(text)
		return row
	end
	
	return
end

function episodes.multipleTitleRow(text, style, rowStyle)
	local row = mw.html.create("td")
	
	if text ~= "" then
		row:addClass("Title-EX")
		   :attr("scope", "row")
		   :css("height", "2em")
		   :css("text-align", "left")
		   :css("padding", ".2em .5em")
		   :css("line-height", "1.2")
		   :cssText((rowStyle or "")..(style or ""))
		   :wikitext(text)
		return row
	end

	return
end

function episodes.chapterRow(text, style, rowStyle, lineColor)
	local row = mw.html.create("th")
	
	if text ~= "" then
		if (lineColor or "") ~= "" then row:css("border-bottom-color", lineColor) end
		row:attr("colspan", (colspan or "25"))
		   :cssText((rowStyle or "")..(style or ""))
		   :wikitext(text)
		return row
	end

	return
end

function episodes.baseRow(tableclass, class, text, style, rowStyle, colspan, rowspan)
	local row = mw.html.create(tableclass or "td")
	
	if text ~= "" then
		localColSpan = localColSpan + 1
		row
		   :addClass(class or "")
		   :attr("scope", "col")
		   :attr("colspan", (colspan or "1"))
		   :attr("rowspan", (rowspan or tostring(localRowSpan-1)))
		   :css("text-align", "center")
		   :cssText("padding:.2em .5em;"..(rowStyle or "")..(style or ""))
		   :wikitext(text)
		return row
	end

	return ""
end

function episodes.base(args)
	args = args or {}

	local base = mw.html.create("tr")
	local text = "td"
	
	if args.Chapter then
		base:node(episodes.chapterRow(args.Chapter, args.ChapterStyle, args.Style, args.ChapterColSpan))
		return base
	end

	if args.Summary and mw.title.getCurrentTitle().text ~= args.SublistOf then text = "th" end
	
	base
		:node(episodes.baseRow("th", "", (args.Header0 or ""), args.Header0Style, args.Style, args.Header0ColSpan, args.Header0RowSpan))
		:node(episodes.baseRow("th", "", (args.Header1 or ""), args.Header1Style, args.Style, args.Header1ColSpan, args.Header1RowSpan))
	
	if (args["TitleA"] or "") ~= "" then
		for i=1,6 do if (args["Title"..titleList[i]] or "") ~= "" then localRowSpan = localRowSpan + 1 end end
	else localRowSpan = 0 end

	if args["Number"] ~= "!INVISIBLE" then base:node(episodes.baseRow(text, "", args.Number, args.NumberStyle, args.Style, args.NumberColSpan, args.NumberRowSpan)) end
	
	if (args["TitleA"] or "") ~= "" then
		local text = args["TitleA"] or ""
		if (args["SubtitleA"] or "") ~= "" then
			text = text .. "<br /><small style=\"color:gray;" .. (args["SubtitleAStyle"] or "") .. "\"><em>" .. (args["SubtitleA"] or "") .. "</em></small>"
		end
		if (args["NativeTitleA"] or "") ~= "" then
			text = text .. "<br />-{(" .. args["NativeTitleA"] .. ")}-"
		end
		base:node(episodes.multipleTitleRow(text, args.Style, args["TitleAStyle"]))
	elseif args["Title"] ~= "!INVISIBLE" then
		local text = args.Title or ""
		if args.Summary and mw.title.getCurrentTitle().text ~= args.SublistOf then text = "<strong>"..(args.Title or "").."</strong>" end
		if (args["Subtitle"] or "") ~= "" then text = text .. "<br /><small style=\"color:gray;" .. (args["SubtitleStyle"] or "") .. "\"><em>" .. (args["Subtitle"] or "") .. "</em></small>" end
		if (args["NativeTitle"] or "") ~= "" then text = text .. "<br />-{(" .. args["NativeTitle"] .. ")}-" end
		base:node(episodes.titleRow(text, args.TitleStyle, (args.Style or ""), args.TitleColSpan, args.TitleRowSpan))
	end

	for i=0,19 do
		base:node(episodes.baseRow("td", "", (args["Aux"..i] or ""), args["Aux"..i.."Style"], args.Style, args["Aux"..i.."ColSpan"], args["Aux"..i.."RowSpan"]))
		if mw.title.getCurrentTitle().text ~= args.SublistOf then
			if i == 19 then
				for j=16,19 do
					base:node(episodes.baseRow("td", "", (args["SubAux"..j] or ""), args["SubAux"..j.."Style"], args.Style, args["SubAux"..j.."ColSpan"], args["SubAux"..i.."RowSpan"]))
				end
			elseif i%4 == 0 then
				for j=0+6*((i-4)/4),5+6*((i-4)/4) do
					base:node(episodes.baseRow("td", "", (args["SubAux"..j] or ""), args["SubAux"..j.."Style"], args.Style, args["SubAux"..j.."ColSpan"], args["SubAux"..i.."RowSpan"]))
				end
			end
		end
	end

	if (args["TitleA"] or "") ~= "" then
		for i=2,6 do
			if (args["Title"..titleList[i]] or "") ~= "" then
				local text = args["Title"..titleList[i]] or ""
				if (args["Subtitle"..titleList[i]] or "") ~= "" then
					text = text .. "<br /><small style=\"color:gray;" .. (args["Subtitle"..titleList[i].."Style"] or "") .. "\"><em>" .. (args["Subtitle"..titleList[i]] or "") .. "</em></small>"
				end
				if (args["NativeTitle"..titleList[i]] or "") ~= "" then
					text = text .. "<br />-{(" .. args["NativeTitle"..titleList[i]] .. ")}-"
				end
				base:tag("tr"):node(episodes.multipleTitleRow(text, (args["Title"..titleList[i].."Style"] or ""), args["Title"..titleList[i].."ColSpan"], args["Title"..titleList[i].."RowSpan"]))
			end
		end
	end
	
	if (args.Summary or "") ~= "" and mw.title.getCurrentTitle().text ~= args.SublistOf then 
		base:tag("tr"):node(episodes.baseSummaryRow(args.Summary, args.LineColor))
	end
		
    return base
end

function episodes.header(args)
	args = args or {}
	
	local header = mw.html.create("table")
	
	if not args.ExcludeTableTag then
		header
		  :addClass("wikitable")
		  :css("border-collapse", "collapse")
		  :css("border-spacing", "0")
		  :cssText(args.TableStyle)
	end
	
	if (args.Caption or "") ~= "" then
		header:tag("caption")
			  :cssText(args.CaptionStyle)
			  :wikitext(args.Caption)
	end
		  
	local headerRow = header:tag("tr")
	
	headerRow
		     :cssText("border-bottom: .3em solid " .. (args.LineColor or "#aaa"))
			 :node(episodes.headerRow((args.Header0 or ""), args.Header0Style, args.Style, args.Header0ColSpan, args.Header0RowSpan))
			 :node(episodes.headerRow((args.Header1 or ""), args.Header1Style, args.Style, args.Header1ColSpan, args.Header1RowSpan))
	if args["Number"] ~= "!INVISIBLE" then
		headerRow:node(episodes.headerRow((args.Number or "#"), args.NumberStyle, args.Style, args.NumberColSpan, args.NumberRowSpan))
	end
	if args["Title"] ~= "!INVISIBLE" then
		local text = args.Title or "劇集標題"
		if (args["Subtitle"] or "") ~= "" then
			text = text .. "<br /><small style=\"color:gray;" .. (args.SubtitleStyle or "") .. "\"><em>" .. (args.Subtitle or "") .. "</em></small>"
		end
		headerRow:node(episodes.headerRow(text, args.TitleStyle, args.Style, args.TitleColSpan, args.NumberRowSpan))
	end
	for i=0,19 do
		headerRow:node(episodes.headerRow((args["Aux"..i] or ""), args["Aux"..i.."Style"], args["Aux"..i.."ColSpan"], args["Aux"..i.."RowSpan"]))
		if mw.title.getCurrentTitle().text ~= args.SublistOf then
			if i == 19 then
				for j=16,19 do
					headerRow:node(episodes.headerRow((args["SubAux"..j] or ""), args["SubAux"..j.."Style"], args.Style, args["SubAux"..j.."ColSpan"], args["SubAux"..j.."RowSpan"]))
				end
			elseif i%4 == 0 then
				for j=0+6*((i-4)/4),5+6*((i-4)/4) do
					headerRow:node(episodes.headerRow((args["SubAux"..j] or ""), args["SubAux"..j.."Style"], args.Style, args["SubAux"..j.."ColSpan"], args["SubAux"..j.."RowSpan"]))
				end
			end
		end
	end
    return tostring(mw.ustring.gsub(tostring(header), "</table>", ""))
end

function p.mainHeader(frame)
    local args = require('Module:Arguments').getArgs(frame, {
		removeBlanks = false,
        wrappers = "User:HelloYu0910/沙盒"
    })
	return episodes.header(args)
end

function p.main(frame)
    local args = require('Module:Arguments').getArgs(frame, {
		removeBlanks = false,
        wrappers = "User:HelloYu0910/沙盒"
    })
	return episodes.base(args)
end

return p