Module:Sandbox/ProcrastinatingReader/ib

local getArgs = require('Module:Arguments').getArgs

local p = {}

local function isempty(s)
  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

	local net = args[paramName] or dataValue(frame, args['subdivision_name'], paramName, args['name'])

	return net
end

function p.nativeName(frame)
	local val = frame.args[1]
	
	if val then
		local match = mw.ustring.match(val, "{{[Ii]nfobox (%a*)")
		--if true then return match end
		if match and match[1] then
			return match[1]
		end
	end
	
	return ""
end

function p.area(frame)
	local args = getArgs(frame)
	
	local argCategory = 'area'
	
	local km2 = getNetValue(frame, argCategory, 'km2')
	local ha = getNetValue(frame, argCategory, 'ha')
	local acre = getNetValue(frame, argCategory, 'acre')
	local sqmi = getNetValue(frame, argCategory, 'sq_mi')
	local dunam = getNetValue(frame, argCategory, 'dunam')
	
	if not (isempty(km2) and isempty(ha) and isempty(acre) and isempty(sqmi) and isempty(dunam)) then
		return frame:expandTemplate{ title = 'infobox_settlement/areadisp', args = {
			['km2'] = km2,
			['ha'] = ha,
			['acre'] = acre,
			['sqmi'] = sqmi,
			['dunam'] = dunam,
			['link'] = args['dunam_link'],
			['pref'] = args['unit_pref'],
			['name'] = args['subdivision_name'],
			['mag'] = args['area_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

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.