Module:Numlinks 2-num: Difference between revisions
mNo edit summary |
try to add edge case detection |
||
| Line 65: | Line 65: | ||
-- Create a grid of links | -- Create a grid of links | ||
local num_rows = 1 + num_links_2 | local num_rows = 1 + num_links_2 + math.max(num_links_2, curr_num_2 - num_links_2) | ||
local num_cols = 1 + num_links_1 | local num_cols = 1 + num_links_1 + math.max(num_links_1, curr_num_1 - num_links_1) | ||
local row_offset = 1 + num_links_2 | local row_offset = 1 + num_links_2 -- How far from upper edge to current-page's row | ||
local col_offset = 1 + num_links_1 | local col_offset = 1 + num_links_1 -- How far from left edge to current-page's column | ||
local links = {} | local links = {} | ||
for j = 1, num_rows do | for j = 1, num_rows do | ||
| Line 89: | Line 89: | ||
-- Produce table of links | -- Produce table of links | ||
table.insert(lines, '{| style="width: 100%;"') | table.insert(lines, '{| style="width: 100%;"') | ||
local middle_cell_width = 100 / ( | local middle_cell_width = 100 / (num_cols + 1) | ||
for j = 1, num_rows do | for j = 1, num_rows do | ||
-- New row | -- New row | ||