模組:播放訊息
外观
local p = {}
local platform = {}
function platform.part(args)
args = args or {}
local platform_part = mw.html.create("tr")
platform_part:tag("th")
:attr("colspan", 5)
:css("background", (args["3"] or args["background"] or "#CCCCFF"))
:css("color", (args["4"] or args["color"] or "black"))
:wikitext(args["2"])
return tostring(platform_part)
end
function platform.main(args)
args = args or {}
local aType = args["1"] or args["type"] or nil
if aType == "part" then return platform.part(args)
elseif aType == "line" then
return mw.html.create("tr"):css("border-bottom", ".3em solid "..(args["2"] or args["color"] or "#CCCCFF"))
end
local platform_table = mw.html.create("table")
platform_table
:addClass(args.class or "wikitable")
:css("font-size", args.size or "small")
:css("text-align", args.align or "left")
:cssText(args.style or "")
if args.version ~= nil then args.version = args.version.." " end
if args.season ~= nil then args.season = args.season.." " end
local text = ((args.area or "日本國內").." "..(args.media or "電視").."/"..(args.version or "")..(args.season or "").. (args.caption or "播放日期時間"))
if (args.ref or args.refname) then
local reference = { "ref", args.ref }
if args.refname and args.refgroup then reference = { "ref", args.ref or "", name=args.refname, args.refgroup }
elseif args.refname then reference = { "ref", args.ref or "", name=args.refname }
elseif args.refgroup then reference = { "ref", args.ref or "", name=args.refgroup }
else reference = { "ref", args.ref }
end
text = text..mw.getCurrentFrame():callParserFunction("#tag", reference)
end
platform_table:tag("caption")
:wikitext(args.network or text)
platform_table:tag("tr")
platform_table
:tag("th"):css("width",args["width1"]):wikitext(args["1"] or "播放日期")
:tag("th"):css("width",args["width2"]):wikitext(args["2"] or "播放時間")
:tag("th"):css("width",args["width3"]):wikitext(args["3"] or "所屬聯播網")
local startWith = 5
local percentWith = 5
if args[4] ~= nil and not args["4"]:match("^%s*$") then
platform_table:tag("th"):css("width",args["width4"]):wikitext(args["4"])
else percentWith = percentWith - 1
end
if args[5] ~= nil and not args["5"]:match("^%s*$") then
platform_table:tag("th"):css("width",args["width5"]):wikitext(args["5"])
else
percentWith = percentWith - 1
end
local num = 0
local num2 = 0
platform_table:tag("tr")
for i=(startWith+1),160 do
if args[i] == nil then break end
if not args[i]:match("^%s*$") then
platform_table:tag("td"):wikitext(args[i])
elseif not ((args[num+1] == "備註") or (args[num+1] == "备注")) then
platform_table:tag("td"):attr("abbr",args[i]):cssText((num2 < percentWith and "" or "border-top:hidden")):wikitext("")
else
platform_table:tag("td"):wikitext("")
end
num = num + 1
num2 = num2 + 1
if num>=percentWith then
platform_table:tag("tr")
num = 0
end
end
if args["note"] ~= nil then
platform_table:tag("tr"):tag("td"):attr("colspan",startWith):css("font-size", "x-small"):wikitext(args.note)
end
return tostring(platform_table)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
removeBlanks = false,
wrappers = "Template:播放訊息"
})
return platform.main(args)
end
return p