Module:Infobox interval region: Difference between revisions

No edit summary
m Cleanup and style
 
(30 intermediate revisions by one other user not shown)
Line 4: Line 4:
local u = require("Module:Utils")
local u = require("Module:Utils")
local infobox = require("Module:Infobox")
local infobox = require("Module:Infobox")
local rat = require("Module:Rational")
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")
function p.concatenate_tables(t1, t2)
for i=1, #t2 do
t1[#t1 + 1] = t2[i]
end
end


function p.infobox_IR(frame)
function p.infobox_IR(frame)
Line 13: Line 20:
local centslowerStrict = frame.args["centsLower"]
local centslowerStrict = frame.args["centsLower"]
local centsupperStrict = frame.args["centsUpper"]
local centsupperStrict = frame.args["centsUpper"]
local subregions = frame.args["subregions"]
local superregions = frame.args["superregions"]
local prevRegion = frame.args["prevRegion"]
local nextRegion = frame.args["nextRegion"]
local equave = frame.args["equave"]
local equave = frame.args["equave"]
local ji3 = frame.args["ji3"]
local ji3 = frame.args["ji3"]
Line 19: Line 30:
local ji11 = frame.args["ji11"]
local ji11 = frame.args["ji11"]
local ji13 = frame.args["ji13"]
local ji13 = frame.args["ji13"]
local jiPre = frame.args["ji"]
local ji = {}
for note in jiPre:gmatch("%d*/%d*") do
table.insert(ji, rat.parse(note))
end
local jihigh = frame.args["jiHigh"]
local moses = frame.args["MOSes"]
local moses = frame.args["MOSes"]
local data = {}
local data = {}
table.insert(data, {
table.insert(data, {
"Name",
"Name",
name
name
})
})
table.insert(data, {
"Equave",
"[[" .. equave .. "]]"
})
if centslower == nil or centslower == "" then
if centslower == nil or centslower == "" then
Line 43: Line 54:
table.insert(data, {
table.insert(data, {
"Lower bound",
"Lower bound",
centslower .. "¢ - " .. centslowerStrict .. "¢"
centslower .. "¢ " .. centslowerStrict .. "¢"
})
})
end
end
Line 55: Line 66:
table.insert(data, {
table.insert(data, {
"Upper bound",
"Upper bound",
centsupperStrict .. "¢ - " .. centsupper .. "¢"
centsupperStrict .. "¢ " .. centsupper .. "¢"
})
})
end
end
if moses ~= nil and moses ~= "" then
table.insert(data, {
"Generated [[MOS]]es",
moses
})
end
table.insert(data, {
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "Example [[JI]] intervals")
})
local jidata = ""
local q = 0
for k, v in pairs(ji) do
if q == 1 then
jidata = jidata .. "<br>"
end
jidata = jidata .. "[[" .. rat.as_ratio(v) .. "]] (" .. math.floor(rat.cents(v)*10 + 0.5)/10 .. "¢)"
q = 1
end
table.insert(data, {
"Intervals",
jidata
})
table.insert(data, {
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "Related regions")
})
if complement ~= nil and complement ~= "" then
table.insert(data, {
"[[Complement]]",
complement
})
end
if subregions ~= nil and subregions ~= "" then
table.insert(data, {
"Subregions",
subregions
})
end
if superregions ~= nil and superregions ~= "" then
table.insert(data, {
"Superregion(s)",
superregions
})
end
local args = {
["Adjacent Links"] = { "←&nbsp;"..(prevRegion or ""), (nextRegion or "").."&nbsp;→" },
["Title"] = "Interval&nbsp;region",
["Rows"] = data,
}


local result = infobox.build(
local result = infobox._infobox(args)
"Interval region",
data
)
return frame:preprocess(debugg == true and "<pre>" .. result .. "</pre>" or result)
return frame:preprocess(debugg == true and "<pre>" .. result .. "</pre>" or result)