https://www.eastvanbaseball.com/statistics/leaders
The dropdown menus should change the year and type of stats, but it’s not working.
Here is the javascript:
var m,pushStat,z,count,assignTeam,getYear=2023,statsFile="/assets/stats/EVBL-stats-"+getYear+".json?nocache="+(new Date).getTime(),teamNameData=[{fullName:"East Van Black Sox",lastName:"Black Sox",abbr:"SOX",logoPath:"Black_Sox.png"},{fullName:"Little Mtn Blasters",lastName:"Blasters",abbr:"LM",logoPath:"blasters.png"},{fullName:"Clark Park Brawlers",lastName:"Brawlers",abbr:"CP",logoPath:"brawlers.png"},{fullName:"Chinatown Cobras",lastName:"Cobras",abbr:"CHN",logoPath:"Cobras.png"},{fullName:"Sunrise Cosmos",lastName:"Cosmos",abbr:"COS",logoPath:"cosmos.png"},{fullName:"Gastown Gaolers",lastName:"Gaolers",abbr:"GAS",logoPath:"Gaolers.png"},{fullName:"Vancouver Isotopes",lastName:"Isotopes",abbr:"VAN",logoPath:"isotopes.png"},{fullName:"Mt Pleasant Murder",lastName:"Murder",abbr:"MT",logoPath:"Murder.png"},{fullName:"Railtown Spikers",lastName:"Spikers",abbr:"RT",logoPath:"Spikers_alt.png"},{fullName:"Strathcona Stevedores",lastName:"Stevedores",abbr:"STR",logoPath:"Stevedores.png"},{fullName:"Sunset Stilettos",lastName:"Stilettos",abbr:"SET",logoPath:"Stilettos.png"}],logoRootURL="/assets/team_logos/",battingStatsTabs=[20,11,12,28,23,22,21,9,10],pitchingStatsTabs=[69,67,70,54,57,59,101,99],tablelength=15,qualifyPA=0,qualifyBF=0,batHeaderLine=[],pitchHeaderLine=[],batNameTable=[],pitchNameTable=[],batTeamTable=[],pitchTeamTable=[],batStatTable=[],pitchStatTable=[],playerPA=[],playerBF=[],batTableHtmlMobile="",pitchTableHtmlMobile="",batHtml='<div id="batting_leaders"><h3>BATTING LEADERS</h3>',pitchHtml='<div id="pitching_leaders"><h3>PITCHING LEADERS</h3>',batHtmlMobile='<div id="batting_leadersMobile"><h3>BATTING LEADERS</h3><div id="bat_tabs">',pitchHtmlMobile='<div id="pitching_leadersMobile"><h3>PITCHING LEADERS</h3><div id="pitch_tabs">',batTabsHtml="<ul>",pitchTabsHtml="<ul>";for(m=0;m<battingStatsTabs.length;m++)batStatTable[m]=[];for(m=0;m<pitchingStatsTabs.length;m++)pitchStatTable[m]=[];$.ajax({type:"GET",url:statsFile,async:!1}).done(function(t){for(var a=0;a<t.player.length;a++){if(0==a)for(l in t.player[a])batHeaderLine.push(l);if("Ringer"!=t.player[a].Last.substr(0,6)&&"0"!=t.player[a].Last.substr(0,1)&&0<t.player[a].Last.length&&t.player[a].Number.length<3){batNameTable.push(t.player[a].Last),assignTeam=-1;for(var e=0;teamNameData[e].lastName==t.player[a].team&&(assignTeam=e,batTeamTable.push(assignTeam)),e++,assignTeam<0;);for(qualifyPA+=Number(t.player[a].PA),playerPA.push(t.player[a].PA),m=0;m<battingStatsTabs.length;m++)pushStat=batHeaderLine[battingStatsTabs[m]],batStatTable[m].push(Number(t.player[a][pushStat]))}}(qualifyPA=Math.round(qualifyPA/batNameTable.length*.5))<1&&(qualifyPA=0),0<qualifyPA&&(batHtml+="<p>*Minimum "+qualifyPA+" plate appearances</p>");for(a=0;a<t.player.length;a++){var l;if(0==a)for(l in t.player[a])pitchHeaderLine.push(l);if("Ringer"!=t.player[a].Last.substr(0,6)&&"0"!=t.player[a].Last.substr(0,1)&&0<t.player[a].Last.length&&t.player[a].Number.length<3&&0<t.player[a].IP){pitchNameTable.push(t.player[a].Last),assignTeam=-1;for(e=0;teamNameData[e].lastName==t.player[a].team&&(assignTeam=e,pitchTeamTable.push(assignTeam)),e++,assignTeam<0;);for(qualifyBF+=Number(t.player[a].BF),playerBF.push(t.player[a].BF),m=0;m<pitchingStatsTabs.length;m++)pushStat=pitchHeaderLine[pitchingStatsTabs[m]],pitchStatTable[m].push(Number(t.player[a][pushStat]))}}for((qualifyBF=Math.round(qualifyBF/pitchNameTable.length*.6))<1&&(qualifyBF=0),0<qualifyBF&&(pitchHtml+="<p>*Minimum "+qualifyBF+" batters faced</p>"),m=0;m<battingStatsTabs.length;m++){29==battingStatsTabs[m]&&(batHeaderLine[battingStatsTabs[m]]="RISP"),batTabsHtml+='<li><a href="#fragment-'+(m+1)+'"><span>'+batHeaderLine[battingStatsTabs[m]]+"</span></a></li>",batTableHtmlMobile+='<div id="fragment-'+(m+1)+'">',batHtml+='<div class = "statTable"><table class="leaders"><thead><tr><th colspan="4" valign="middle">'+batHeaderLine[battingStatsTabs[m]]+"</th></tr></thead><tbody>";var i=batStatTable[m].length,b=new Array(i);for(a=0;a<i;++a)b[a]=a,b.sort(function(t,a){return batStatTable[m][t]>batStatTable[m][a]?-1:batStatTable[m][t]<batStatTable[m][a]?1:playerPA[m][t]>playerPA[m][a]?-1:playerPA[m][t]<playerPA[m][a]?1:0});for(batTableHtmlMobile+='<table class="leadersMobile"><thead><tr><th class="rank" valign="middle"></th><th class="team"></th><th class="player" valign="middle"></th><th class="stat" valign="middle"></th></tr></thead><tbody>',count=z=0;count<tablelength;)playerPA[b[z]]>qualifyPA&&(batTableHtmlMobile+="<tr",batHtml+="<tr","HR"!=batHeaderLine[battingStatsTabs[m]]&&"RBI"!=batHeaderLine[battingStatsTabs[m]]&&"SB"!=batHeaderLine[battingStatsTabs[m]]&&"2B"!=batHeaderLine[battingStatsTabs[m]]&&"3B"!=batHeaderLine[battingStatsTabs[m]]||0==batStatTable[m][b[z]]&&(batTableHtmlMobile+=' class="hidden"',batHtml+=' class="hidden"'),batTableHtmlMobile+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[batTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[batTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+batNameTable[b[z]]+'</td><td class="stat" valign="middle">',batHtml+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[batTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[batTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+batNameTable[b[z]]+'</td><td class="stat" valign="middle">',"AVG"==batHeaderLine[battingStatsTabs[m]]||"SLG"==batHeaderLine[battingStatsTabs[m]]||"OBP"==batHeaderLine[battingStatsTabs[m]]||"RISP"==batHeaderLine[battingStatsTabs[m]]||"OPS"==batHeaderLine[battingStatsTabs[m]]?.999<Number(batStatTable[m][b[z]])?(batTableHtmlMobile+=Number(batStatTable[m][b[z]]).toFixed(3),batHtml+=Number(batStatTable[m][b[z]]).toFixed(3)):(batTableHtmlMobile+=Number(batStatTable[m][b[z]]).toFixed(3).toString().substr(1),batHtml+=Number(batStatTable[m][b[z]]).toFixed(3).toString().substr(1)):(batTableHtmlMobile+=batStatTable[m][b[z]],batHtml+=batStatTable[m][b[z]]),batTableHtmlMobile+="</td></tr>",batHtml+="</td></tr>",count++),z++;batTableHtmlMobile+="</tbody></table></div>",batHtml+="</tbody></table></div>"}for(batTabsHtml+="</ul>",batHtml+="</div>",m=0;m<pitchingStatsTabs.length;m++){67==pitchingStatsTabs[m]&&(pitchHeaderLine[pitchingStatsTabs[m]]="K"),99==pitchingStatsTabs[m]&&(pitchHeaderLine[pitchingStatsTabs[m]]="K/7"),pitchTabsHtml+='<li><a href="#fragment-'+(m+1)+'"><span>'+pitchHeaderLine[pitchingStatsTabs[m]]+"</span></a></li>",pitchTableHtmlMobile+='<div id="fragment-'+(m+1)+'">',pitchHtml+='<div class = "statTable"><table class="leaders"><thead><tr><th colspan="4" valign="middle">'+pitchHeaderLine[pitchingStatsTabs[m]]+"</th></tr></thead><tbody>";i=pitchStatTable[m].length,b=new Array(i);for(a=0;a<i;++a)b[a]=a,"ERA"==pitchHeaderLine[pitchingStatsTabs[m]]||"WHIP"==pitchHeaderLine[pitchingStatsTabs[m]]?b.sort(function(t,a){return pitchStatTable[m][t]<pitchStatTable[m][a]?-1:pitchStatTable[m][t]>pitchStatTable[m][a]?1:playerBF[m][t]>playerBF[m][a]?-1:playerBF[m][t]<playerBF[m][a]?1:0}):b.sort(function(t,a){return pitchStatTable[m][t]>pitchStatTable[m][a]?-1:pitchStatTable[m][t]<pitchStatTable[m][a]?1:playerBF[m][t]>playerBF[m][a]?-1:playerBF[m][t]<playerBF[m][a]?1:0});for(pitchTableHtmlMobile+='<table class="leadersMobile"><thead><tr><th class="rank" valign="middle"></th><th class="team" valign="middle"></th><th class="player" valign="middle"></th><th class="stat" valign="middle"></th></tr></thead><tbody>',count=z=0;count<tablelength;)playerBF[b[z]]>qualifyBF&&(pitchTableHtmlMobile+="<tr",pitchHtml+="<tr","K"!=pitchHeaderLine[pitchingStatsTabs[m]]&&"W"!=pitchHeaderLine[pitchingStatsTabs[m]]&&"SV"!=pitchHeaderLine[pitchingStatsTabs[m]]||0==pitchStatTable[m][b[z]]&&(pitchTableHtmlMobile+=' class="hidden"',pitchHtml+=' class="hidden"'),pitchTableHtmlMobile+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[pitchTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[pitchTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+pitchNameTable[b[z]]+'</td><td class="stat" valign="middle">',pitchHtml+='><td class="rank" valign="middle">'+(count+1)+'</td><td class="team"><img src="'+logoRootURL+teamNameData[pitchTeamTable[b[z]]].logoPath+'" alt="'+teamNameData[pitchTeamTable[b[z]]].abbr+'" width="24" height="24"></td><td class="player" valign="middle">'+pitchNameTable[b[z]]+'</td><td class="stat" valign="middle">',"ERA"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=(7*Number(pitchStatTable[m][b[z]])/7).toFixed(2),pitchHtml+=(7*Number(pitchStatTable[m][b[z]])/7).toFixed(2)):"WHIP"==pitchHeaderLine[pitchingStatsTabs[m]]||"K/BB"==pitchHeaderLine[pitchingStatsTabs[m]]||"K/7"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=Number(pitchStatTable[m][b[z]]).toFixed(2),pitchHtml+=Number(pitchStatTable[m][b[z]]).toFixed(2)):"IP"==pitchHeaderLine[pitchingStatsTabs[m]]?(pitchTableHtmlMobile+=Number(pitchStatTable[m][b[z]]).toFixed(1),pitchHtml+=Number(pitchStatTable[m][b[z]]).toFixed(1)):(pitchTableHtmlMobile+=pitchStatTable[m][b[z]],pitchHtml+=pitchStatTable[m][b[z]]),pitchTableHtmlMobile+="</td></tr>",pitchHtml+="</td></tr>",count++),z++;pitchTableHtmlMobile+="</tbody></table></div>",pitchHtml+="</tbody></table></div>"}pitchHtml+="</div>",batHtmlMobile+=batTabsHtml+batTableHtmlMobile+"</div>",pitchHtmlMobile+=(pitchTabsHtml+="</ul>")+pitchTableHtmlMobile+"</div>",$("#leadersTableMobile").html(""),$("#leadersTableMobile").append(batHtmlMobile),$("#leadersTableMobile").append(pitchHtmlMobile),$("#bat_tabs").tabs(),$("#pitch_tabs").tabs(),$("#leadersTable").html(""),$("#leadersTable").append(batHtml),$("#leadersTable").append(pitchHtml)});