Module:Navbar: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
Line 36: Line 36:
local thresh = 5
local thresh = 5
local out_str = "<br />{{Navbox"
local idxn1 = x - 1
local idxn2 = x - 2
local idxn3 = x - 3
local idx1 = x + 1
local idx2 = x + 2
local idx3 = x + 3
local result = "<br />{{Navbox"
.. "|name=Navbox Lumatone"
.. "|name=Navbox Lumatone"
.. "|Title=[[Lumatone|Lumatone mappings]]"
.. "|Title=[[Lumatone|Lumatone mappings]]"
.. "|Data 1={{centre|"
.. "|Data 1={{centre|"
.. ((x >= thresh + 4) and "'''&larr;''' " or "")
.. ((x >= thresh + 3) and "[[Lumatone mapping for " .. (x - 3) .. "edo|" .. (x - 3) .. "edo]] &bull; " or "")
if x >= thresh + 4 then
.. ((x >= thresh + 2) and "[[Lumatone mapping for " .. (x - 2) .. "edo|" .. (x - 2) .. "edo]] &bull; " or "")
result = result .. "'''&larr;''' "
.. ((x >= thresh + 1) and "[[Lumatone mapping for " .. (x - 1) .. "edo|" .. (x - 1) .. "edo]] &bull; " or "")
end
.. "'''Lumatone mapping for " .. x .. "edo''' &bull; "
.. "[[Lumatone mapping for " .. (x + 1) .. "edo|" .. (x + 1) .. "edo]] &bull; "
if x >= thresh + 3 then
.. "[[Lumatone mapping for " .. (x + 2) .. "edo|" .. (x + 2) .. "edo]] &bull; "
result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idxn3, idxn3)
.. "[[Lumatone mapping for " .. (x + 3) .. "edo|" .. (x + 3) .. "edo]] '''&rarr;'''}}"
end
.. "}}"
if x >= thresh + 2 then
result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idxn2, idxn2)
end
if x >= thresh + 1 then
result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idxn1, idxn1)
end
result = result .. string.format("'''Lumatone mapping for %sedo''' &bull; "
.. "[[Lumatone mapping for %sedo|%sedo]] &bull; "
.. "[[Lumatone mapping for %sedo|%sedo]] &bull; "
.. "[[Lumatone mapping for %sedo|%sedo]] '''&rarr;'''}}"
.. "}}", x, idx1, idx1, idx2, idx2, idx3, idx3)
if string.lower(arpn) ~= "template:navbox lumatone" then
if string.lower(arpn) ~= "template:navbox lumatone" then
out_str = out_str .. " [[Category:Lumatone mappings]] [[Category:" .. x .. "edo]]"
result = result .. " [[Category:Lumatone mappings]] [[Category:" .. x .. "edo]]"
end
end


return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str)
return frame:preprocess(debugg == true and "<pre>" .. result .. "</pre>" or result)
end
end


function p.frac_octave(frame)
function p.frac_octave(frame)
local root_page_name = frame:preprocess("{{FULLROOTPAGENAME}}")
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local debugg = yesno(frame.args["debug"])
local debugg = yesno(frame.args["debug"])
local a = root_page_name:match("(%d+)%a+[%s%-]*[Oo]ctave%s*[Tt]emperament[s]?")
local a = arpn:match("(%d+)%a+[%s%-]*[Oo]ctave%s*[Tt]emperament[s]?")
local x = tonumber(frame.args["f"]) or tonumber(a)
local x = tonumber(frame.args["f"]) or tonumber(a)
local thresh = 2
local idxn1 = ordinal(x - 1)
local idxn2 = ordinal(x - 2)
local idxn3 = ordinal(x - 3)
local idxn4 = ordinal(x - 4)
local idx1 = ordinal(x + 1)
local idx2 = ordinal(x + 2)
local idx3 = ordinal(x + 3)
local idx4 = ordinal(x + 4)
local result = "<br />{{Navbox"
.. "| name=Navbox fractional-octave"
.. "| Title=[[Fractional-octave temperaments]]"
.. "| Data 1={{centre|"
if x >= thresh + 4 then
result = result .. "'''&larr;''' "
end
if x >= thresh + 3 then
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn4, idxn4)
end
local out_str = "<br />{{Navbox"
if x >= thresh + 2 then
.. "|name=Navbox fractional-octave"
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn3, idxn3)
.. "|Title=[[Fractional-octave temperaments]]"
end
.. "|Data 1={{centre|"
.. ((x >= 6) and "'''&larr;''' " or "")
if x >= thresh + 1 then
.. ((x >= 5) and "[[" .. ordinal(x - 4) .. "-octave temperaments|" .. ordinal(x - 4) .. "]] &bull; " or "")
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn2, idxn2)
.. ((x >= 4) and "[[" .. ordinal(x - 3) .. "-octave temperaments|" .. ordinal(x - 3) .. "]] &bull; " or "")
end
.. ((x >= 3) and "[[" .. ordinal(x - 2) .. "-octave temperaments|" .. ordinal(x - 2) .. "]] &bull; " or "")
.. ((x >= 2) and "[[" .. ordinal(x - 1) .. "-octave temperaments|" .. ordinal(x - 1) .. "]] &bull; " or "")
if x >= thresh then
.. "'''" .. ordinal(x) .. "-octave''' &bull; "
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn1, idxn1)
.. "[[" .. ordinal(x + 1) .. "-octave temperaments|" .. ordinal(x + 1) .. "]] &bull; "
end
.. "[[" .. ordinal(x + 2) .. "-octave temperaments|" .. ordinal(x + 2) .. "]] &bull; "
.. "[[" .. ordinal(x + 3) .. "-octave temperaments|" .. ordinal(x + 3) .. "]] &bull; "
result = result .. string.format("'''%s-octave''' &bull; "
.. "[[" .. ordinal(x + 4) .. "-octave temperaments|" .. ordinal(x + 4) .. "]] '''&rarr;'''}}"
.. "[[%s-octave temperaments|%s]] &bull; "
.. "}}"
.. "[[%s-octave temperaments|%s]] &bull; "
.. "[[%s-octave temperaments|%s]] &bull; "
.. "[[%s-octave temperaments|%s]] '''&rarr;'''}}"
.. "}}", ordinal(x), idx1, idx1, idx2, idx2, idx3, idx3, idx4, idx4)


return frame:preprocess(debugg == true and "<pre>" .. out_str .. "</pre>" or out_str)
return frame:preprocess(debugg == true and "<pre>" .. result .. "</pre>" or result)
end
end


return p
return p