Module:Navbar: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
fractional-octave and lumatone functions (should be) no longer needed; numlinks+navbox modules/templates handle everything now
Line 20: Line 20:
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
text, p_name, links[1], s, p_talk_name, links[2], s, p_edit_name, links[3])
.. "</span>"
.. "</span>"
end
-- Wrapper function for [[Template:Navbar]]
function p.navbar(frame)
local name = frame.args["name"]
local namespace = frame.args["namespace"]
local mode = frame.args["mode"]
local text = frame.args["text"]
local debugg = frame.args["debug"]
local result = p._navbar(name, mode, text, namespace)
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
-- Navbox for lumatone mappings
function p.lumatone_map(frame)
local debugg = yesno(frame.args["debug"])
local x = tonumber(frame.args["edo"]:match("(%d+)"))
local thresh = 5
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\n"
.. "| name = Navbox Lumatone\n"
.. "| Title = [[Lumatone|Lumatone mappings]]\n"
.. "| Data 1 = {{centre|"
if x >= thresh + 4 then
result = result .. "'''&larr;''' "
end
if x >= thresh + 3 then
result = result .. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idxn3, idxn3)
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; ", x)
.. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idx1, idx1)
.. string.format("[[Lumatone mapping for %sedo|%sedo]] &bull; ", idx2, idx2)
.. string.format("[[Lumatone mapping for %sedo|%sedo]] '''&rarr;'''}}\n", idx3, idx3)
.. "}}"
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
-- Navbox for fractional-octave temperaments
function p.frac_octave(frame)
local arpn = frame:preprocess("{{ARTICLEROOTPAGENAME}}")
local debugg = yesno(frame.args["debug"])
local a = arpn:match("(%d+)%a+[%s%-]*")
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\n"
.. "| name = Navbox fractional-octave\n"
.. "| Title = [[Fractional-octave temperaments]]\n"
.. "| 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
if x >= thresh + 2 then
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn3, idxn3)
end
if x >= thresh + 1 then
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn2, idxn2)
end
if x >= thresh then
result = result .. string.format("[[%s-octave temperaments|%s]] &bull; ", idxn1, idxn1)
end
result = result
.. string.format("'''%s-octave''' &bull; ", ordinal(x))
.. string.format("[[%s-octave temperaments|%s]] &bull; ", idx1, idx1)
.. string.format("[[%s-octave temperaments|%s]] &bull; ", idx2, idx2)
.. string.format("[[%s-octave temperaments|%s]] &bull; ", idx3, idx3)
.. string.format("[[%s-octave temperaments|%s]] '''&rarr;'''}}\n", idx4, idx4)
.. "}}"
-- Debugger option
if debugg == true then
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>"
end
return frame:preprocess(result)
end
end


return p
return p