Module:Sandbox/BearBin/List163
< Module:Sandbox | BearBin
跳到导航
跳到搜索
local getArgs = require("Module:Arguments").getArgs local p = {} --[==[ 别问我为什么不用mw.html库,问就是手搓好玩( ]==] function NewDiv(content, classes) if classes ~= nil then return '<div class="' .. classes .. '">' .. content .. "</div>" end return "<div>" .. content .. "</div>" end function NewImg(src) return '<img src="' .. src .. '" />' end function p.main(frame) local args = getArgs(frame) return p._main(args) end function p._main(args) local innerHtml = {} -- top local top = NewDiv( table.concat( { NewDiv(NewImg(args.cover), "list163-cover"), NewDiv( table.concat( { NewDiv(args.name, "list163-name"), NewDiv( NewImg(args.avatar) .. " " .. args.creator .. " " .. args.date .. "创建", "list163-creator" ), NewDiv( table.concat( { NewDiv("播放全部", "list163-playall"), NewDiv("收藏"), NewDiv("分享"), NewDiv("下载") } ), "list163-action" ), NewDiv( table.concat( { NewDiv("标签:" .. args.tags, "list163-tag"), NewDiv("歌曲:" .. args.count .. " 播放:" .. args.play, "list163-data"), NewDiv("简介:" .. args.brief, "list163-brief") } ) ) } ), "list163-info" ) } ), "list163-top" ) table.insert(innerHtml, top) -- rows local rowheader = NewDiv( table.concat( { NewDiv("", "list163-song-no"), NewDiv("操作", "list163-song-action"), NewDiv("标题", "list163-song-title"), NewDiv("歌手", "list163-song-artist"), NewDiv("专辑", "list163-song-cd"), NewDiv("时间", "list163-song-length") } ), "list163-row list163-header" ) table.insert(innerHtml, rowheader) table.insert(innerHtml, "-{") local i = 1 while args["title-" .. i] do local no if i < 10 then no = "0" .. i else no = tostring(i) end table.insert( innerHtml, NewDiv( table.concat( { NewDiv(no, "list163-song-no"), NewDiv("❤↓", "list163-song-action"), NewDiv(args["title-" .. i], "list163-song-title"), NewDiv(args["artist-" .. i], "list163-song-artist"), NewDiv(args["cd-" .. i], "list163-song-cd"), NewDiv(args["length-" .. i], "list163-song-length") } ), "list163-row" ) ) i = i + 1 end table.insert(innerHtml, "}-") return NewDiv(table.concat(innerHtml), "list163") end return p