diff --git a/static/index.js b/static/index.js index d4bdf3f..c697a7b 100644 --- a/static/index.js +++ b/static/index.js @@ -94,3 +94,38 @@ function loadClans() { console.error('There has been a problem with your fetch operation:', error); }); } + +function updateSelectedPlayers(sender) { + const playerList = sender.parentElement.parentElement.parentElement; + const checkCounter = playerList.parentElement.parentElement.querySelector('span.badge'); + let counter = 0; + + Array.from(playerList.children).forEach(p => { + if (p.querySelector('input[type="checkbox"]:checked')) + counter++; + }); + + checkCounter.innerText = counter; +} + +function selectAllPlayers(playerListId) { + const playerList = document.getElementById(playerListId); + const checkCounter = playerList.parentElement.parentElement.querySelector('span.badge'); + + Array.from(playerList.children).forEach(p => { + p.querySelector('input[type="checkbox"]').checked = true; + }); + + checkCounter.innerText = playerList.children.length; +} + +function deselectAllPlayers(playerListId) { + const playerList = document.getElementById(playerListId); + const checkCounter = playerList.parentElement.parentElement.querySelector('span.badge'); + + Array.from(playerList.children).forEach(p => { + p.querySelector('input[type="checkbox"]').checked = false; + }); + + checkCounter.innerText = 0; +} \ No newline at end of file diff --git a/templates/components/home_player_list.html b/templates/components/home_player_list.html index cc35f48..31b063b 100644 --- a/templates/components/home_player_list.html +++ b/templates/components/home_player_list.html @@ -8,8 +8,8 @@