feat: allow n Teams

This commit is contained in:
eneller
2024-07-10 16:57:13 +02:00
parent 1073603350
commit 807a142b6d
3 changed files with 26 additions and 3 deletions

View File

@@ -2,9 +2,12 @@
function randomizeTeams() {
let teamCount = 2;
if(document.getElementById("threeTeams").checked == true){
if(document.getElementById("threeTeams").checked){
teamCount = 3;
}
if(document.getElementById("nTeams").checked){
teamCount = document.getElementById("nTeamsTextField").value;
}
const outputField = document.getElementById("teamOutput");
let textinput = document.getElementById("playerNames").value;
let names = textinput.split('\n').map(function(str){return str.trim();});
@@ -43,4 +46,16 @@ function* iter(list){
yield list[index % list.length];
index++;
}
}
}
function textchangelistener(){
let elem = document.getElementById("nTeamsTextField");
if(this.checked && this.id == "nTeams"){
elem.style.display = "block";
}
else {
elem.style.display = "none";
}
}
buttons = document.querySelectorAll("input[type='radio']");
buttons.forEach((x) => x.addEventListener("change", textchangelistener));