2023年政策修订增补工作正在进行中,欢迎参与!
Module:Sandbox/破壁人五号/VOCALOID Songbox Introduction
跳转到导航
跳转到搜索
-- Module:VOCALOID Songbox Introduction
-- Made with ♥ by User:Leranjun
-- This module implements {{tl|VOCALOID Songbox Introduction}}.
-- Please refrain from invoking this module directly.
local p = {}
local getArgs = require("Module:Arguments").getArgs
local KW = {
["lbgcolor"] = true,
["ltcolor"] = true,
["rbdcolor"] = true,
["ldc"] = true,
["args"] = true
}
local function startsWith(s, t)
return (mw.ustring.sub(s, 1, mw.ustring.len(t)) == t)
end
function p.main(frame)
return p._main(
getArgs(
frame,
{
valueFunc = function(k, v)
if (KW[k]) then
return mw.text.trim(v)
elseif v then
v = mw.text.trim(v)
if v ~= "" then
return v
end
end
return nil
end
}
)
)
end
function p._main(args)
local parsed = p.parse(args)
local wrapper = mw.html.create("div")
wrapper:css("text-align", "left")
if args.ldc and (args.ldc ~= "no") then
local LDC = mw.html.create("div")
LDC:css("float", "right")
local frame = mw.getCurrentFrame()
if args.ldc == "yes" then
args.ldc = nil
end
LDC:wikitext(frame:preprocess(args.ldc or "本段落中所使用的歌词,其著作权属于原作者,仅以介绍为目的引用。"))
wrapper:node(tostring(LDC))
wrapper:node(frame:preprocess("{{clear|right}}"))
end
local mainTable = mw.html.create("table")
mainTable:cssText("margin-left: 0.5em; float: right;")
for k, v in ipairs(parsed.group) do
local row = mw.html.create("tr")
local cell = mw.html.create("td")
cell:cssText("vertical-align: middle; padding: 0 2px;"):css("background-color", args.lbgcolor or "transparent"):css(
"color",
args.ltcolor or "#0645ad"
)
cell:wikitext(v)
row:node(tostring(cell))
cell = mw.html.create("td")
cell:css("border", (args.rbdcolor or args.lbgcolor) .. " 1px solid")
cell:wikitext(args["list" .. k])
row:node(tostring(cell))
mainTable:node(tostring(row))
end
for _, k in pairs(parsed.args) do
if (parsed[""][k]) then
local v = parsed[""][k]
local row = mw.html.create("tr")
local cell = mw.html.create("td")
cell:cssText("vertical-align: middle; padding: 0 2px;"):css(
"background-color",
args.lbgcolor or "transparent"
):css("color", args.ltcolor or "#0645ad")
cell:wikitext(k)
row:node(tostring(cell))
cell = mw.html.create("td")
cell:css("border", (args.rbdcolor or args.lbgcolor) .. " 1px solid")
cell:wikitext(v)
row:node(tostring(cell))
mainTable:node(tostring(row))
end
end
wrapper:node(mainTable)
local clear = mw.html.create("div")
clear:addClass("mobileonly"):css("clear", "both")
wrapper:node(clear)
return tostring(wrapper)
end
function p.parse(args)
local r = {["group"] = {}, [""] = {}}
r.args = mw.text.split(args.args, ";")
for k, v in pairs(args) do
if (startsWith(k, "group")) then
r["group"][tonumber(mw.ustring.sub(k, 6, mw.ustring.len(k)))] = v
elseif ((not KW[k]) and (not startsWith(k, "list"))) then -- 屏蔽已存在的项目
r[""][k] = v
end
end
return r
end
return p