Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Humanipedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Infobox weather event/scalebar
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local getArgs = require('Module:Arguments').getArgs local cats = require('Module:Storm categories') local p = {} function p.main(frame) local args = getArgs(frame, { trim = true }) return p._main(frame, args) end function p._main(frame, args) local infoboxScale = args["scale"] local basin = args["basin"] function getCategory(winds) templateArgs = { categoryonly = "y", winds = winds, basin = basin } return frame:expandTemplate{ title = 'Infobox weather event/' .. infoboxScale, args = templateArgs } end local steps = {} local start = getCategory(0) local last = start local lastMinimum = 0 for i = 0, 140 do local category = getCategory(i) if category ~= last then if last == start then -- first category table.insert(steps, { last, nil, i - 1 }) else table.insert(steps, { last, lastMinimum, i - 1 }) end last = category lastMinimum = i end end table.insert(steps, { last, lastMinimum, nil }) function barCell(category, minimumWinds, maximumWinds) local minKmh = minimumWinds and (1.852 * minimumWinds) or nil local minMph = minimumWinds and (1.151 * minimumWinds) or nil local maxKmh = maximumWinds and (1.852 * maximumWinds) or nil local maxMph = maximumWinds and (1.151 * maximumWinds) or nil local nameCell = mw.html.create("td") :css("text-align", "center") :css("background-color", "#" .. cats._color(category)) :wikitext("'''" .. cats._name(category, args['basin']) .. "'''<br/>") local windsCell = mw.html.create("td") :css("text-align", "center") :css("vertical-align", "top") if minimumWinds ~= nil and maximumWinds ~= nil then windsCell:wikitext( "''" .. minimumWinds .. "–" .. maximumWinds .. " kn, " .. math.floor(minKmh) .. "–" .. math.floor(maxKmh) .. " km/h, " .. math.floor(minMph) .. "–" .. math.floor(maxMph) .. " mph''" ) elseif minimumWinds == nil then windsCell:wikitext( "''<" .. maximumWinds .. " kn, <" .. math.floor(maxKmh) .. " km/h, <" .. math.floor(maxMph) .. " mph''" ) elseif maximumWinds == nil then windsCell:wikitext( "''>" .. minimumWinds .. " kn, >" .. math.floor(minKmh) .. " km/h, >" .. math.floor(minMph) .. " mph''" ) end return { nameCell, windsCell } end local nameBar = mw.html.create("tr") local windsBar = mw.html.create("tr") for i, v in ipairs(steps) do local cells = barCell(v[1], v[2], v[3]) nameBar:node(cells[1]) windsBar:node(cells[2]) end return tostring( mw.html.create("table") :addClass("wikitable") :css("width", "100%") :node(nameBar) :node(windsBar) ) end return p
Summary:
Please note that all contributions to Humanipedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Humanipedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Error
(
edit
)
Template:Module other
(
edit
)
Template:Module rating
(
edit
)
Template:Ombox
(
edit
)
Template:Pp
(
edit
)
Template:Protection padlock
(
edit
)
Template:Sandbox other
(
edit
)
Template:Template link
(
edit
)
Template:Tl
(
edit
)
Module:Error
(
edit
)
Module:File link
(
edit
)
Module:Infobox weather event/scalebar/doc
(
edit
)
Module:Message box
(
edit
)
Module:Protection banner
(
edit
)
Module:String
(
edit
)