<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfobox%2Futilities</id>
	<title>Module:Infobox/utilities - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://mindpowe.red/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AInfobox%2Futilities"/>
	<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Infobox/utilities&amp;action=history"/>
	<updated>2026-04-06T06:58:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://mindpowe.red/wiki/index.php?title=Module:Infobox/utilities&amp;diff=1796&amp;oldid=prev</id>
		<title>imported&gt;MusikBot II: Protected &quot;Module:Infobox/utilities&quot;: High-risk template or module (more info) ([Edit=Require autoconfirmed or confirmed access] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://mindpowe.red/wiki/index.php?title=Module:Infobox/utilities&amp;diff=1796&amp;oldid=prev"/>
		<updated>2020-07-24T18:00:26Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/wiki/index.php/Module:Infobox/utilities&quot; title=&quot;Module:Infobox/utilities&quot;&gt;Module:Infobox/utilities&lt;/a&gt;&amp;quot;: &lt;a href=&quot;https://en.wikipedia.org/wiki/High-risk_templates&quot; class=&quot;extiw&quot; title=&quot;wikipedia:High-risk templates&quot;&gt;High-risk template or module&lt;/a&gt; (&lt;a href=&quot;/wiki/index.php?title=User:MusikBot_II/TemplateProtector&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:MusikBot II/TemplateProtector (page does not exist)&quot;&gt;more info&lt;/a&gt;) ([Edit=Require autoconfirmed or confirmed access] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;require('Module:No globals');&lt;br /&gt;
local getArgs = require ('Module:Arguments').getArgs;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; I S _ C J K _ C O D E &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
return true if code is one of the listed Chinese, Japanese, Korean ISO 639 codes, false else.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function is_cjk_code (code)&lt;br /&gt;
local cjk =&lt;br /&gt;
		{&lt;br /&gt;
		['zh'] = true, ['cdo'] = true, ['cjy'] = true, ['cmn'] = true,			-- Chinese language codes&lt;br /&gt;
		['cpi'] = true, ['cpx'] = true, ['czh'] = true, ['czo'] = true,&lt;br /&gt;
		['gan'] = true, ['hak'] = true, ['hsn'] = true, ['ltc'] = true,&lt;br /&gt;
		['lzh'] = true, ['mnp'] = true, ['nan'] = true, ['och'] = true,&lt;br /&gt;
		['wuu'] = true, ['yue'] = true, ['zhx'] = true,&lt;br /&gt;
		['ja'] = true, ['jpx'] = true, ['ojp'] = true,							-- Japanese language codes&lt;br /&gt;
		['ko'] = true, ['okm'] = true, ['oko'] = true,							-- Korean language codes&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
	return cjk[code] or false;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S E T _ I T A L I C S &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
Created for use with Template:Infobox book and Template:Infobox document and perhaps others to replace hard-coded&lt;br /&gt;
italic markup in the call to {{lang}}.  This module attempts to make sure that {{lang}} correctly applies italic&lt;br /&gt;
markup according to MOS:FOREIGNITALIC.&lt;br /&gt;
&lt;br /&gt;
|italics={{#invoke:Infobox/utilities|set_italics|{{{orig_lang_code|}}}|{{{title_orig}}}}}}}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function set_italics (frame)&lt;br /&gt;
	local args=getArgs(frame); &lt;br /&gt;
	local code = args[1] or args['code'] or '';									-- empty string causes 'yes' return; {{lang}} will handle the missing code error&lt;br /&gt;
	local text = args[2] or args['text'] or '';									-- empty string causes 'yes' return; {{lang}} will handle the missing text error&lt;br /&gt;
&lt;br /&gt;
	local is_latn = require (&amp;quot;Module:Unicode data&amp;quot;).is_Latin;&lt;br /&gt;
	&lt;br /&gt;
	if is_cjk_code (code) and not is_latn (text) then							-- is_latn() is in Module:Unicode data&lt;br /&gt;
		return  'no';															-- only case for 'no' &lt;br /&gt;
	end&lt;br /&gt;
	return 'yes';																-- everything else is yes&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; C O M P &amp;gt;----------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
compare function for result{} table descending sort&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function comp (a, b)&lt;br /&gt;
	return tonumber (a[1]) &amp;gt; tonumber (b[1]);&lt;br /&gt;
end&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; S O R T _ C O M M O N &amp;gt;--------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
common function to render sorted distribution, ethnicity, and occupation lists.&lt;br /&gt;
&lt;br /&gt;
inputs:&lt;br /&gt;
	result - table of percentages and labels&lt;br /&gt;
	ref - value from |distribution ref=, |ethnicity ref=, or |occupation ref= as appropriate&lt;br /&gt;
	frame - calling frame required for expandTemplate()&lt;br /&gt;
	&lt;br /&gt;
returns sorted list on success; empty string else&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function sort_common (result, ref, frame)&lt;br /&gt;
	for i=#result, 1, -1 do&lt;br /&gt;
		if not tonumber (result[i][1]) then										-- if cannot be converted to a number&lt;br /&gt;
			table.remove (result, i);											-- delete&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if 0 == #result then														-- if we get here and the result table is empty&lt;br /&gt;
		return '';																-- abandon returning empty string&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	table.sort (result, comp);													-- sort what remains&lt;br /&gt;
&lt;br /&gt;
	for i, v in ipairs (result) do&lt;br /&gt;
		result[i] = table.concat (result[i]);									-- make each table in result{} a string&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	result[1] = table.concat ({result[1], ref and ref or ''});					-- add reference(s) from |&amp;lt;list&amp;gt; ref= to first item in the list&lt;br /&gt;
	&lt;br /&gt;
	return frame:expandTemplate { title = 'Unbulleted list', args = result};	-- render the unbulleted list&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; D I S R I B U T I O N _ S O R T &amp;gt;----------------------------------------------&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Infobox/utilities|distribution_sort|{{{percent urban|}}}|{{{percent rural|}}}|{{{distribution ref|}}} }}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function distribution_sort (frame)&lt;br /&gt;
	local args=getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	local result = {															-- initialize; table will be sorted according to values in result[n][1]&lt;br /&gt;
		{args[1], '% urban'},&lt;br /&gt;
		{args[2], '% rural'},&lt;br /&gt;
	};&lt;br /&gt;
	&lt;br /&gt;
	return sort_common (result, args[#result+1], frame);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E T H N I C I T Y _ S O R T &amp;gt;--------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Infobox/utilities|ethnicity_sort|{{{percent white|}}}|{{{percent black|}}}|{{{percent asian|}}}|{{{percent hispanic|}}}|{{{percent native american|}}}|{{{percent native hawaiian|}}}|{{{percent more than one race|}}}|{{{percent other race|}}}|{{{ethnicity ref|}}} }}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function ethnicity_sort (frame)&lt;br /&gt;
	local args=getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	local result = {															-- initialize; table will be sorted according to values in result[n][1]&lt;br /&gt;
		{args[1], '% [[White people|white]]'},&lt;br /&gt;
		{args[2], '% [[Black people|black]]'},&lt;br /&gt;
		{args[3], '% [[Asian Americans|Asian]]'},&lt;br /&gt;
		{args[4], '% [[Hispanic]]'},&lt;br /&gt;
		{args[5], '% [[Native Americans in the United States|Native American]]'},&lt;br /&gt;
		{args[6], '% [[Pacific Islands Americans]]'},&lt;br /&gt;
		{args[7], '% [[Two or more races]]'},&lt;br /&gt;
		{args[8], '% other'},													-- TODO: make other always last?&lt;br /&gt;
	};&lt;br /&gt;
	&lt;br /&gt;
	return sort_common (result, args[#result+1], frame);&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; O C C U P A T I O N _ S O R T &amp;gt;------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
{{#invoke:Infobox/utilities|distribution_sort|{{{percent blue collar|}}}|{{{percent white collar|}}}|{{{percent grey collar|}}}|{{{occupation ref|}}} }}&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
local function occupation_sort (frame)&lt;br /&gt;
	local args=getArgs(frame);&lt;br /&gt;
	&lt;br /&gt;
	local result = {															-- initialize; table will be sorted according to values in result[n][1]&lt;br /&gt;
		{args[1], '% [[Blue-collar worker|Blue-collar]]'},&lt;br /&gt;
		{args[2], '% [[White-collar worker|White-collar]]'},&lt;br /&gt;
		{args[3], '% [[Gray-collar]]'},&lt;br /&gt;
	};&lt;br /&gt;
	&lt;br /&gt;
	return sort_common (result, args[#result+1], frame)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[--------------------------&amp;lt; E X P O R T E D   F U N C T I O N S &amp;gt;------------------------------------------&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	distribution_sort = distribution_sort,										-- {{Infobox U.S. congressional district}}&lt;br /&gt;
	ethnicity_sort = ethnicity_sort,&lt;br /&gt;
	occupation_sort = occupation_sort,&lt;br /&gt;
	&lt;br /&gt;
	set_italics = set_italics,													-- {{Infobox book}}&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>imported&gt;MusikBot II</name></author>
		
	</entry>
</feed>