Module:Infobox interval region: Difference between revisions

No edit summary
m Cleanup and style
 
(2 intermediate revisions by one other user not shown)
Line 21: Line 21:
local centsupperStrict = frame.args["centsUpper"]
local centsupperStrict = frame.args["centsUpper"]
local subregions = frame.args["subregions"]
local subregions = frame.args["subregions"]
local superregions = frame.args["superregions"]
local prevRegion = frame.args["prevRegion"]
local prevRegion = frame.args["prevRegion"]
local nextRegion = frame.args["nextRegion"]
local nextRegion = frame.args["nextRegion"]
Line 40: Line 41:
local data = {}
local data = {}
table.insert(data, {
table.insert(data, {
"Name",
"Name",
name
name
})
})
 
if centslower == nil or centslower == "" then
if centslower == nil or centslower == "" then
Line 56: Line 54:
table.insert(data, {
table.insert(data, {
"Lower bound",
"Lower bound",
centslower .. "¢ - " .. centslowerStrict .. "¢"
centslower .. "¢ " .. centslowerStrict .. "¢"
})
})
end
end
Line 68: Line 66:
table.insert(data, {
table.insert(data, {
"Upper bound",
"Upper bound",
centsupperStrict .. "¢ - " .. centsupper .. "¢"
centsupperStrict .. "¢ " .. centsupper .. "¢"
})
})
end
end
Line 78: Line 76:
end
end
table.insert(data, {
table.insert(data, {
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "[[JI]] intervals")
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "Example [[JI]] intervals")
})
})
local jidata = ""
local jidata = ""
local q = 0
local q = 0
for k,v in pairs(ji) do
for k, v in pairs(ji) do
if q == 1 then
if q == 1 then
jidata = jidata .. "<br>"
jidata = jidata .. "<br>"
end
end
jidata = jidata .. "[[" .. rat.as_ratio(v) .. "]] (" .. math.floor(rat.cents(v)*10+0.5)/10 .. "¢)"
jidata = jidata .. "[[" .. rat.as_ratio(v) .. "]] (" .. math.floor(rat.cents(v)*10 + 0.5)/10 .. "¢)"
q = 1
q = 1
end
end
table.insert(data, {
table.insert(data, {
"Intervals",
"Intervals",
jidata
jidata
})
})
table.insert(data, {
table.insert(data, {
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "Related regions")
string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b></div>", "Related regions")
})
})
if complement ~= nil and complement ~= "" then
if complement ~= nil and complement ~= "" then
table.insert(data, {
table.insert(data, {
"[[Complement]]",
"[[Complement]]",
complement
complement
})
})
end
end
if subregions ~= nil and subregions ~= "" then
if subregions ~= nil and subregions ~= "" then
table.insert(data, {
table.insert(data, {
"Subregions",
"Subregions",
subregions
subregions
})
})
end
end
if superregions ~= nil and superregions ~= "" then
table.insert(data, {
"Superregion(s)",
superregions
})
end
local args = {
local args = {
["Adjacent Links"] = { "<&nbsp;"..(prevRegion or ""), (nextRegion or "").."&nbsp;>" },
["Adjacent Links"] = { "&nbsp;"..(prevRegion or ""), (nextRegion or "").."&nbsp;" },
["Title"] = "Interval&nbsp;region",
["Title"] = "Interval&nbsp;region",
["Rows"] = data,
["Rows"] = data,
Line 115: Line 119:


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