Module:Prime limit navigation: Difference between revisions

ArrowHead294 (talk | contribs)
m Fix typo
+ odd limit navigation
Line 15: Line 15:
function p.prime_limit_navigation(frame)
function p.prime_limit_navigation(frame)
local i = table_index(PRIME_LIST, tonumber (frame.args['limit']))
local i = table_index(PRIME_LIST, tonumber (frame.args['limit']))
local entry_prev, entry_curr, entry_next, out_elem = "", "", "", ""
local entry_prev, entry_curr, entry_next = "", "", ""
if PRIME_LIST[i] then
if PRIME_LIST[i] then
Line 37: Line 37:
local result = "<div class=\"toccolours\" style=\"float: right; margin: 0px 0px 4px 4px;\">\n"
local result = "<div class=\"toccolours\" style=\"float: right; margin: 0px 0px 4px 4px;\">\n"
.. "{{centre|'''[[Prime limit]]'''}}\n"
.. "{{centre|'''[[Prime limit]]'''}}\n"
.. "<hr />\n"
.. "----\n"
.. string.format("%s%s%s\n", entry_prev, entry_curr, entry_next)
.. "</div>"
if yesno(frame.args["debug"]) == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
 
function p.odd_limit_navigation(frame)
local limit = frame.args['limit']
local entry_prev, entry_curr, entry_next = "", "", "", ""
if limit > 0 and limit % 2 == 1 then
entry_curr = string.format("[[%d-odd-limit]]", limit)
limit_prev = limit - 2
if limit_prev > 0 then
entry_prev = string.format("<span style=\"font-size: 0.8em;\">"
.. "[[%d-odd-limit|'''&larr;'''&nbsp;%d-odd-limit]]"
.. "</span>&nbsp;&nbsp;", limit_prev, limit_prev)
else
entry_prev = ""
end
limit_next = limit + 2
if limit_next > 0 then
entry_next = string.format("&nbsp;&nbsp;<span style=\"font-size: 0.8em;\">"
.. "[[%d-odd-limit|%d-odd-limit&nbsp;'''&rarr;''']]"
.. "</span>", limit_next, limit_next)
else
entry_next = ""
end
end
local result = "<div class=\"toccolours\" style=\"float: right; margin: 0px 0px 4px 4px;\">\n"
.. "{{centre|'''[[Odd limit]]'''}}\n"
.. "----\n"
.. string.format("%s%s%s\n", entry_prev, entry_curr, entry_next)
.. string.format("%s%s%s\n", entry_prev, entry_curr, entry_next)
.. "</div>"
.. "</div>"