Modul:Storm categories
Modul ini dilindungi. Modul ini sangat mencolok yang digunakan oleh banyak halaman, atau sangat sering disubstitusikan. Karena vandalisme atau kesalahan akan mempengaruhi banyak halaman, dan suntingan kecil dapat memberi beban besar pada server, modul ini dilindungi dari penyuntingan. |
Modul Lua ini digunakan pada banyak halaman dan perubahannya kemungkinan dipantau. Uji cobalah di subhalaman /bak pasir atau /kasus uji modul, atau bak pasir modul Anda. Pertimbangkan untuk mendiskusikan perubahan di halaman pembicaraan sebelum mengimplementasikannya. |
In order to conform to Wikipedia:Manual of Style/Accessibility#Color guidelines, do not use storm colors in conjunction with links. This is necessary to avoid problems related to lack of contrast. |
Modul ini menggunakan Lua: |
This template is used to control a multitude of tropical cyclone-related templates: {{storm colour}}, {{storm name}}, {{storm sortkey}}, and {{storm icon}}. It acts as a centralized location for storm categories to avoid discrepancies between templates, allowing for the same ID to be used across all related templates.
Data is located in the following submodules:
- Module:Storm categories/categories for fully-detailed storm categories
- Module:Storm categories/colors for color-only IDs
- Module:Storm categories/icons for icon-only IDs
Usage
[sunting sumber]This module exports three functions for templates: p.color
, p.name
, p.sortkey
, and p.icon
. It also provides p._color
, p._name
, p._sortkey
, and p._icon
for use in other modules.
All input IDs are case-insensitive, and all non-alphanumeric characters are stripped.
Color
[sunting sumber]Provides the color of the given tropical cyclone category code. This comes in the format of their raw hexadecimal code. This function is available as a template at {{storm colour}}.
Code | Output |
---|---|
<span style="padding:4px;border:1px solid black;background-color:#{{#invoke:Storm categories|color|depression}}">depression</span>
|
depression |
Name
[sunting sumber]Provides the name of the given tropical cyclone category code. A optional basin argument can be provided as the second argument in order to slightly tweak the name of the category, if the given category definition supports it. This function is available as a template at {{storm name}}.
Code | Interpreted | Output | |
---|---|---|---|
ID | Basin | ||
{{#invoke:Storm categories|name|severe}}
|
severe | (default) | Severe tropical storm |
{{#invoke:Storm categories|name|spr - cYcL -s TorM}}
|
sprcyclstorm | (default) | Super cyclonic storm |
{{#invoke:Storm categories|name|cat5}}
|
cat5 | (default) | Category 5-equivalent tropical cyclone |
{{#invoke:Storm categories|name|cat5|ATl}}
|
cat5 | ATl | Category 5 hurricane |
{{#invoke:Storm categories|name|cat5|WPac}}
|
cat5 | WPac | Category 5-equivalent super typhoon |
Sortkey
[sunting sumber]The sortkey is a number that aids in sorting categories. Using the sortkey, it is possible to automatically sort a table of tropical cyclones given their category code. Due to the ambiguous nature of sortkeys, tables may be sorted incorrectly if values from other basins were used. For categories that span multiple basins, however, (e.g. depression
and storm
) they are given the lowest possible sortkeys in order to achieve maximum compatibility.
This sortkey is used in {{storm sortkey}} and {{Tropical cyclone season effects (cyclone)}}, a subtemplate of {{Tropical cyclone season effects}}.
The sortkey format is as follows. Note that not all values between the given ranges were used. The arrangement of these were determined by their positions in the {{Storm colour}} template.
Basin | Sortkey range |
---|---|
Global (unused) | 90000 to 99999 |
Atl/EPac/SAtl | 80000 to 89999 |
WPac | 60000 to 69999 |
Nio | 50000 to 59999 |
Aus/Fiji | 40000 to 49999 |
SWio | 30000 to 39999 |
Historical | 20000 to 29999 |
Global | 0 to 9999 |
A demonstration of a sortable table using these sortkeys can be found below. Note that it does not use categories outside of its own basin (in this case, the Atl/EPac/SAtl basin) and the global range.
Category | Sortkey | Code |
---|---|---|
cat3 | 80.030 | {{#invoke:Storm categories|sortkey|cat3}}
|
cat1 | 80.010 | {{#invoke:Storm categories|sortkey|cat1}}
|
cat5 | 80.050 | {{#invoke:Storm categories|sortkey|cat5}}
|
cat4 | 80.040 | {{#invoke:Storm categories|sortkey|cat4}}
|
depression | 90 | {{#invoke:Storm categories|sortkey|depression}}
|
cat2 | 80.020 | {{#invoke:Storm categories|sortkey|cat2}}
|
Sorting table which uses different basins | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Icon
[sunting sumber]Icons exist for some Storm categories for presentation purposes. This function is available as a template at {{storm icon}}. p.icon
will return wikitext of an image or formatted text.
Full list of available values
[sunting sumber]The following table is generated by invoking the demo
function of this module. Some IDs are only available as colors or icons because they existed as parameters on old non-module template implementations and cannot be feasibly aliased to a specific tropical cyclone category.
It will show any color errors, including colors which aren't compliant with the minimal Web Content Accessibility Guidelines 2.0 AA color standards (see MOS:COLOR for more information).
Legend
Icon | ID | Name | Color | Sortkey | |||
---|---|---|---|---|---|---|---|
Basin | Name | Basin | Sortkey | ||||
aus1 | Category 1 tropical cyclone | #00faf4 | Aus/Fiji | 40006 | |||
aus2 | Category 2 tropical cyclone | #B4FDA8 | Aus/Fiji | 40008 | |||
aus3 | Category 3 severe tropical cyclone | #FFD821 | Aus/Fiji | 40010 | |||
aus4 | Category 4 severe tropical cyclone | #FF6060[W 1] | Aus/Fiji | 40013 | |||
aus5 | Category 5 severe tropical cyclone | #C464D9[W 1] | Aus/Fiji | 40015 | |||
TC | beaufort0 | Calm (Force 0) | #FFFFFF | Global | 1500 | ||
TC | beaufort1 | Light Air (Force 1) | #757575[W 1][W 2] | Global | 1510 | ||
TC | beaufort10 | Storm (Force 10) | #AAFD9C | Global | 1600 | ||
TC | beaufort11 | Violent Storm (Force 11) | #D6FFA4 | Global | 1610 | ||
TC | beaufort12 | Hurricane-force (Force 12) | #FFFCD1 | Global | 1620 | ||
TC | beaufort2 | Light Breeze (Force 2) | #909090[W 1] | Global | 1520 | ||
TC | beaufort3 | Gentle Breeze (Force 3) | #B7B7B7[W 1] | Global | 1530 | ||
TC | beaufort4 | Moderate Breeze (Force 4) | #D2D2D2 | Global | 1540 | ||
TC | beaufort5 | Fresh Breeze (Force 5) | #F1F1F1 | Global | 1550 | ||
TC | beaufort6 | Strong Breeze (Force 6) | #007FCE[W 1][W 2] | Global | 1560 | ||
TC | beaufort7 | Near Gale (Force 7) | #46A1FF[W 1] | Global | 1570 | ||
TC | beaufort8 | Gale (Force 8) | #5EDBF8 | Global | 1580 | ||
TC | beaufort9 | Strong Gale (Force 9) | #3BFDFD | Global | 1590 | ||
cat1 | atl | Category 1 hurricane | #fff795 | Atl/EPac/SAtl | 80010 | ||
default | Category 1-equivalent tropical cyclone | ||||||
epac | Category 1 hurricane | ||||||
satl | Category 1 hurricane | ||||||
wpac | Category 1-equivalent typhoon | ||||||
cat2 | atl | Category 2 hurricane | #ffd821 | Atl/EPac/SAtl | 80020 | ||
default | Category 2-equivalent tropical cyclone | ||||||
epac | Category 2 hurricane | ||||||
satl | Category 2 hurricane | ||||||
wpac | Category 2-equivalent typhoon | ||||||
cat3 | atl | Category 3 hurricane | #ff8f20[W 1] | Atl/EPac/SAtl | 80030 | ||
default | Category 3-equivalent tropical cyclone | ||||||
epac | Category 3 hurricane | ||||||
satl | Category 3 hurricane | ||||||
wpac | Category 3-equivalent typhoon | ||||||
cat4 | atl | Category 4 hurricane | #ff6060[W 1] | Atl/EPac/SAtl | 80040 | ||
default | Category 4-equivalent tropical cyclone | ||||||
epac | Category 4 hurricane | ||||||
satl | Category 4 hurricane | ||||||
wpac | Category 4-equivalent typhoon | ||||||
cat5 | atl | Category 5 hurricane | #c464d9[W 1] | Atl/EPac/SAtl | 80050 | ||
default | Category 5-equivalent tropical cyclone | ||||||
epac | Category 5 hurricane | ||||||
satl | Category 5 hurricane | ||||||
wpac | Category 5-equivalent super typhoon | ||||||
cs | Cyclonic storm | #00faf4 | NIO | 50006 | |||
cyclstorm | Cyclonic storm | #00faf4 | NIO | 50006 | |||
d | Tropical depression | #80ccff[1] | Global | 90 | |||
dd | Deep depression | #5ebaff[W 1] | NIO | 50002 | |||
deepdepression | Deep depression | #5ebaff[W 1] | NIO | 50002 | |||
depression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
di | Tropical disturbance | #72a9cd[W 1] | Global | 80 | |||
disturbance | Tropical disturbance | #72a9cd[W 1] | Global | 80 | |||
ef0 | EF0 tornado | #00faf4 | Global | 1000 | |||
ef1 | EF1 tornado | #FFF795 | Global | 1010 | |||
ef2 | EF2 tornado | #FFD821 | Global | 1020 | |||
ef3 | EF3 tornado | #FF8F20[W 1] | Global | 1030 | |||
ef4 | EF4 tornado | #ff6060[W 1] | Global | 1040 | |||
ef5 | EF5 tornado | #C464D9[W 1] | Global | 1050 | |||
efu | EFU tornado | #cccccc | Global | 1001 | |||
escs | Extremely severe cyclonic storm | #ff6060[W 1] | NIO | 50015 | |||
esvrcyclstorm | Extremely severe cyclonic storm | #ff6060[W 1] | NIO | 50015 | |||
et | Extratropical cyclone | #cccccc | Global | 50 | |||
ex | Extratropical cyclone | #cccccc | Global | 50 | |||
extratropical | Extratropical cyclone | #cccccc | Global | 50 | |||
TC | f0 | Calm (Force 0) | #FFFFFF | Global | 1500 | ||
TC | f1 | Light Air (Force 1) | #757575[W 1][W 2] | Global | 1510 | ||
TC | f10 | Storm (Force 10) | #AAFD9C | Global | 1600 | ||
TC | f11 | Violent Storm (Force 11) | #D6FFA4 | Global | 1610 | ||
TC | f12 | Hurricane-force (Force 12) | #FFFCD1 | Global | 1620 | ||
TC | f2 | Light Breeze (Force 2) | #909090[W 1] | Global | 1520 | ||
TC | f3 | Gentle Breeze (Force 3) | #B7B7B7[W 1] | Global | 1530 | ||
TC | f4 | Moderate Breeze (Force 4) | #D2D2D2 | Global | 1540 | ||
TC | f5 | Fresh Breeze (Force 5) | #F1F1F1 | Global | 1550 | ||
TC | f6 | Strong Breeze (Force 6) | #007FCE[W 1][W 2] | Global | 1560 | ||
TC | f7 | Near Gale (Force 7) | #46A1FF[W 1] | Global | 1570 | ||
TC | f8 | Gale (Force 8) | #5EDBF8 | Global | 1580 | ||
TC | f9 | Strong Gale (Force 9) | #3BFDFD | Global | 1590 | ||
fiji1 | Category 1 tropical cyclone | #00faf4 | Aus/Fiji | 40006 | |||
fiji2 | Category 2 tropical cyclone | #B4FDA8 | Aus/Fiji | 40008 | |||
fiji3 | Category 3 severe tropical cyclone | #FFD821 | Aus/Fiji | 40010 | |||
fiji4 | Category 4 severe tropical cyclone | #FF6060[W 1] | Aus/Fiji | 40013 | |||
fiji5 | Category 5 severe tropical cyclone | #C464D9[W 1] | Aus/Fiji | 40015 | |||
intense | Intense tropical cyclone | #FF6060[W 1] | SWIO | 30008 | |||
itc | Intense tropical cyclone | #FF6060[W 1] | SWIO | 30008 | |||
land | Land depression | #72a9cd[W 1] | NIO | 50000 | |||
landdepression | Land depression | #72a9cd[W 1] | NIO | 50000 | |||
ld | Land depression | #72a9cd[W 1] | NIO | 50000 | |||
low | Tropical low | #5ebaff[W 1] | Aus/Fiji | 40002 | |||
md | Monsoon depression | #5ebaff[W 1] | Global | 30 | |||
TC | moddepression | Moderate tropical depression | #5ebaff[W 1] | Global | 95 | ||
monsoondepression | Monsoon depression | #5ebaff[W 1] | Global | 30 | |||
mstorm | Moderate tropical storm | #00faf4 | SWIO | 30004 | |||
mts | Moderate tropical storm | #00faf4 | SWIO | 30004 | |||
mtstorm | Moderate tropical storm | #00faf4 | Global | 105 | |||
niocyclone | Cyclonic storm | #00faf4 | NIO | 50006 | |||
niodepression | Depression | #72a9cd[W 1] | NIO | 50001 | |||
nioland | Land depression | #72a9cd[W 1] | NIO | 50000 | |||
nwpdepression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
nwpsevere | Severe tropical storm | #b4fda8 | Global | 120 | |||
nwpstorm | Tropical storm | #00faf4 | Global | 100 | |||
od | Overland depression | #5ebaff[W 1] | Global | 60 | |||
overland | Overland depression | #5ebaff[W 1] | Global | 60 | |||
overlanddepression | Overland depression | #5ebaff[W 1] | Global | 60 | |||
post | Post-tropical depression | #cccccc | Global | 70 | |||
posttropical | Post-tropical depression | #cccccc | Global | 70 | |||
potential | Potential tropical cyclone | #72a9cd[W 1] | Global | 25 | |||
potentialtropicalcyclone | Potential tropical cyclone | #72a9cd[W 1] | Global | 25 | |||
pt | Potential tropical cyclone | #72a9cd[W 1] | Global | 25 | |||
remnant | Post-tropical depression | #cccccc | Global | 70 | |||
remnantlow | Post-tropical depression | #cccccc | Global | 70 | |||
rl | Post-tropical depression | #cccccc | Global | 70 | |||
rsi0 | Category 0 "Nuisance" | #cccccc | Atl/EPac/SAtl | 80100 | |||
rsi1 | Category 1 "Notable" | #FFF795 | Atl/EPac/SAtl | 80110 | |||
rsi2 | Category 2 "Minor" | #FFD821 | Atl/EPac/SAtl | 80120 | |||
rsi3 | Category 3 "Major" | #FF8F20[W 1] | Atl/EPac/SAtl | 80130 | |||
rsi4 | Category 4 "Crippling" | #FF6060[W 1] | Atl/EPac/SAtl | 80140 | |||
rsi5 | Category 5 "Extreme" | #C464D9[W 1] | Atl/EPac/SAtl | 80150 | |||
rsicrippling | Category 4 "Crippling" | #FF6060[W 1] | Atl/EPac/SAtl | 80140 | |||
rsiextreme | Category 5 "Extreme" | #C464D9[W 1] | Atl/EPac/SAtl | 80150 | |||
rsimajor | Category 3 "Major" | #FF8F20[W 1] | Atl/EPac/SAtl | 80130 | |||
rsiminor | Category 2 "Minor" | #FFD821 | Atl/EPac/SAtl | 80120 | |||
rsinotable | Category 1 "Notable" | #FFF795 | Atl/EPac/SAtl | 80110 | |||
rsinuisance | Category 0 "Nuisance" | #cccccc | Atl/EPac/SAtl | 80100 | |||
scs | Severe cyclonic storm | #b4fda8 | NIO | 50008 | |||
sd | Subtropical depression | #5ebaff[W 1] | Global | 62 | |||
severe | Severe tropical storm | #b4fda8 | Global | 120 | |||
TC | severedep | Severe tropical depression | #5ebaff[W 1] | Global | 120 | ||
severets | Severe tropical storm | #b4fda8 | Global | 120 | |||
shdepression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
TC | shem1 | Tropical cyclone | #00faf4 | Historical | 20008 | ||
TC | shem2 | Tropical cyclone | #ccffff | Historical | 20008 | ||
TC | shem3 | Tropical cyclone | #FFD821 | SWIO | 30006 | ||
TC | shem4 | Tropical cyclone | #ffc140 | Historical | 20008 | ||
TC | shem5 | Severe tropical cyclone | #ff6060[W 1] | Historical | 20010 | ||
shemdepression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
TC | shemsvrtc | Severe tropical cyclone | #ffe775 | Historical | 20020 | ||
TC | shemtc | Tropical cyclone | #FFD821 | SWIO | 30006 | ||
spdepression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
sprcyclstorm | Super cyclonic storm | #c464d9[W 1] | NIO | 50020 | |||
ss | Subtropical storm | #00faf4 | Global | 65 | |||
storm | Tropical storm | #00faf4 | Global | 100 | |||
strong | Severe tropical storm | #b4fda8 | Global | 120 | |||
sts | Severe tropical storm | #b4fda8 | Global | 120 | |||
TC | sty | Category 4 super typhoon | #c464d9[W 1] | Atl/EPac/SAtl | 80045 | ||
TC | styphoon | Supertyphoon | #C464D9[W 1] | WPAC | 60050 | ||
sub | Moderate tropical storm | #00faf4 | SWIO | 30004 | |||
subdepression | Subtropical depression | #5ebaff[W 1] | Global | 62 | |||
subdisturbance | Subtropical disturbance | #72a9cd[W 1] | Global | 55 | |||
TC | sublow | Subtropical low | #5ebaff[W 1] | Aus/Fiji | 40000 | ||
subtropical | Subtropical storm | #00faf4 | Global | 65 | |||
TC | subtropicalcyclone | Subtropical cyclone | #00faf4 | Global | 70 | ||
sucs | Super cyclonic storm | #c464d9[W 1] | NIO | 50020 | |||
TC | supertyphoon | Category 4 super typhoon | #c464d9[W 1] | Atl/EPac/SAtl | 80045 | ||
svrcyclstorm | Severe cyclonic storm | #b4fda8 | NIO | 50008 | |||
TC | svtyphoon | Severe typhoon | #FF6060[W 1] | WPAC | 60015 | ||
swiodepression | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
swiodisturbance | Tropical disturbance | #72a9cd[W 1] | Global | 80 | |||
[2] | swiosts | Severe tropical storm | #b4fda8 | Global | 120 | ||
[3] | swiotc | Tropical cyclone | #FFD821 | SWIO | 30006 | ||
swsubdep | Subtropical depression | #5ebaff[W 1] | Global | 62 | |||
[3] | tc | Tropical cyclone | #FFD821 | SWIO | 30006 | ||
td | Tropical depression | #5ebaff[W 1] | Global | 90 | |||
tdist | Tropical disturbance | #72a9cd[W 1] | Global | 80 | |||
tl | Tropical low | #5ebaff[W 1] | Aus/Fiji | 40002 | |||
TC | tropicalcyclone | Tropical cyclone | #FFD821 | SWIO | 30006 | ||
ts | Tropical storm | #00faf4 | Global | 100 | |||
ty | Typhoon | #FFD821 | WPAC | 60010 | |||
typhoon | Typhoon | #FFD821 | WPAC | 60010 | |||
? | unknown | Unknown strength tropical cyclone | #c0c0c0 | Global | 0 | ||
vintense | Very intense tropical cyclone | #C464D9[W 1] | SWIO | 30010 | |||
vitc | Very intense tropical cyclone | #C464D9[W 1] | SWIO | 30010 | |||
TC | vity | Violent typhoon | #C464D9[W 1] | WPAC | 60030 | ||
TC | vityphoon | Violent typhoon | #C464D9[W 1] | WPAC | 60030 | ||
vscs | Very severe cyclonic storm | #ffd821 | NIO | 50010 | |||
TC | vsty | Very strong typhoon | #FF6060[W 1] | WPAC | 60020 | ||
TC | vstyphoon | Very strong typhoon | #FF6060[W 1] | WPAC | 60020 | ||
vsvrcyclstorm | Very severe cyclonic storm | #ffd821 | NIO | 50010 | |||
wssi0 | No impacts | #cccccc | Atl/EPac/SAtl | 80200 | |||
wssi1 | Limited impacts | #80ccff | Atl/EPac/SAtl | 80210 | |||
wssi2 | Minor impacts | #ffc140 | Atl/EPac/SAtl | 80220 | |||
wssi3 | Moderate impacts | #ff8f20[W 1] | Atl/EPac/SAtl | 80230 | |||
wssi4 | Major impacts | #ff6060[W 1] | Atl/EPac/SAtl | 80240 | |||
wssi5 | Extreme impacts | #cf75ff[W 1] | Atl/EPac/SAtl | 80250 | |||
wssiextreme | Extreme impacts | #cf75ff[W 1] | Atl/EPac/SAtl | 80250 | |||
wssilimited | Limited impacts | #80ccff | Atl/EPac/SAtl | 80210 | |||
wssimajor | Major impacts | #ff6060[W 1] | Atl/EPac/SAtl | 80240 | |||
wssiminor | Minor impacts | #ffc140 | Atl/EPac/SAtl | 80220 | |||
wssimoderate | Moderate impacts | #ff8f20[W 1] | Atl/EPac/SAtl | 80230 | |||
wssinone | No impacts | #cccccc | Atl/EPac/SAtl | 80200 | |||
zodw | Zone of disturbed weather | #72A9CD[W 1] | SWIO | 30000 | |||
1 | not available | #fff795 | not available | ||||
2 | not available | #ffd821 | not available | ||||
3 | not available | #ff8f20[W 1] | not available | ||||
4 | not available | #ff6060[W 1] | not available | ||||
5 | not available | #c464d9[W 1] | not available | ||||
a1 | not available | #00faf4 | not available | ||||
a2 | not available | #B4FDA8 | not available | ||||
a3 | not available | #FFD821 | not available | ||||
a4 | not available | #FF6060[W 1] | not available | ||||
a5 | not available | #C464D9[W 1] | not available | ||||
et2 | not available | ||||||
ex2 | not available | ||||||
extratropical2 | not available | ||||||
stss | not available |
Warnings
This table contains warnings than should be addressed. Please note that some warnings cannot be fully addressed without changes that would require consensus.
- ^ a b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm This color has contrast issues with links (not WCAG 2.0 AA-compatible). It should not be used in conjunction with a link.
- ^ a b c d e This color has contrast issues with visited links (not WCAG 2.0 AA-compatible with #0b0080). It should not be used in conjunction with a visited link.
local categoryData = require("Modul:Storm categories/categories")
local colors = require("Modul:Storm categories/colors").colors
local icons = require("Modul:Storm categories/icons").icons
local cats = categoryData.cats
local defaultCategory = categoryData.defaultCategory
local p = {}
function p.color(frame)
return p._color(frame.args[1] or frame:getParent().args[1], false)
end
function p.name(frame)
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
string.gsub(string.lower(colorCode), "[^%w]", "")
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
string.gsub(string.lower(category), "[^%w]", "")
or defaultCategory
] or cats[defaultCategory]).name
return type(name_def) == "table" and
(
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[
(category ~= nil and string.len(category) ~= 0) and
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
string.gsub(string.lower(iconCode), "[^%w]", "")
or defaultCategory
return icons[icon] or (cats[icon] ~= nil and (
cats[icon].icon or cats["tropicalcyclone"].icon
) or (nullIfMissing and nil or cats[defaultCategory].icon))
end
function p.demo(frame)
return require("Module:Storm categories/demo").demo(frame)
end
return p