Content deleted Content added
copy from Module:Weather box; will later provide alternative for: "require('Module:Weather box/row/sandbox').buildRow" |
refactor so makeFrame kludge is not required; define wantSingleLine in one place for consistency and to change it so default is true; require sandbox module if called from sandbox |
||
Line 20:
end
local function makeLabel(args, options, is_first, base, what)
local first
if isAny(args, ' ' .. what .. ' cm') then
Line 39:
end
if is_first then
if
first = first .. ' (' .. second .. ')'
end
Line 65:
end
local function
-- Originally needed "|single line=yes" or "|single line=<any non-blank>" for
-- single line output (default was separate lines for metric/imperial units).
-- That was changed in June 2020 so single line is the default and
-- now need "|single line=no" or "|single line=n" for separate lines.
parm = (parm or ''):lower()
return not (parm == 'no' or parm == 'n')
end▼
local function getDefinitions(frame, args, options)
-- Return a list of tables or strings that define each row.
local navbar = require('Module:Navbar')._navbar
Line 76 ⟶ 85:
local function _ifany(suffix)
return isAny(args, suffix)
end
local function _ifSingle(a, b)
return options.wantSingleLine and a or b or ''
end
return {
Line 114 ⟶ 126:
{---------- FIRST LINE MAXIMUM HUMIDEX ----------
WANTROW = _ifany(' maximum humidex') and (_ifset('metric first') or
mode = 'basic',
group_name = 'maximum humidex',
Line 128 ⟶ 140:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Record high °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'max',
},
Line 137 ⟶ 149:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Mean maximum °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'max',
},
Line 146 ⟶ 158:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Average high °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'avg',
},
Line 155 ⟶ 167:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Daily mean °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'avg',
},
Line 164 ⟶ 176:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Average low °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'avg',
},
Line 173 ⟶ 185:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Mean minimum °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'min',
},
Line 182 ⟶ 194:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Record low °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'min',
},
{---------- FIRST LINE MINIMUM WIND CHILL ----------
WANTROW = _ifany(' chill') and (_ifset('metric first') or
mode = 'basic',
group_name = 'chill',
Line 202 ⟶ 214:
scale_factor = '1',
prefer_cm = precision(_ifset('Jan precipitation inch', '0')) < 1,
label = makeLabel(args, options, true, 'Average [[precipitation]]', 'precipitation'),
annual_mode = 'sum',
},
Line 213 ⟶ 225:
scale_factor = '1',
prefer_cm = precision(_ifset('Jan rain inch', '0')) < 1,
label = makeLabel(args, options, true, 'Average rainfall', 'rain'),
annual_mode = 'sum',
},
Line 224 ⟶ 236:
date_mode = true,
scale_factor = '1',
label = makeLabel(args, options, true, 'Average snowfall', 'snow'),
annual_mode = 'sum',
},
{---------- SECOND LINE MAXIMUM HUMIDEX ----------
WANTROW = not
mode = 'basic',
group_name = 'maximum humidex',
Line 238 ⟶ 250:
},
{---------- SECOND LINE RECORD HIGH TEMPERATURES ----------
WANTROW = not
mode = 'temperature',
group_name = 'record high',
Line 248 ⟶ 260:
},
{---------- SECOND LINE AVERAGE HIGH TEMPERATURES ----------
WANTROW = not
mode = 'temperature',
group_name = 'high',
Line 258 ⟶ 270:
},
{---------- SECOND LINE DAILY MEAN TEMPERATURES ----------
WANTROW = not
mode = 'temperature',
group_name = 'mean',
Line 269 ⟶ 281:
},
{---------- SECOND LINE AVERAGE LOW TEMPERATURES ----------
WANTROW = not
mode = 'temperature',
group_name = 'low',
Line 280 ⟶ 292:
},
{---------- SECOND LINE RECORD LOW TEMPERATURES ----------
WANTROW = not
mode = 'temperature',
group_name = 'record low',
Line 291 ⟶ 303:
},
{---------- SECOND LINE MINIMUM WIND CHILL ----------
WANTROW = not
mode = 'basic',
group_name = 'chill',
Line 300 ⟶ 312:
},
{---------- SECOND LINE TOTAL PRECIPITATION ----------
WANTROW = not
mode = 'precipitation',
group_name = 'precipitation',
Line 308 ⟶ 320:
scale_factor = '1',
prefer_cm = precision(_ifset('Jan precipitation inch', '0')) < 1,
label = makeLabel(args, options, false, 'Average [[precipitation]]', 'precipitation'),
annual_mode = 'sum',
},
{---------- SECOND LINE RAINFALL ----------
WANTROW = not
mode = 'precipitation',
group_name = 'rain',
Line 320 ⟶ 332:
scale_factor = '1',
prefer_cm = precision(_ifset('Jan rain inch', '0')) < 1,
label = makeLabel(args, options, false, 'Average rainfall', 'rain'),
annual_mode = 'sum',
},
{---------- SECOND LINE SNOWFALL ----------
WANTROW = not
mode = 'precipitation',
group_name = 'snow',
Line 332 ⟶ 344:
date_mode = true,
scale_factor = '1',
label = makeLabel(args, options, false, 'Average snowfall', 'snow'),
annual_mode = 'sum',
},
Line 393 ⟶ 405:
color_scheme = _ifset('temperature colour', 't'),
scale_factor = '1',
label = 'Average [[dew point]] °' .. _if('metric first', 'C', 'F') ..
annual_mode = 'avg',
},
{---------- SECOND LINE AVERAGE DEW POINT----------
WANTROW = not
mode = 'temperature',
group_name = 'dew point',
Line 458 ⟶ 470:
makeSources(frame, args),
}
▲end
}▼
end
local function main(frame)
local sandbox = frame:getTitle():find('sandbox', 1, true) and '/sandbox' or ''
local buildRow = require('Module:Weather box/row' .. sandbox).
local args = frame:getParent().args
local options = {
wantSingleLine = wantSingle(args['single line']),
sandbox = sandbox,
▲ }
local results = {}
for i,
local row
if type(
row =
elseif
row = buildRow(
else
row = ''
|