Module:Sandbox/Chi ZJ2/模块:UmaList
跳到导航
跳到搜索
local p = {} function p.class() if (mw.title.getCurrentTitle().text == "音乐鉴赏") then local class = " mw-collapsed" return class end end function p.table(frame) local max_pieces = 50 local args = (frame == mw.getCurrentFrame() and frame.args) or frame res_table = {} local title = mw.text.trim(args["表格标题"] or "") local have_album = ((mw.text.trim(args["专辑栏"] or ""))~="") local lack_file = false local table_class = "wikitable mw-collapsible mw-collapsible-dark mw-collapsible-title-center"..(p.class() or '') table.insert(res_table, string.format("\n{|class=\"%s\" ", table_class)) table.insert(res_table, "style=\"width:850px;max-width:100%;line-height:18px;text-align:center;display:table;white-space:normal;\"\n") table.insert(res_table, string.format("!style=\"font-size:14px;\" colspan=3| %s\n", title)) table.insert(res_table, string.format("|-\n%s!class=\"nomobile\"|标题\n! width=\"450px\"|播放\n", (have_album and "!class=\"nomobile\" width=\"64px\"|专辑封面\n" or ""))) for i = 1, max_pieces do local piece_title = mw.text.trim(args["标题" .. i] or "") if piece_title ~= "" then local piece_style = mw.text.trim(args["样式" .. i] or "") local piece_file = mw.text.trim(args["资源" .. i] or "") local piece_album = mw.text.trim(args["专辑" .. i] or "") local piece_title_hl = ((string.find(piece_style, "非官方") or "")~="") local piece_title_game = ((string.find(piece_style, "游戏版") or "")~="") local piece_title_noAK = ((string.find(piece_style, "外源") or "")~="") local piece_title_boss = ((string.find(piece_style, "Boss") or "")~="") local piece_title_dep = ((string.find(piece_style, "已弃用") or "")~="") local piece_title_already = ((string.find(piece_style, "旧曲") or "")~="") local piece_lack_file = (piece_file == "") local piece_lack_album = (piece_album == "") if piece_title_boss then piece_title = "<span style=\"color:white;background: linear-gradient(90deg,#c1470e,#9e2626,#5b2400);border-radius:20px;padding-left:8px;padding-right:8px\">'''BOSS'''</span><br>"..piece_title end table.insert(res_table, "\n|-\n") if have_album then if not(piece_lack_album) then table.insert(res_table, string.format("| class=\"nomobile\"| <img width=\"64px\" src=\"%s\">\n", piece_album)) else table.insert(res_table, "| class=\"nomobile\"| 暂无\n") end end table.insert(res_table, string.format("| class=\"nomobile\" style=\"%s\"|%s\n", ((piece_title_hl and "color:#ff8f00;") or (piece_title_game and "color:#1e88e5;") or (piece_title_noAK and "color:#00897b;") or (piece_title_already and "color:#ababab;") or ""), (piece_title_dep and "<del> "..piece_title.." </del>" or piece_title))) table.insert(res_table, string.format("|<div class=\"nodesktop\">%s%s%s</div>", ((piece_title_hl and "<span style=\"color:#ff8f00;\">") or (piece_title_game and "<span style=\"color:#1e88e5;\">") or (piece_title_noAK and "<span style=\"color:#00897b;\">") or (piece_title_already and "<span style=\"color:#ababab;\">") or ""), (piece_title_dep and "<del> "..piece_title.." </del>" or piece_title), ((piece_title_hl or piece_title_game) and "</span>" or ""))) if not(piece_lack_file) then local player_args = {"Html5media", attr = 'preload="none"', url=piece_file, width=300, height=54} code_player = frame:callParserFunction{name = '#Widget', args = player_args} table.insert(res_table, code_player) else table.insert(res_table, "<span style=\"color:red;line-height:54px;\">音乐文件缺失</span>") end lack_file = lack_file or piece_lack_file end end table.insert(res_table, "\n|}") if lack_file then table.insert(res_table, "[[分类:音乐文件缺失的页面]]") end return table.concat(res_table) end return p