Optimize all modals (fetching). Implement add-player modal.
This commit is contained in:
@@ -45,24 +45,29 @@
|
||||
"Content-type": "application/json; charset=UTF-8"
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
const clanToRemove = clanList.children[clanList.selectedIndex];
|
||||
const clanIndex = clanToRemove.index;
|
||||
clanList.removeChild(clanToRemove);
|
||||
clanList.selectedIndex = 0;
|
||||
clanList.dispatchEvent(new Event('change'));
|
||||
.then(() => {
|
||||
fetch('/clans_html')
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(data => {
|
||||
clanList.innerHTML = data;
|
||||
otherClanList.innerHTML = data;
|
||||
|
||||
const lastOtherIndex = otherClanList.selectedIndex;
|
||||
otherClanList.children.item(clanIndex).remove();
|
||||
if (lastOtherIndex === clanIndex) {
|
||||
otherClanList.selectedIndex = 0;
|
||||
clanList.dispatchEvent(new Event('change'));
|
||||
otherClanList.dispatchEvent(new Event('change'));
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There has been a problem with your fetch operation:', error);
|
||||
});
|
||||
|
||||
deleteClanModalBS.hide();
|
||||
} else
|
||||
throw new Error(response.error)
|
||||
deleteClanModalBS.hide();
|
||||
})
|
||||
.catch((error) => {
|
||||
throw new Error(error)
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user