模块:AutoTabTable:修订间差异

跳到导航 跳到搜索
添加607字节 、​ 2022年2月1日 (星期二)
无编辑摘要
无编辑摘要
无编辑摘要
第151行: 第151行:
     -- i hate lua why array subscribtion starts at 1
     -- i hate lua why array subscribtion starts at 1
     local tot_row_ids = {}
     local tot_row_ids = {}
    local item_per_tab = tonumber(params["item_per_tab"])
     for k, _ in pairs(args) do
     for k, _ in pairs(args) do
         local anum = ('' .. k):match('^a(%d+)$')
         local anum = ('' .. k):match('^a(%d+)$')
第160行: 第159行:
     table.sort(tot_row_ids)
     table.sort(tot_row_ids)


     local tab_count = math.ceil(tableLength(tot_row_ids) / item_per_tab)
     local tab_count = 0
    local current_item_count = 0
    local current_max_item = tonumber(params["item_per_tab"])
     local tabs_row_ids = {}
     local tabs_row_ids = {}
    for i, a in ipairs(tot_row_ids) do
        if current_item_count == 0 then
            if tab_count ~= 0 then table.sort(tabs_row_ids[tab_count]) end
            tab_count = tab_count + 1
            if args["item_in_tab"..tostring(tab_count)] then
                current_max_item = tonumber(args["item_in_tab"..tostring(tab_count)])
            else
                current_max_item = tonumber(params["item_per_tab"])
            end
            tabs_row_ids[tab_count] = {}
        end
        table.insert(tabs_row_ids[tab_count], a)
        current_item_count = current_item_count + 1
        if current_item_count == current_max_item then
            current_item_count = 0
        end
    end


     -- if only one table is needed...
     -- if only one table is needed...
第171行: 第189行:
         constraint_div:node(tbl)
         constraint_div:node(tbl)
         return constraint_div
         return constraint_div
    end
    for i=1,tab_count do
        tabs_row_ids[i] = {}
        for j=1,item_per_tab do
            tabs_row_ids[i][j] = tot_row_ids[(i-1)*item_per_tab + j]
        end
     end
     end


第193行: 第204行:
         :css("overflow-x", "auto")
         :css("overflow-x", "auto")
      
      
     for i, _ in ipairs(tabs_row_ids) do
    local current_count = 1
     for i, row_ids in ipairs(tabs_row_ids) do
         local list_ele = tab_list:tag("li")
         local list_ele = tab_list:tag("li")
         if i == 1 then
         if i == 1 then
第201行: 第213行:
             :addClass("tab")
             :addClass("tab")
             :tag("strong")
             :tag("strong")
            if args[params['tab_prefix']..tostring(i)] then
        if args[params['tab_prefix']..tostring(i)] then
                ele_title:wikitext(args[params['tab_prefix']..tostring(i)])
            ele_title:wikitext(args[params['tab_prefix']..tostring(i)])
            else
        else  
                ele_title:wikitext(tostring((i-1)*item_per_tab+1).."~"..tostring(i*item_per_tab))
            ele_title:wikitext(tostring(current_count).."~"..tostring(current_count+tableLength(row_ids)-1))
            end
        end
        current_count = current_count + tableLength(row_ids)
     end
     end


导航菜单