function setupClanButtons(dropdownId, delBtnId, editBtnId) { const dropdown = document.getElementById(dropdownId); const deleteButton = document.getElementById(delBtnId); const editButton = document.getElementById(editBtnId); dropdown.addEventListener('change', function () { deleteButton.disabled = !this.value; editButton.disabled = !this.value; }); } function setupPlayerButtons(dropdownId, listId, delBtnId, editBtnId, addBtnId) { const dropdown = document.getElementById(dropdownId); const deleteButton = document.getElementById(delBtnId); const editButton = document.getElementById(editBtnId); const addButton = document.getElementById(addBtnId); dropdown.addEventListener('change', function () { deleteButton.disabled = !this.value; editButton.disabled = !this.value && (dropdown.selectedIndex !== -1); addButton.disabled = !this.value && (dropdown.selectedIndex !== -1); }); dropdown.addEventListener('change', function () { deleteButton.disabled = (this.selectedIndex !== -1); editButton.disabled = (this.selectedIndex !== -1); }); } function getClanLists(event) { const button = event.relatedTarget; const clanListId = button.getAttribute('data-bs-list'); const clanList = document.querySelector(clanListId); let otherClanListId; if (clanListId === '#home-clan') otherClanListId = '#opponent-clan' else otherClanListId = '#home-clan' const otherClanList = document.querySelector(otherClanListId); return [clanList, otherClanList]; } function getPlayerLists(event) { const button = event.relatedTarget; const playerListId = button.getAttribute('data-bs-list'); const playerList = document.querySelector(playerListId); let otherPlayerListId; if (playerListId === '#home-player-list') otherPlayerListId = '#opponent-player-list' else otherPlayerListId = '#home-player-list' const otherPlayerList = document.querySelector(otherPlayerListId); return [playerList, otherPlayerList]; } function getSelectedClan(event) { const button = event.relatedTarget; const playerListId = button.getAttribute('data-bs-list'); let clanListId; if (playerListId === '#home-player-list') clanListId = '#home-clan' else clanListId = '#opponent-clan' const clanList = document.querySelector(clanListId); return clanList.options[clanList.selectedIndex]; }