@@ -1001,6 +1001,10 @@ <h3>Divisions</h3>
1001
1001
< h3 > Generations</ h3 >
1002
1002
< ul > </ ul > <!-- This will be populated dynamically -->
1003
1003
</ div >
1004
+ < div class ="filter-section " id ="exclusive-filter-section ">
1005
+ < h3 > Exclusive</ h3 >
1006
+ < ul > </ ul > <!-- This will be populated dynamically -->
1007
+ </ div >
1004
1008
</ div >
1005
1009
< table >
1006
1010
< thead >
@@ -1165,13 +1169,14 @@ <h3>Proofs</h3>
1165
1169
personalLink : athlete . PersonalLink ,
1166
1170
profilePic : athlete . ProfilePic ,
1167
1171
division : athlete . Division ,
1168
- generation : generation
1172
+ generation : generation ,
1173
+ exclusiveLeague : athlete . ExclusiveLeague
1169
1174
} ;
1170
-
1171
1175
} ) ;
1172
1176
1173
1177
generateDivisionFilters ( athleteResults ) ;
1174
1178
generateGenerationFilters ( athleteResults ) ;
1179
+ generateExclusiveFilters ( athleteResults ) ;
1175
1180
1176
1181
// Sort the athletes by age reduction in ascending order
1177
1182
athleteResults . sort ( compareAthleteRank ) ;
@@ -1664,6 +1669,10 @@ <h3>Proofs</h3>
1664
1669
const selectedGenerations = Array . from ( document . querySelectorAll ( 'input[name="generation"]:checked' ) )
1665
1670
. map ( checkbox => checkbox . value . toLowerCase ( ) ) ;
1666
1671
1672
+ // Get selected exclusive leagues (e.g. "Prosperan")
1673
+ const selectedExclusiveLeagues = Array . from ( document . querySelectorAll ( 'input[name="exclusiveLeague"]:checked' ) )
1674
+ . map ( checkbox => checkbox . value . toLowerCase ( ) ) ;
1675
+
1667
1676
const query = normalizeString ( document . getElementById ( 'athleteSearch' ) . value . trim ( ) . toLowerCase ( ) ) ;
1668
1677
const searchTerms = query . split ( / \s + / ) . filter ( term => term . length > 0 ) ;
1669
1678
const uniqueSearchTerms = [ ...new Set ( searchTerms ) ] ;
@@ -1687,6 +1696,11 @@ <h3>Proofs</h3>
1687
1696
matches = matches && selectedGenerations . includes ( athlete . generation . toLowerCase ( ) ) ;
1688
1697
}
1689
1698
1699
+ // Check exclusive league match
1700
+ if ( selectedExclusiveLeagues . length > 0 ) {
1701
+ matches = matches && selectedExclusiveLeagues . includes ( ( athlete . exclusiveLeague || "" ) . toLowerCase ( ) ) ;
1702
+ }
1703
+
1690
1704
// Check search terms
1691
1705
if ( matches && ! showAll ) {
1692
1706
matches = uniqueSearchTerms . every ( term => athleteNameNormalized . includes ( term ) ) ;
@@ -1700,7 +1714,7 @@ <h3>Proofs</h3>
1700
1714
filteredAthletes = filteredAthletes . slice ( 0 , maxAthletesGlobal ) ;
1701
1715
1702
1716
// Determine if filters are used
1703
- const filtersUsed = selectedDivisions . length > 0 || selectedGenerations . length > 0 ;
1717
+ const filtersUsed = selectedDivisions . length > 0 || selectedGenerations . length > 0 || selectedExclusiveLeagues . length > 0 ;
1704
1718
const searchUsed = uniqueSearchTerms . length > 0 ;
1705
1719
1706
1720
// If filters are used, reassign ranks starting from 1
@@ -1785,82 +1799,86 @@ <h3>Proofs</h3>
1785
1799
// Update the collapsed-title text based on selected filters
1786
1800
let leagueText = '' ;
1787
1801
1788
- // Build generation part of the league text
1789
- if ( selectedGenerations . length === 1 ) {
1790
- leagueText += selectedGenerations [ 0 ] . toUpperCase ( ) ;
1791
- } else if ( selectedGenerations . length === 2 ) {
1792
- const [ first , second ] = selectedGenerations . map ( gen => gen . toLowerCase ( ) ) . sort ( ) ;
1793
-
1794
- // Check for specific two-generation combinations
1795
- if ( first === "baby boomers" && second === "silent generation" ) {
1796
- leagueText += "HERITAGE" ;
1797
- } else if ( first === "baby boomers" && second === "gen x" ) {
1798
- leagueText += "SENIOR" ;
1799
- } else if ( first === "gen x" && second === "millennials" ) {
1800
- leagueText += "PRIME" ;
1801
- } else if ( first === "gen z" && second === "millennials" ) {
1802
- leagueText += "RISING" ;
1803
- } else if ( first === "gen alpha" && second === "gen z" ) {
1804
- leagueText += "NEXT-GEN" ;
1805
- } else {
1806
- leagueText += selectedGenerations [ 0 ] . toUpperCase ( ) + ' AND ' + selectedGenerations [ 1 ] . toUpperCase ( ) ;
1807
- }
1808
- } else if ( selectedGenerations . length === 3 ) {
1809
- leagueText +=
1810
- selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1811
- selectedGenerations [ 1 ] . toUpperCase ( ) + ', AND ' +
1812
- selectedGenerations [ 2 ] . toUpperCase ( ) ;
1813
- } else if ( selectedGenerations . length === 4 ) {
1814
- leagueText +=
1815
- selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1816
- selectedGenerations [ 1 ] . toUpperCase ( ) + ', ' +
1817
- selectedGenerations [ 2 ] . toUpperCase ( ) + ', AND ' +
1818
- selectedGenerations [ 3 ] . toUpperCase ( ) ;
1819
- } else if ( selectedGenerations . length === 5 ) {
1820
- leagueText +=
1821
- selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1822
- selectedGenerations [ 1 ] . toUpperCase ( ) + ', ' +
1823
- selectedGenerations [ 2 ] . toUpperCase ( ) + ', ' +
1824
- selectedGenerations [ 3 ] . toUpperCase ( ) + ', AND ' +
1825
- selectedGenerations [ 4 ] . toUpperCase ( ) ;
1826
- }
1827
-
1828
- // Build division part of the league text
1829
- if ( selectedDivisions . length === 1 ) {
1830
- if ( leagueText . length > 0 ) {
1831
- leagueText += ' ' ;
1802
+ // If an exclusive league is selected, override the league text.
1803
+ if ( selectedExclusiveLeagues . length > 0 ) {
1804
+ // If multiple exclusive leagues are selected, join them with " AND "
1805
+ leagueText = selectedExclusiveLeagues . map ( league => league . toUpperCase ( ) ) . join ( ' AND ' ) + ' LEAGUE' ;
1806
+ } else {
1807
+ // Build generation part of the league text
1808
+ if ( selectedGenerations . length === 1 ) {
1809
+ leagueText += selectedGenerations [ 0 ] . toUpperCase ( ) ;
1810
+ } else if ( selectedGenerations . length === 2 ) {
1811
+ const [ first , second ] = selectedGenerations . map ( gen => gen . toLowerCase ( ) ) . sort ( ) ;
1812
+
1813
+ // Check for specific two-generation combinations
1814
+ if ( first === "baby boomers" && second === "silent generation" ) {
1815
+ leagueText += "HERITAGE" ;
1816
+ } else if ( first === "baby boomers" && second === "gen x" ) {
1817
+ leagueText += "SENIOR" ;
1818
+ } else if ( first === "gen x" && second === "millennials" ) {
1819
+ leagueText += "PRIME" ;
1820
+ } else if ( first === "gen z" && second === "millennials" ) {
1821
+ leagueText += "RISING" ;
1822
+ } else if ( first === "gen alpha" && second === "gen z" ) {
1823
+ leagueText += "NEXT-GEN" ;
1824
+ } else {
1825
+ leagueText += selectedGenerations [ 0 ] . toUpperCase ( ) + ' AND ' + selectedGenerations [ 1 ] . toUpperCase ( ) ;
1826
+ }
1827
+ } else if ( selectedGenerations . length === 3 ) {
1828
+ leagueText +=
1829
+ selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1830
+ selectedGenerations [ 1 ] . toUpperCase ( ) + ', AND ' +
1831
+ selectedGenerations [ 2 ] . toUpperCase ( ) ;
1832
+ } else if ( selectedGenerations . length === 4 ) {
1833
+ leagueText +=
1834
+ selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1835
+ selectedGenerations [ 1 ] . toUpperCase ( ) + ', ' +
1836
+ selectedGenerations [ 2 ] . toUpperCase ( ) + ', AND ' +
1837
+ selectedGenerations [ 3 ] . toUpperCase ( ) ;
1838
+ } else if ( selectedGenerations . length === 5 ) {
1839
+ leagueText +=
1840
+ selectedGenerations [ 0 ] . toUpperCase ( ) + ', ' +
1841
+ selectedGenerations [ 1 ] . toUpperCase ( ) + ', ' +
1842
+ selectedGenerations [ 2 ] . toUpperCase ( ) + ', ' +
1843
+ selectedGenerations [ 3 ] . toUpperCase ( ) + ', AND ' +
1844
+ selectedGenerations [ 4 ] . toUpperCase ( ) ;
1845
+
1846
+ // Build division part of the league text
1832
1847
}
1833
- leagueText += selectedDivisions [ 0 ] . toUpperCase ( ) ;
1834
- } else if ( selectedDivisions . length === 2 ) {
1835
- if ( leagueText . length > 0 ) {
1836
- leagueText += ' ' ;
1848
+
1849
+ if ( selectedDivisions . length === 1 ) {
1850
+ if ( leagueText . length > 0 ) {
1851
+ leagueText += ' ' ;
1852
+ }
1853
+ leagueText += selectedDivisions [ 0 ] . toUpperCase ( ) ;
1854
+ } else if ( selectedDivisions . length === 2 ) {
1855
+ if ( leagueText . length > 0 ) {
1856
+ leagueText += ' ' ;
1857
+ }
1858
+
1859
+ // Custom sorting order for divisions
1860
+ const order = { "men's" : 1 , "women's" : 2 , "open" : 3 } ;
1861
+ const [ first , second ] = selectedDivisions
1862
+ . map ( div => div . toLowerCase ( ) )
1863
+ . sort ( ( a , b ) => order [ a ] - order [ b ] ) ;
1864
+
1865
+ if ( first === "men's" && second === "women's" ) {
1866
+ leagueText += 'MIXED' ;
1867
+ } else if ( first === "men's" && second === 'open' ) {
1868
+ leagueText += "INCLUSIVE MEN'S" ;
1869
+ } else if ( first === "women's" && second === 'open' ) {
1870
+ leagueText += "INCLUSIVE WOMEN'S" ;
1871
+ }
1837
1872
}
1838
1873
1839
- // Custom sorting order for divisions
1840
- const order = { "men's" : 1 , "women's" : 2 , "open" : 3 } ;
1841
-
1842
- // Sort divisions based on custom order
1843
- const [ first , second ] = selectedDivisions
1844
- . map ( div => div . toLowerCase ( ) )
1845
- . sort ( ( a , b ) => order [ a ] - order [ b ] ) ;
1846
-
1847
- // Simplified conditions
1848
- if ( first === "men's" && second === "women's" ) {
1849
- leagueText += 'MIXED' ;
1850
- } else if ( first === "men's" && second === 'open' ) {
1851
- leagueText += "INCLUSIVE MEN'S" ;
1852
- } else if ( first === "women's" && second === 'open' ) {
1853
- leagueText += "INCLUSIVE WOMEN'S" ;
1874
+ // Default text if no filters are selected
1875
+ if ( leagueText === '' ) {
1876
+ leagueText = 'ULTIMATE' ;
1854
1877
}
1855
- }
1856
1878
1857
- // Default text if no filters are selected
1858
- if ( leagueText === '' ) {
1859
- leagueText = 'ULTIMATE' ;
1879
+ leagueText += " LEAGUE" ;
1860
1880
}
1861
1881
1862
- leagueText += " LEAGUE" ;
1863
-
1864
1882
// Update the text content of the collapsed-title element
1865
1883
const collapsedTitle = document . querySelector ( '.collapsed-title' ) ;
1866
1884
if ( collapsedTitle ) {
@@ -1871,11 +1889,12 @@ <h3>Proofs</h3>
1871
1889
displayNoResults ( tableRows , podiumItems , query ) ;
1872
1890
1873
1891
// Hide podium athletes' rows if no filters/search are applied and includePodiumGlobal is true
1874
- if ( includePodiumGlobal && selectedDivisions . length === 0 && selectedGenerations . length === 0 && uniqueSearchTerms . length === 0 ) {
1892
+ if ( includePodiumGlobal && selectedDivisions . length === 0 && selectedGenerations . length === 0 && selectedExclusiveLeagues . length === 0 && uniqueSearchTerms . length === 0 ) {
1875
1893
document . querySelectorAll ( '.leaderboard table tbody tr.podium-athlete' ) . forEach ( row => {
1876
1894
row . style . display = 'none' ;
1877
1895
} ) ;
1878
1896
}
1897
+
1879
1898
}
1880
1899
1881
1900
function updateFilterCounts ( filteredAthletes ) {
@@ -2164,7 +2183,32 @@ <h3>Proofs</h3>
2164
2183
} ) ;
2165
2184
}
2166
2185
} ) ;
2186
+ }
2187
+
2188
+ function generateExclusiveFilters ( athletes ) {
2189
+ const filterSection = document . querySelector ( '#exclusive-filter-section ul' ) ;
2190
+ filterSection . innerHTML = '' ; // Clear existing filters if any
2191
+
2192
+ const prosperanCount = athletes . reduce ( ( count , athlete ) => {
2193
+ return athlete . exclusiveLeague === "Prosperan" ? count + 1 : count ;
2194
+ } , 0 ) ;
2195
+
2196
+ if ( prosperanCount > 0 ) {
2197
+ const li = document . createElement ( 'li' ) ;
2198
+ li . innerHTML = `
2199
+ <label data-exclusive-league="Prosperan">
2200
+ <input type="checkbox" name="exclusiveLeague" value="Prosperan">
2201
+ 🏝️ Prosperan (<span class="filter-count">${ prosperanCount } </span>)
2202
+ </label>
2203
+ ` ;
2204
+ filterSection . appendChild ( li ) ;
2167
2205
2206
+ const input = li . querySelector ( 'input[type="checkbox"]' ) ;
2207
+ input . addEventListener ( 'change' , function ( event ) {
2208
+ event . stopPropagation ( ) ; // Prevent this event from affecting the sidebar toggle
2209
+ performFilter ( ) ;
2210
+ } ) ;
2211
+ }
2168
2212
}
2169
2213
2170
2214
function getGeneration ( birthYear ) {
0 commit comments