Skip to content

Commit 6b2ab0d

Browse files
committed
implement prosperan league
1 parent b9b20c7 commit 6b2ab0d

File tree

2 files changed

+123
-76
lines changed

2 files changed

+123
-76
lines changed

LongevityWorldCup.Website/Data/Athletes.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"Proofs": [
2929
"/assets/proofs/jesse_proof_1.png"
3030
],
31-
"PersonalLink": "https://x.com/jesse_pariselli"
31+
"PersonalLink": "https://x.com/jesse_pariselli",
32+
"ExclusiveLeague": "Prosperan"
3233
},
3334
{
3435
"Name": "Spiderius",
@@ -59,7 +60,8 @@
5960
"Proofs": [
6061
"/assets/proofs/spiderius_proof_1.png"
6162
],
62-
"PersonalLink": "https://davidstancel.com"
63+
"PersonalLink": "https://davidstancel.com",
64+
"ExclusiveLeague": "Prosperan"
6365
},
6466
{
6567
"Name": "Cody Hergenroeder",
@@ -90,7 +92,8 @@
9092
"Proofs": [
9193
"/assets/proofs/cody_hergenroeder_proof_1.png"
9294
],
93-
"PersonalLink": null
95+
"PersonalLink": null,
96+
"ExclusiveLeague": "Prosperan"
9497
},
9598
{
9699
"Name": "Alan V",

LongevityWorldCup.Website/wwwroot/partials/leaderboard-content.html

+117-73
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,10 @@ <h3>Divisions</h3>
10011001
<h3>Generations</h3>
10021002
<ul></ul> <!-- This will be populated dynamically -->
10031003
</div>
1004+
<div class="filter-section" id="exclusive-filter-section">
1005+
<h3>Exclusive</h3>
1006+
<ul></ul> <!-- This will be populated dynamically -->
1007+
</div>
10041008
</div>
10051009
<table>
10061010
<thead>
@@ -1165,13 +1169,14 @@ <h3>Proofs</h3>
11651169
personalLink: athlete.PersonalLink,
11661170
profilePic: athlete.ProfilePic,
11671171
division: athlete.Division,
1168-
generation: generation
1172+
generation: generation,
1173+
exclusiveLeague: athlete.ExclusiveLeague
11691174
};
1170-
11711175
});
11721176

11731177
generateDivisionFilters(athleteResults);
11741178
generateGenerationFilters(athleteResults);
1179+
generateExclusiveFilters(athleteResults);
11751180

11761181
// Sort the athletes by age reduction in ascending order
11771182
athleteResults.sort(compareAthleteRank);
@@ -1664,6 +1669,10 @@ <h3>Proofs</h3>
16641669
const selectedGenerations = Array.from(document.querySelectorAll('input[name="generation"]:checked'))
16651670
.map(checkbox => checkbox.value.toLowerCase());
16661671

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+
16671676
const query = normalizeString(document.getElementById('athleteSearch').value.trim().toLowerCase());
16681677
const searchTerms = query.split(/\s+/).filter(term => term.length > 0);
16691678
const uniqueSearchTerms = [...new Set(searchTerms)];
@@ -1687,6 +1696,11 @@ <h3>Proofs</h3>
16871696
matches = matches && selectedGenerations.includes(athlete.generation.toLowerCase());
16881697
}
16891698

1699+
// Check exclusive league match
1700+
if (selectedExclusiveLeagues.length > 0) {
1701+
matches = matches && selectedExclusiveLeagues.includes((athlete.exclusiveLeague || "").toLowerCase());
1702+
}
1703+
16901704
// Check search terms
16911705
if (matches && !showAll) {
16921706
matches = uniqueSearchTerms.every(term => athleteNameNormalized.includes(term));
@@ -1700,7 +1714,7 @@ <h3>Proofs</h3>
17001714
filteredAthletes = filteredAthletes.slice(0, maxAthletesGlobal);
17011715

17021716
// 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;
17041718
const searchUsed = uniqueSearchTerms.length > 0;
17051719

17061720
// If filters are used, reassign ranks starting from 1
@@ -1785,82 +1799,86 @@ <h3>Proofs</h3>
17851799
// Update the collapsed-title text based on selected filters
17861800
let leagueText = '';
17871801

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
18321847
}
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+
}
18371872
}
18381873

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';
18541877
}
1855-
}
18561878

1857-
// Default text if no filters are selected
1858-
if (leagueText === '') {
1859-
leagueText = 'ULTIMATE';
1879+
leagueText += " LEAGUE";
18601880
}
18611881

1862-
leagueText += " LEAGUE";
1863-
18641882
// Update the text content of the collapsed-title element
18651883
const collapsedTitle = document.querySelector('.collapsed-title');
18661884
if (collapsedTitle) {
@@ -1871,11 +1889,12 @@ <h3>Proofs</h3>
18711889
displayNoResults(tableRows, podiumItems, query);
18721890

18731891
// 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) {
18751893
document.querySelectorAll('.leaderboard table tbody tr.podium-athlete').forEach(row => {
18761894
row.style.display = 'none';
18771895
});
18781896
}
1897+
18791898
}
18801899

18811900
function updateFilterCounts(filteredAthletes) {
@@ -2164,7 +2183,32 @@ <h3>Proofs</h3>
21642183
});
21652184
}
21662185
});
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);
21672205

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+
}
21682212
}
21692213

21702214
function getGeneration(birthYear) {

0 commit comments

Comments
 (0)