Displays entire row from Module:Gridiron color/data for team and year passed in template call or using |team= and |year= (if omitted from invoke, module will take values from the template call):
{{#invoke:Gridiron color|test|team=team name (optional)|year=#### (optional)}}
Returns either raw color value or prefixed color value. |column= uses the following values:
Primary color (background)
Secondary color (text)
Tertiary color raw (border)
Alt primary color
Alt secondary color
Set |raw=true to display raw hex values. Team name and year passed in template call or specified using |team= and |year=:
{{#invoke:Gridiron color|color|column=#|raw=true (optional)|team=team name (optional)|year=#### (optional)}}
background: #00274D
Return team style
Returns complete CSS style for given team. A border will be displayed using the tertiary color if |border= is set to "true" (in which case the border will be 2px wide) or to a positive integer value (in which case the width will be the value specified in pixels). Team name and year passed in template call or specified using |team= and |year=:
{{#invoke:Gridiron color|style|border=# or yes (optional)|team=team name (optional)|year=#### (optional)}}
---- This module implements-- {{Gridiron primary color}} -- {{Gridiron primary style}} -- {{Gridiron alt primary style}}-- {{Gridiron secondary color}}-- {{Gridiron alt primary color}} -- {{Gridiron alt secondary color}}--localp={}localcolor_data=mw.loadData("Module:Gridiron color/data")localyesno=require('Module:Yesno')localprefixes={"background: ","color: ","/**/","background: ","color: "}localdefault={"#DCDCDC","#000000","none","",""}localfunctionget_year(colors,year)ifcolorsandcolors[6]andtype(colors[6]=='table')thenforteam,year_colorsinpairs(colors[6])doifmw.ustring.find(team,"%d%d%d%dthru%d%d%d%d$")thenlocalstart_year,end_year=mw.ustring.match(team,"(%d%d%d%d)thru(%d%d%d%d)$")if(tonumber(start_year)<=tonumber(year))and(tonumber(year)<=tonumber(end_year))thenreturnyear_colorsendendendendreturncolorsendlocalfunctionget_colors(team,unknown,year)team=(teamor''):match("^%s*(.-)%s*$")year=tonumber(year)default=color_dataandcolor_data["#default"]ordefaultunknown=unknownordefaultlocaluse_default={[""]=1,["retired"]=1,["free agent"]=1,}localcolors=unknownif(notuse_default[team:lower()])thenifmw.ustring.find(team,"%d?%d?%d%dthru%d?%d?%d%d$")thenif(notyearoryear<=0)thenteam,year=mw.ustring.match(team,"^(.-) -(%d?%d?%d%d)thru%d?%d?%d%d$")team,year=team:match("^%s*(.-)%s*$"),tonumber(year)ifyear>=20andyear<100then-- Two-digit years were deprecated in 2018year=year+1900elseifyear<20thenyear=year+2000elseifyear<1000thenyear=nilendelseteam=mw.ustring.match(team,"^(.-) -%d?%d?%d%dthru%d?%d?%d%d$")orteamendendifcolor_datathenifyearandyear>0then--code for handling year parametercolors=get_year(color_data[team],year)elsecolors=color_data[team]endendif(colorsandtype(colors)=='string')thenifteam==colorsthenyear=nilend-- follow alias recursivelyreturnget_colors(colors,unknown,year)endendreturncolorsorunknownendlocalfunctionbordercss(c,w)ifw>0thenlocals='inset '..w..'px '..w..'px 0 '..c..', inset -'..w..'px -'..w..'px 0 '..creturn'box-shadow: '..s..';'elsereturn''endendlocalfunctioncontrast_check(background,text,colors,alt)localc_limit=3localcontrast=require('Module:Color_contrast')ifcontrast._ratio({[1]=text,[2]=background,['error']=0})<c_limitthenifcontrast._ratio({[1]='#FFFFFF',[2]=background,['error']=0})>=c_limitthentext='#FFFFFF'elseifcontrast._ratio({[1]='#000000',[2]=background,['error']=0})>=c_limitthentext='#000000'elseif(notalt)and(contrast._ratio({[1]=colors[5],[2]=colors[4],['error']=0})>=c_limit)thenbackground,text=colors[4],colors[5]elsebackground,text=default[1],default[2]endendreturnbackground,textendfunctionp.test(frame)localargs=frame.args.teamandframe.argsorframe:getParent().argslocalcolors=get_colors((args.teamorargs[1]),nil,args.year)return'["'..args.team..'"] = {{ "'..colors[1]..'", '..colors[2]..'", '..colors[3]..'", '..colors[4]..'", '..colors[5]..'"}}'endfunctionp.color(frame,column,altcolumn)localargs=frame.args.teamandframe.argsorframe:getParent().argslocalcolors=get_colors((args.teamorargs[1]),nil,args.year)column=(columnortonumber(frame.args.column))or1altcolumn=altcolumnortonumber(frame.args.altcolumn)if((notcolors[column])or(colors[column]==''))andaltcolumnthencolumn=altcolumnendreturn(yesno(frame.args.raw)and""orprefixes[column])..colors[column]endfunctionp.style(frame)localteam=frame.args.teamorframe.args[1]orframe:getParent().args.teamorframe:getParent().args[1]localyear=frame.args.yearorframe:getParent().args.yearlocalborder=frame.args.borderorframe:getParent().args.borderlocalalt=yesno(frame.args.altorframe:getParent().args.alt)localcolors=get_colors(team,nil,year)localbackground,textifaltthenbackground,text=colors[4],colors[5]-- Alt colors (4 and 5)endif((notbackground)or(background==''))thenbackground=colors[1]-- Default to primary color (1)endif((notbackground)or(background==''))thenbackground=default[1]-- Default background colorendif((nottext)or(text==''))thentext=colors[2]-- Default text color (2)endif((nottext)or(text==''))thentext=default[2]-- Default text colorendbackground,text=contrast_check(background,text,colors,alt)-- Add !important to prevent dark mode overrideslocalstyle='background-color: '..background..' !important; color: '..text..' !important; '-- Apply border based on the argument:-- Use the primary color (1) for the border if 'alt' is true, otherwise use the tertiary color (3)iftonumber(border)oryesno(border)thenborder=tonumber(border)andborderor2localborder_color=altandcolors[1]orcolors[3]style=style..bordercss(border_color,tonumber(border))endreturnstyleendreturnp