<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AGridiron_color%2Fcontrast</id>
	<title>Module:Gridiron color/contrast - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AGridiron_color%2Fcontrast"/>
	<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Gridiron_color/contrast&amp;action=history"/>
	<updated>2026-04-07T00:38:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://moasspedia.org/w/index.php?title=Module:Gridiron_color/contrast&amp;diff=1358&amp;oldid=prev</id>
		<title>Wikipedia&gt;Ahecht: Support a flexible number of columns</title>
		<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Gridiron_color/contrast&amp;diff=1358&amp;oldid=prev"/>
		<updated>2021-11-29T21:07:41Z</updated>

		<summary type="html">&lt;p&gt;Support a flexible number of columns&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This submodule is used to generate the complete color contrast table in&lt;br /&gt;
-- the documentation for [[Module:Gridiron color]]&lt;br /&gt;
local contrast = {}&lt;br /&gt;
local all_colors = {}&lt;br /&gt;
&lt;br /&gt;
local contrast_mod = require(&amp;quot;Module:Color contrast&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local function stripwhitespace(text)&lt;br /&gt;
	return text:match(&amp;quot;^%s*(.-)%s*$&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_colors(team, unknown)&lt;br /&gt;
	team = stripwhitespace(team or &amp;#039;&amp;#039;)&lt;br /&gt;
	unknown = unknown or {&amp;quot;DCDCDC&amp;quot;, &amp;quot;000000&amp;quot;}&lt;br /&gt;
 &lt;br /&gt;
	local use_default = {&lt;br /&gt;
		[&amp;quot;&amp;quot;] = 1,&lt;br /&gt;
		[&amp;quot;retired&amp;quot;] = 1,&lt;br /&gt;
		[&amp;quot;free agent&amp;quot;] = 1,&lt;br /&gt;
	}&lt;br /&gt;
 &lt;br /&gt;
	local colors = nil&lt;br /&gt;
 &lt;br /&gt;
	if ( team and use_default[team:lower()] ) then&lt;br /&gt;
		colors = {&amp;quot;DCDCDC&amp;quot;, &amp;quot;000000&amp;quot;}&lt;br /&gt;
	else&lt;br /&gt;
		colors = all_colors[team]&lt;br /&gt;
		if ( colors and type(colors) == &amp;#039;string&amp;#039; ) then&lt;br /&gt;
			colors = all_colors[colors]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
 &lt;br /&gt;
	return colors or unknown&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function color_contrast_ratio(hex1, hex2)&lt;br /&gt;
	if( hex1 and hex2) then&lt;br /&gt;
		local r = contrast_mod._ratio({&amp;#039;&amp;#039; .. hex1, &amp;#039;&amp;#039; .. hex2, error = 0})&lt;br /&gt;
		if( r &amp;gt; 0 ) then&lt;br /&gt;
			r = (r &amp;gt; 1) and r or (1/r)&lt;br /&gt;
			r = math.floor(r * 100 + 0.5) / 100&lt;br /&gt;
			return  (r &amp;gt; 1) and r or (1/r)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function contrast._testtable(args)&lt;br /&gt;
	local teamlist = {}&lt;br /&gt;
	local aliaslist = {}&lt;br /&gt;
	local style = args[&amp;#039;style&amp;#039;]&lt;br /&gt;
	local data_module = args[&amp;#039;data&amp;#039;] or (&amp;#039;Module:Gridiron color/&amp;#039; .. (args[&amp;#039;sport&amp;#039;] or &amp;#039;football&amp;#039;))&lt;br /&gt;
	local columns = tonumber(args[&amp;#039;columns&amp;#039;]) or 4&lt;br /&gt;
	all_colors = mw.loadData(data_module)&lt;br /&gt;
&lt;br /&gt;
	-- helper function&lt;br /&gt;
	local function table_row(t, c)&lt;br /&gt;
		local res = mw.html.create(&amp;#039;&amp;#039;)&lt;br /&gt;
		if( c[1] ) then&lt;br /&gt;
			res:tag(&amp;#039;td&amp;#039;):wikitext(t)&lt;br /&gt;
		else&lt;br /&gt;
			res:tag(&amp;#039;td&amp;#039;):wikitext(t .. &amp;#039; &amp;lt;span class=error&amp;gt;ERROR&amp;lt;/span&amp;gt;&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		for i=1,columns do&lt;br /&gt;
			res:tag(&amp;#039;td&amp;#039;)&lt;br /&gt;
				:css(&amp;#039;background&amp;#039;, c[i] or &amp;#039;transparent&amp;#039;)&lt;br /&gt;
				:wikitext(c[i] and &amp;#039;&amp;#039; or &amp;#039;X&amp;#039;)&lt;br /&gt;
		end&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;):wikitext(color_contrast_ratio(c[1],c[2]))&lt;br /&gt;
		res:tag(&amp;#039;td&amp;#039;):wikitext(color_contrast_ratio(c[columns],c[columns-1]))&lt;br /&gt;
		return tostring(res)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    -- list of teams&lt;br /&gt;
	if( args and args[1] ) then&lt;br /&gt;
		for k, team in pairs(args) do&lt;br /&gt;
			if type(k) == &amp;#039;number&amp;#039; then&lt;br /&gt;
				table.insert(teamlist, team)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		for team, colors in pairs( all_colors ) do&lt;br /&gt;
			if type(colors) == &amp;#039;string&amp;#039; then&lt;br /&gt;
				aliaslist[colors] = (aliaslist[colors] or &amp;#039;&amp;#039;) .. &amp;#039;&amp;lt;br /&amp;gt;Also known as &amp;#039; .. team&lt;br /&gt;
			else&lt;br /&gt;
				table.insert(teamlist, team)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		table.sort(teamlist)&lt;br /&gt;
		table.insert(teamlist, &amp;#039;Free agent&amp;#039;)&lt;br /&gt;
		table.insert(teamlist, &amp;#039;Retired&amp;#039;)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- build table&lt;br /&gt;
	local root = mw.html.create(&amp;#039;table&amp;#039;)&lt;br /&gt;
	root:addClass(&amp;#039;wikitable sortable&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;background&amp;#039;, &amp;#039;transparent&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;font-size&amp;#039;, &amp;#039;90%&amp;#039;)&lt;br /&gt;
		:css(&amp;#039;line-height&amp;#039;, &amp;#039;100%&amp;#039;)&lt;br /&gt;
		:cssText(style)&lt;br /&gt;
	if args[&amp;#039;caption&amp;#039;] then&lt;br /&gt;
		root:tag(&amp;#039;caption&amp;#039;):wikitext(args[&amp;#039;caption&amp;#039;])&lt;br /&gt;
	end&lt;br /&gt;
	local row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;rowspan&amp;#039;,2)&lt;br /&gt;
		:wikitext(&amp;#039;Team&amp;#039;)&lt;br /&gt;
	for i=1,columns do&lt;br /&gt;
		row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
			:addClass(&amp;#039;unsortable&amp;#039;)&lt;br /&gt;
			:attr(&amp;#039;rowspan&amp;#039;,2)&lt;br /&gt;
			:wikitext(i)&lt;br /&gt;
	end&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;)&lt;br /&gt;
		:attr(&amp;#039;colspan&amp;#039;, 2)&lt;br /&gt;
		:wikitext(&amp;#039;Contrast&amp;#039;)&lt;br /&gt;
	row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;):wikitext(&amp;#039;1/2&amp;#039;)&lt;br /&gt;
	row:tag(&amp;#039;th&amp;#039;):wikitext( tostring(columns) .. &amp;#039;/&amp;#039; .. tostring(columns - 1) )&lt;br /&gt;
	for k, team in pairs( teamlist ) do&lt;br /&gt;
		row = root:tag(&amp;#039;tr&amp;#039;)&lt;br /&gt;
		row:wikitext(table_row(team .. (aliaslist[team] or &amp;#039;&amp;#039;), get_colors(team)))&lt;br /&gt;
	end&lt;br /&gt;
	if style and style ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		style = &amp;#039;font-size:90%; padding:0.4em; width:32em; border:1px #aaa solid;&amp;#039; .. style&lt;br /&gt;
	end&lt;br /&gt;
	local note = nil&lt;br /&gt;
	if args[&amp;#039;note&amp;#039;] then&lt;br /&gt;
		note = args[&amp;#039;note&amp;#039;]&lt;br /&gt;
	else&lt;br /&gt;
		note = &amp;#039;The numeric columns are the calculated contrast ratio for colors&amp;#039;&lt;br /&gt;
		.. &amp;#039; 1:2 and colors &amp;#039; .. tostring(columns) .. &amp;#039;:&amp;#039; .. tostring(columns-1) &lt;br /&gt;
		.. &amp;#039;. Anything lower than 3 is&amp;#039;&lt;br /&gt;
		.. &amp;#039; very poor contrast and should be changed in&amp;#039;&lt;br /&gt;
		.. &amp;#039; [[&amp;#039; .. data_module .. &amp;#039;|the data module]]. For more&amp;#039;&lt;br /&gt;
		.. &amp;#039; information, see [[Template:Color contrast ratio]].&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	if note ~= &amp;#039;&amp;#039; then&lt;br /&gt;
		note = mw.html.create(&amp;#039;div&amp;#039;):cssText(style):wikitext(note)&lt;br /&gt;
	end&lt;br /&gt;
	return tostring(root) .. tostring(note)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function contrast.testtable(frame)&lt;br /&gt;
	return frame:preprocess(contrast._testtable(frame.args))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return contrast&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;Ahecht</name></author>
	</entry>
</feed>