Module:Sandbox/ProcrastinatingReader/ib: Difference between revisions

Content deleted Content added
+def
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 3:
local p = {}
 
local function dataValueisempty(settlementName, parameterName, itemNames)
return s == nil or s == ''
end
 
local function dataValue(frame, settlementName, parameterName, itemName)
return frame:expandTemplate{ title = 'Data '..settlementName..' municipality', args = {
parameterName,
itemName
}}
end
 
local function getNetValue(frame, argCategory, argName)
local args = getArgs(frame)
local argType = args['arg_type'] and (args['arg_type']..'_') or ''
local paramName = argCategory..'_'..argType..argName
 
['km2'] local net = args['area_total_km2'paramName] or dataValue(frame, args['subdivision_name'], 'area_total_km2'paramName, args['name']),
 
return net
end
 
Line 27 ⟶ 41:
local args = getArgs(frame)
local argCategory = 'area'
return frame:expandTemplate{ title = 'infobox_settlement/areadisp', args = {
['km2'] = args['area_total_km2'] or dataValue(args['subdivision_name'], 'area_total_km2', args['name']),
local km2 = getNetValue(frame, argCategory, 'km2')
['ha'] = args['area_total_ha'],
local ha = getNetValue(frame, argCategory, 'ha')
['acre'] = args['area_total_acre'],
local acre = getNetValue(frame, argCategory, 'acre')
['sqmi'] = args['area_total_sq_mi'],
local sqmi = getNetValue(frame, argCategory, 'sq_mi')
['dunam'] = args['area_total_dunam'],
local dunam = getNetValue(frame, argCategory, 'dunam')
['link'] = args['dunam_link'],
['pref'] = args['unit_pref'],
if not (isempty(km2) and isempty(ha) and isempty(acre) and isempty(sqmi) and isempty(dunam)) then
['name'] = args['subdivision_name'],
return frame:expandTemplate{ title = 'infobox_settlement/areadisp', args = {
['mag'] = args['area_magnitude']
['km2'] = km2,
}}
['ha'] = ha,
['acre'] = acre,
['sqmi'] = sqmi,
['dunam'] = dunam,
['halink'] = args['area_total_hadunam_link'],
['acrepref'] = args['area_total_acreunit_pref'],
['sqminame'] = args['area_total_sq_misubdivision_name'],
['dunammag'] = args['area_total_dunamarea_magnitude'],
}}
else
return ""
end
end
 
function p.demographics(frame)
local args = getArgs(frame)
local tArgs = {
['child'] = 'yes',
['headerstyle'] = 'text-align:left',
}}
 
for i = 1,2 do
local dtype = getNetValue(frame, 'demographics', 'type'..i)
if not isempty(dtype) then
local series = i + 20 * (i-1)
tArgs['header'..series] = dtype..'<div style="font-weight:normal;display:inline;">'.. getNetValue(frame, 'demographics1', 'footnotes') ..'</div>'
tArgs['rowclass'..series] = 'mergedtoprow'
for j = 1,10 do
local dval = getNetValue(frame, 'demographics1', 'title'..j)
if not isempty(dval) then
tArgs['rowclass'..(series + j)] = 'mergedrow'
tArgs['label'..(series + j)] = '&nbsp;•&nbsp;'..getNetValue(frame, 'demographics1', 'title'..j)
tArgs['data'..(series + j)] = getNetValue(frame, 'demographics1', 'info'..j)
end
end
end
end
return frame:expandTemplate{ title = 'infobox', args = tArgs}
end
 
function p.generic(frame)
local args = getArgs(frame)
local paramName = args['param_name']
return getNetValue(frame, 'area', paramName)
end