Module:Weather box/row/sandbox: Difference between revisions

Content deleted Content added
style cleanups; no substantive change
work with refactored Module:Weather box
Line 1:
local p = {}
local math_mod = require('Module:Math')
local wbc = require('Module:Weather box/colors')
 
local traceText
Line 150 ⟶ 148:
end
 
local function getInputs(frameargs, group_name, suffix, include_space)
local month_names = { 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', 'year' }
Line 158 ⟶ 156:
for i, mon in ipairs(month_names) do
if include_space then
str = frame.args[ mon .. ' ' .. group_name ] or ''
else
str = frame.args[ mon .. group_name ] or ''
end
values[i] = Value.new(str)
Line 169 ⟶ 167:
for var, suf in ipairs(suffix) do
if include_space then
str = frame.args[ mon .. ' ' .. group_name .. ' ' .. suf ]
else
str = frame.args[ mon .. group_name .. ' ' .. suf ]
end
if str ~= nil and str ~= '' then
Line 300 ⟶ 298:
end
 
local function p.buildRow_buildRow(framedefinition, args, options)
local modewbc = require(frame'Module:Weather box/colors' .args.mode (options.sandbox or 'basic'):lower()
local mode = (definition.mode or 'basic'):lower()
local group_name = frame.argsdefinition.group_name
local first_values, second_values
local color_values
local color_scheme = frame.argsdefinition.color_scheme or 't'
local scale_factor = math_mod._cleanNumber( frame.argsdefinition.scale_factor ) or 1
local date_mode = checkFlag( frame.argsdefinition.date_mode, false )
local label = frame.argsdefinition.label or ''
local annual_mode = (frame.argsdefinition.annual_mode or 'avg'):lower()
local include_space = checkFlag( frame.argsdefinition.include_space, true )
local second_line = checkFlag( frame.argsdefinition.second_line, false )
local prefer_cm = checkFlag( frame.argsdefinition.prefer_cm, false )
local imperial_first = checkFlag( args['imperial first'] )
local pframe = frame:getParent()
local imperial_firstmetric_first = checkFlag( frame.args['imperial first'] or pframe.args['imperialmetric first'] )
local metric_firstwantSingleLine = checkFlag( frameoptions.args['metric first']wantSingleLine or pframe.checkFlag( args['metricsingle firstline'] )
local trace = pframe.args.trace
local single_line = checkFlag( frame.args['single line'] or pframe.args['single line'] )
local trace = pframe.args.trace
if trace and trace ~= '' then
traceText = trace
Line 325 ⟶ 323:
end
if mode == 'basic' then
first_values = getInputs( pframeargs, group_name, nil, include_space )
second_values = nil
elseif mode == 'temperature' then
first_values = getInputs( pframeargs, group_name, {'C'}, include_space )
second_values = getInputs( pframeargs, group_name, {'F'}, include_space )
reconcileTemperature( first_values, second_values )
elseif mode == "precipitation" then
first_values = getInputs( pframeargs, group_name, {'cm', 'mm'}, include_space )
second_values = getInputs( pframeargs, group_name, {'inch'}, include_space )
reconcilePrecipitation( first_values, second_values, prefer_cm )
else
error('Requested mode not recognized')
Line 379 ⟶ 377:
first_values, second_values = second_values, first_values
end
if not single_linewantSingleLine then
if second_line and second_values ~= nil then
first_values = second_values
Line 388 ⟶ 386:
end
 
local function buildRow(frame)
return p
return _buildRow(frame.args, frame:getParent().args) -- row definition, template parameters
end
 
return p{
buildRow = buildRow,
_buildRow = _buildRow,
}