242
个编辑
Willson-v-(讨论 | 贡献) 无编辑摘要 |
Willson-v-(讨论 | 贡献) 无编辑摘要 |
||
第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 = {} | ||
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 = | 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 | end | ||
第193行: | 第204行: | ||
:css("overflow-x", "auto") | :css("overflow-x", "auto") | ||
for i, | 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 | |||
ele_title:wikitext(args[params['tab_prefix']..tostring(i)]) | |||
else | |||
ele_title:wikitext(tostring(current_count).."~"..tostring(current_count+tableLength(row_ids)-1)) | |||
end | |||
current_count = current_count + tableLength(row_ids) | |||
end | end | ||