Add add-player modal and player bar button setup.
This commit is contained in:
@@ -9,6 +9,24 @@ function setupClanButtons(dropdownId, delBtnId, editBtnId) {
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -22,4 +40,33 @@ function getClanLists(event) {
|
||||
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];
|
||||
}
|
||||
Reference in New Issue
Block a user