Module:Infobox weather event/scalebar explained
local getArgs = require('Module:Arguments').getArgslocal cats = require('Module:Storm categories')
local p =
function p.main(frame) local args = getArgs(frame,)
return p._main(frame, args)end
function p._main(frame, args) local infoboxScale = args["scale"] local basin = args["basin"] function getCategory(winds) templateArgs = return frame:expandTemplate 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,) else table.insert(steps,) end last = category lastMinimum = i end end table.insert(steps,) 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']) .. "
") 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 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