Module:Prime limit navigation: Difference between revisions
Jump to navigation
Jump to search
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) m Centre seems to be working now |
||
Line 17: | Line 17: | ||
if PRIME_LIST[i] then | if PRIME_LIST[i] then | ||
entry_curr = "[[" .. PRIME_LIST[i] .. "-limit]]" | entry_curr = "[[" .. PRIME_LIST[i] .. "-limit]]" | ||
if PRIME_LIST[i-1] then | if PRIME_LIST[i - 1] then | ||
entry_prev = "< | entry_prev = "<span style=\"font-size: 0.75em;\">[[" .. PRIME_LIST[i-1] .. "-limit|← " .. PRIME_LIST[i-1] .. "-limit]]</span> " | ||
else | else | ||
entry_prev = "" | entry_prev = "" | ||
end | end | ||
if PRIME_LIST[i+1] then | if PRIME_LIST[ i+ 1] then | ||
entry_next = " < | entry_next = " <span style=\"font-size: 0.75em;\">[[" .. PRIME_LIST[i+1] .. "-limit|" .. PRIME_LIST[i+1] .. "-limit →]]</span>" | ||
else | else | ||
entry_next = "" | entry_next = "" | ||
Line 31: | Line 31: | ||
out_elem = "<div class=\"toccolours\" style=\"float: right; text-align: center;\">\n" .. | out_elem = "<div class=\"toccolours\" style=\"float: right; text-align: center;\">\n" .. | ||
"<div style=\"margin: auto auto auto auto;\">'''[[Prime limit]]'''</div>\n" .. | "<div style=\"margin: auto auto auto auto;\">'''[[Prime limit]]'''</div>\n" .. | ||
" | "<hr />\n" .. | ||
entry_prev .. entry_curr .. entry_next .. "\n" .. | entry_prev .. entry_curr .. entry_next .. "\n" .. | ||
"</div>" | "</div>" |
Revision as of 15:28, 25 November 2024
Note: Do not invoke this module directly; use the corresponding template instead: Template:Prime limit navigation.
This module generates the navigation bar for prime limit pages.
local p = {}
local PRIME_LIST = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}
local function table_index (t, v)
for i, ti in ipairs (t) do
if v == ti then
return i
end
end
return nil
end
function p.prime_limit_navigation(frame)
local i = table_index(PRIME_LIST, tonumber (frame.args['limit']))
local entry_prev, entry_curr, entry_next, out_elem = "", "", "", ""
if PRIME_LIST[i] then
entry_curr = "[[" .. PRIME_LIST[i] .. "-limit]]"
if PRIME_LIST[i - 1] then
entry_prev = "<span style=\"font-size: 0.75em;\">[[" .. PRIME_LIST[i-1] .. "-limit|← " .. PRIME_LIST[i-1] .. "-limit]]</span> "
else
entry_prev = ""
end
if PRIME_LIST[ i+ 1] then
entry_next = " <span style=\"font-size: 0.75em;\">[[" .. PRIME_LIST[i+1] .. "-limit|" .. PRIME_LIST[i+1] .. "-limit →]]</span>"
else
entry_next = ""
end
end
out_elem = "<div class=\"toccolours\" style=\"float: right; text-align: center;\">\n" ..
"<div style=\"margin: auto auto auto auto;\">'''[[Prime limit]]'''</div>\n" ..
"<hr />\n" ..
entry_prev .. entry_curr .. entry_next .. "\n" ..
"</div>"
return out_elem
end
return p;