Implement select counter + select-all + select-none.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user