<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AGridiron_color</id>
	<title>Module:Gridiron color - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://the-democratika.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AGridiron_color"/>
	<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Gridiron_color&amp;action=history"/>
	<updated>2026-04-04T22:01:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://the-democratika.com/wiki/index.php?title=Module:Gridiron_color&amp;diff=6089&amp;oldid=prev</id>
		<title>&gt;Dissident93 at 18:16, 10 December 2024</title>
		<link rel="alternate" type="text/html" href="https://the-democratika.com/wiki/index.php?title=Module:Gridiron_color&amp;diff=6089&amp;oldid=prev"/>
		<updated>2024-12-10T18:16:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--&lt;br /&gt;
-- This module implements&lt;br /&gt;
-- {{Gridiron primary color}} -- {{Gridiron primary style}} -- {{Gridiron alt primary style}}&lt;br /&gt;
-- {{Gridiron secondary color}}&lt;br /&gt;
-- {{Gridiron alt primary color}} -- {{Gridiron alt secondary color}}&lt;br /&gt;
--&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
local color_data = mw.loadData(&amp;quot;Module:Gridiron color/data&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local yesno = require(&amp;#039;Module:Yesno&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local prefixes = {&lt;br /&gt;
	&amp;quot;background: &amp;quot;,&lt;br /&gt;
	&amp;quot;color: &amp;quot;,&lt;br /&gt;
	&amp;quot;/**/&amp;quot;,&lt;br /&gt;
	&amp;quot;background: &amp;quot;,&lt;br /&gt;
	&amp;quot;color: &amp;quot;&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
local default = {&amp;quot;#DCDCDC&amp;quot;, &amp;quot;#000000&amp;quot;, &amp;quot;none&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
local function get_year(colors, year)&lt;br /&gt;
	if colors and colors[6] and type(colors[6] == &amp;#039;table&amp;#039;) then&lt;br /&gt;
		for team, year_colors in pairs(colors[6]) do&lt;br /&gt;
			if mw.ustring.find(team, &amp;quot;%d%d%d%dthru%d%d%d%d$&amp;quot;) then&lt;br /&gt;
				local start_year, end_year = mw.ustring.match(team, &amp;quot;(%d%d%d%d)thru(%d%d%d%d)$&amp;quot;)&lt;br /&gt;
				if (tonumber(start_year) &amp;lt;= tonumber(year)) and (tonumber(year) &amp;lt;= tonumber(end_year)) then&lt;br /&gt;
					return year_colors&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return colors&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_colors(team, unknown, year)&lt;br /&gt;
	team = (team or &amp;#039;&amp;#039;):match(&amp;quot;^%s*(.-)%s*$&amp;quot;)&lt;br /&gt;
	year = tonumber(year)&lt;br /&gt;
	default = color_data and color_data[&amp;quot;#default&amp;quot;] or default&lt;br /&gt;
	unknown = unknown or default&lt;br /&gt;
&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 = unknown&lt;br /&gt;
	&lt;br /&gt;
	if (not use_default[team:lower()]) then&lt;br /&gt;
		if mw.ustring.find(team, &amp;quot;%d?%d?%d%dthru%d?%d?%d%d$&amp;quot;) then&lt;br /&gt;
			if (not year or year &amp;lt;= 0) then&lt;br /&gt;
				team, year = mw.ustring.match(team, &amp;quot;^(.-) -(%d?%d?%d%d)thru%d?%d?%d%d$&amp;quot;)&lt;br /&gt;
				team, year = team:match(&amp;quot;^%s*(.-)%s*$&amp;quot;), tonumber(year)&lt;br /&gt;
				&lt;br /&gt;
				if year &amp;gt;= 20 and year &amp;lt; 100 then -- Two-digit years were deprecated in 2018&lt;br /&gt;
					year = year + 1900&lt;br /&gt;
				elseif year &amp;lt; 20 then&lt;br /&gt;
					year = year + 2000&lt;br /&gt;
				elseif year &amp;lt; 1000 then&lt;br /&gt;
					year = nil&lt;br /&gt;
				end&lt;br /&gt;
			else&lt;br /&gt;
				team = mw.ustring.match(team, &amp;quot;^(.-) -%d?%d?%d%dthru%d?%d?%d%d$&amp;quot;) or team&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if color_data then&lt;br /&gt;
			if year and year &amp;gt; 0 then&lt;br /&gt;
				--code for handling year parameter&lt;br /&gt;
				colors = get_year(color_data[team], year)&lt;br /&gt;
			else&lt;br /&gt;
				colors = color_data[team]&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if ( colors and type(colors) == &amp;#039;string&amp;#039;) then&lt;br /&gt;
			if team == colors then year = nil end&lt;br /&gt;
			-- follow alias recursively&lt;br /&gt;
			return  get_colors (colors, unknown, year)&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 bordercss(c, w)&lt;br /&gt;
	if w &amp;gt; 0 then&lt;br /&gt;
		local s = &amp;#039;inset &amp;#039; .. w .. &amp;#039;px &amp;#039; .. w .. &amp;#039;px 0 &amp;#039; .. c &lt;br /&gt;
			.. &amp;#039;, inset -&amp;#039; .. w .. &amp;#039;px -&amp;#039; .. w .. &amp;#039;px 0 &amp;#039; .. c&lt;br /&gt;
		return &amp;#039;box-shadow: &amp;#039; .. s .. &amp;#039;;&amp;#039;&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function contrast_check(background, text, colors, alt)&lt;br /&gt;
	local c_limit = 3&lt;br /&gt;
	local contrast = require(&amp;#039;Module:Color_contrast&amp;#039;)&lt;br /&gt;
	if contrast._ratio({[1] = text, [2] = background, [&amp;#039;error&amp;#039;] = 0}) &amp;lt; c_limit then&lt;br /&gt;
		if contrast._ratio({[1] = &amp;#039;#FFFFFF&amp;#039;, [2] = background, [&amp;#039;error&amp;#039;] = 0}) &amp;gt;= c_limit then&lt;br /&gt;
			text = &amp;#039;#FFFFFF&amp;#039;&lt;br /&gt;
		elseif contrast._ratio({[1] = &amp;#039;#000000&amp;#039;, [2] = background, [&amp;#039;error&amp;#039;] = 0}) &amp;gt;= c_limit then&lt;br /&gt;
			text = &amp;#039;#000000&amp;#039;&lt;br /&gt;
		elseif (not alt) and (contrast._ratio({[1] = colors[5], [2] = colors[4], [&amp;#039;error&amp;#039;] = 0}) &amp;gt;= c_limit) then&lt;br /&gt;
			background, text = colors[4], colors[5]&lt;br /&gt;
		else&lt;br /&gt;
			background, text = default[1], default[2]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return background, text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.test(frame)&lt;br /&gt;
	local args = frame.args.team and frame.args or frame:getParent().args&lt;br /&gt;
	local colors = get_colors((args.team or args[1]), nil, args.year)&lt;br /&gt;
	return &amp;#039;[&amp;quot;&amp;#039; .. args.team .. &amp;#039;&amp;quot;] = {{ &amp;quot;&amp;#039; .. colors[1] .. &amp;#039;&amp;quot;, &amp;#039;.. colors[2] ..&lt;br /&gt;
		&amp;#039;&amp;quot;, &amp;#039;.. colors[3] .. &amp;#039;&amp;quot;, &amp;#039;.. colors[4] .. &amp;#039;&amp;quot;, &amp;#039;.. colors[5] .. &amp;#039;&amp;quot;}}&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.color(frame, column, altcolumn)&lt;br /&gt;
	local args = frame.args.team and frame.args or frame:getParent().args&lt;br /&gt;
	local colors = get_colors((args.team or args[1]), nil, args.year)&lt;br /&gt;
&lt;br /&gt;
	column = (column or tonumber(frame.args.column)) or 1&lt;br /&gt;
	altcolumn = altcolumn or tonumber(frame.args.altcolumn)&lt;br /&gt;
	if ((not colors[column]) or (colors[column] == &amp;#039;&amp;#039;)) and altcolumn then&lt;br /&gt;
		column = altcolumn&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return (yesno(frame.args.raw) and &amp;quot;&amp;quot; or prefixes[column]) .. colors[column]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.style(frame)&lt;br /&gt;
    local team = frame.args.team or frame.args[1] or frame:getParent().args.team or frame:getParent().args[1]&lt;br /&gt;
    local year = frame.args.year or frame:getParent().args.year&lt;br /&gt;
    local border = frame.args.border or frame:getParent().args.border&lt;br /&gt;
    local alt = yesno(frame.args.alt or frame:getParent().args.alt)&lt;br /&gt;
    &lt;br /&gt;
    local colors = get_colors(team, nil, year)&lt;br /&gt;
    &lt;br /&gt;
    local background, text&lt;br /&gt;
    if alt then&lt;br /&gt;
        background, text = colors[4], colors[5]  -- Alt colors (4 and 5)&lt;br /&gt;
    end&lt;br /&gt;
    if ((not background) or (background == &amp;#039;&amp;#039;)) then&lt;br /&gt;
        background = colors[1]  -- Default to primary color (1)&lt;br /&gt;
    end&lt;br /&gt;
    if ((not background) or (background == &amp;#039;&amp;#039;)) then&lt;br /&gt;
        background = default[1]  -- Default background color&lt;br /&gt;
    end&lt;br /&gt;
    if ((not text) or (text == &amp;#039;&amp;#039;)) then&lt;br /&gt;
        text = colors[2]  -- Default text color (2)&lt;br /&gt;
    end&lt;br /&gt;
    if ((not text) or (text == &amp;#039;&amp;#039;)) then&lt;br /&gt;
        text = default[2]  -- Default text color&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    background, text = contrast_check(background, text, colors, alt)&lt;br /&gt;
&lt;br /&gt;
    -- Add !important to prevent dark mode overrides&lt;br /&gt;
    local style = &amp;#039;background-color: &amp;#039; .. background .. &amp;#039; !important; color: &amp;#039; .. text .. &amp;#039; !important; &amp;#039;&lt;br /&gt;
&lt;br /&gt;
    -- Apply border based on the argument:&lt;br /&gt;
    -- Use the primary color (1) for the border if &amp;#039;alt&amp;#039; is true, otherwise use the tertiary color (3)&lt;br /&gt;
    if tonumber(border) or yesno(border) then&lt;br /&gt;
        border = tonumber(border) and border or 2&lt;br /&gt;
        local border_color = alt and colors[1] or colors[3]&lt;br /&gt;
        style = style .. bordercss(border_color, tonumber(border))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    return style&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>&gt;Dissident93</name></author>
	</entry>
</feed>