Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Fix divisions' cutoff
Browse files Browse the repository at this point in the history
  • Loading branch information
marqdevx authored Jan 20, 2023
1 parent c9141e4 commit cc55951
Showing 1 changed file with 104 additions and 17 deletions.
121 changes: 104 additions & 17 deletions esea-league-filter-bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ javascript: (() => {
flagOptions.add(newOption);
}


function addFlag(indexTeam) {
flagOptions = flagBox.childNodes[0].childNodes[0];

Expand All @@ -40,6 +41,107 @@ javascript: (() => {
}
}

function largeCutOff(teamsSize) {
let newCuttOff = 0;
switch (true) {
case (teamsSize < 17):
newCuttOff = 8;
break;
case (teamsSize >= 17 && teamsSize < 24):
newCuttOff = 8;
break;
case (teamsSize >= 24 && teamsSize < 32):
newCuttOff = 12;
break;
case (teamsSize >= 32 && teamsSize < 48):
newCuttOff = 16;
break;
case (teamsSize >= 48 && teamsSize < 64):
newCuttOff = 24;
break;
case (teamsSize >= 64 && teamsSize < 96):
newCuttOff = 32;
break;
case (teamsSize >= 96 && teamsSize < 128):
newCuttOff = 48;
break;
case (teamsSize >= 128 && teamsSize < 192):
newCuttOff = 64;
break;
case (teamsSize >= 192 && teamsSize < 256):
newCuttOff = 96;
break;
case (teamsSize >= 256 && teamsSize < 384):
newCuttOff = 128;
break;
case (teamsSize >= 384 && teamsSize < 512):
newCuttOff = 192;
break;
case (teamsSize >= 512 && teamsSize < 768):
newCuttOff = 256;
break;
case (teamsSize >= 768 && teamsSize < 1024):
newCuttOff = 384;
break;
default:
newCuttOff = 4;
break;
}
return newCuttOff;
}

function smallCutOff(teamsSize) {
let newCuttOff = 0;
switch (true) {
case (teamsSize < 48):
newCuttOff = 8;
break;
case (teamsSize >= 48 && teamsSize < 64):
newCuttOff = 16;
break;
case (teamsSize >= 64 && teamsSize < 96):
newCuttOff = 24;
break;
case (teamsSize >= 96 && teamsSize < 128):
newCuttOff = 32;
break;
case (teamsSize >= 128 && teamsSize < 192):
newCuttOff = 48;
break;
case (teamsSize >= 192 && teamsSize < 255):
newCuttOff = 64;
break;
default:
newCuttOff = 4;
break;
}
return newCuttOff;
}

function getCutOff() {

let cutOffValue = 0;
let teamsSize = teamList.length - 1;
switch (division) {
case "open":
cutOffValue = largeCutOff(teamsSize);
break;
case "intermediate":
cutOffValue = largeCutOff(teamsSize);
break;
case "main":
cutOffValue = smallCutOff(teamsSize);
break;
case "advanced":
cutOffValue = smallCutOff(teamsSize);
break;
}
console.log("Division: " + division);
console.log("Teams: " + teamsSize);
console.log("Cutoff: " + cutOffValue);
return cutOffValue;
}

function filter() {
let flagBoxFilter = document.getElementById("flag");
let country = flagBoxFilter.value;
Expand All @@ -59,6 +161,8 @@ javascript: (() => {
}

division = document.getElementById("level").value;
seasonStage = document.getElementById("round").value;
let cutOff = getCutOff();

for (let i = 0; i < qeuedCount; i++) {
targetTeam = qeuedTeams[i];
Expand All @@ -67,22 +171,6 @@ javascript: (() => {

ranking = targetTeam.childNodes[0].textContent.slice(0, targetTeam.childNodes[0].textContent.length - 1);

let cutOff = 0;
switch (division) {
case "open":
cutOff = 192;
break;
case "intermediate":
cutOff = 64;
break;
case "main":
cutOff = 48;
break;
case "advanced":
cutOff = 32;
break;

}
if (ranking <= cutOff) {
targetTeam.childNodes[0].style.backgroundColor = "green";
} else {
Expand All @@ -102,7 +190,6 @@ javascript: (() => {

regionBox.parentElement.parentElement.parentElement.append(flagBox);
}

showSelectorButton();
indexFlags();
filter();
Expand Down

0 comments on commit cc55951

Please sign in to comment.