缺氧 wiki 编辑团队提示:注册账号并登录后体验更佳,且可通过参数设置定制优化您的浏览体验!

该站点为镜像站点,如果你想帮助这个由玩家志愿编辑的 wiki 站点,请前往原站点参与编辑,
同时欢迎加入编辑讨论群 851803695 与其他编辑者一起参与建设!

全站通知:

模块:导航栏

来自缺氧WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

此模块的文档可以在模块:导航栏/doc创建

-- Module:导航栏
local p = {}

local yesno = require('Module:Dev/Yesno')

function p.main(frame)
    local args = require('Module:Dev/Arguments').getArgs(frame)
    local separator = nil
    local tr_style = {}
    local navbox = mw.html.create('div'):attr("cellspacing","0")
    local a = navbox:tag('tr'):tag('td'):css('padding','2px')
    local table = a:tag('table'):attr("cellspacing","0"):addClass("navbox"):addClass("nowraplinks mw-collapsible uncollapsed mw-made-collapsible")
    if args.collapse ~= nil and yesno(args.collapse, true) then 
    	table:addClass("mw-collapsed")
    	tr_style.display = "none"
    end
    if args[1] or args.title then
        local title = table:tag('tr'):tag('th'):addClass('navbox-title'):attr("colspan","2")
        if args[1] then local c = title:wikitext(mw.getCurrentFrame():preprocess(args[1]))
        else local c = title:wikitext(mw.getCurrentFrame():preprocess(args.title)) end
    end
    
    if args.separator then separator = ' '..args.separator..' '
    else separator = ' ! ' end
    local group = nil
    local r = nil
    for k, v in ipairs(args) do
        local i = tonumber(k)
        if i and v and i > 1 then
            if i % 2 == 0 then
            	group = table:tag('tr'):css(tr_style)
                local label = group:tag('td'):addClass("navbox-group"):wikitext(mw.getCurrentFrame():preprocess(v))
            else
                local data = group:tag('td'):addClass("navbox-list navbox-odd")
                r = mw.ustring.gsub(mw.getCurrentFrame():preprocess(v),separator,'&nbsp;&bull;&nbsp;<wbr>')
                data:wikitext(r)
                
            end
        end
    end
    if args["group1"] then
    	for i = 1,20 do
            local g = "group"..tostring(i)
            local h = "header"..tostring(i)
            local l = "list"..tostring(i)
            if args[h] then
                group = table:tag('tr'):css(tr_style)
                local title = group:tag('td'):addClass("navbox-title"):attr('colspan','2'):wikitext(args[h])
        		end
            if args[g] then
                group = table:tag('tr'):css(tr_style)
                local label = group:tag('td'):addClass("navbox-group"):wikitext(args[g])
				end
            if args[l] then
                local data = group:tag('td'):addClass("navbox-list")
                data:wikitext(args[l])
            end        
        end
    end

    return navbox
end

return p