Content deleted Content added
adjust aliases |
better demo |
||
Line 459:
icons["stss"] = icons["swiosts"]
icons["tc"] = icons["swiotc"]
local customKeys = {}
for k, v in pairs(colors) do
table.insert(customKeys, k)
for k, v in pairs(icons) do
table.insert(customKeys, k)
TableTools.removeDuplicates(customKeys)
function p.color(frame)
return p._color(frame.args[1] or frame:getParent().args[1], false)
end
Line 467 ⟶ 476:
return p._name(
frame.args[1] or frame:getParent().args[1],
frame.args[2] or frame:getParent().args[2],
false
)
end
function p.sortkey(frame)
return p._sortkey(frame.args[1] or frame:getParent().args[1], false)
end
function p.icon(frame)
return p._icon(frame.args[1] or frame:getParent().args[1], false)
end
function p._color(colorCode, nullIfMissing)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
local color = (colorCode ~= nil and string.len(colorCode) ~= 0) and
Line 485 ⟶ 495:
or defaultCategory
return colors[color] or ((cats[color] or
nullIfMissing
and { color = nil }
or cats[defaultCategory]
)).color)
end
function p._name(category, basin, nullIfMissing)
local name_def = (cats[
(category ~= nil and string.len(category) ~= 0) and
Line 498 ⟶ 512:
name_def[string.lower(basin or "default")]
or name_def["default"]
or (nullIfMissing and nil or error("No default name for basin-based category name."))
)
or name_def
end
function p._sortkey(category, nullIfMissing)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
return (cats[
Line 509 ⟶ 523:
string.gsub(string.lower(category), "[^%w]", "")
or defaultCategory
] or (nullIfMissing and { sortkey = nil } or cats[defaultCategory])).sortkey
end
function p._icon(iconCode, nullIfMissing)
-- This looks confusing, but it's actually nested ternaries (for nil checks)
local icon = (iconCode ~= nil and string.len(iconCode) ~= 0) and
Line 520 ⟶ 534:
return icons[icon] or (cats[icon] ~= nil and (
cats[icon].icon or cats["tropicalcyclone"].icon
) or (nullIfMissing and nil or cats[defaultCategory].icon))
end
Line 724 ⟶ 738:
end
for name,
if cats[name] == nil then
local row = mw.html.create("tr")
local icon = p._icon(name, true)
row
:node(mw.html.create("td")
:wikitext(
icon ~= nil
and icon
))
:node(mw.html.create("td"):wikitext(name))
:node(mw.html.create("td")▼
local color = p._color(name, true)
:attr("colspan", "2")▼
-- Add more conditions eventually
▲ :wikitext("''<span style=\"color:gray\">not available</span>''"))
row
:node(mw.html.create("td")
:
:wikitext("''<span style=\"color:gray\">not available</span>''"))▼
:
:
:wikitext("#" .. color))
▲ end
▲ :node(mw.html.create("td")
▲ end
▲ :attr("colspan", "2")
:wikitext("''<span style=\"color:gray\">not available</span>''"))
else
▲ if cats[name] == nil then
row
:node(mw.html.create("td")
:
:wikitext("''<span style=\"color:gray\">not available</span>''"))
end
▲ :wikitext("''<span style=\"color:gray\">not available</span>''"))
out:node(row)
end
|