Optimize all modals (fetching). Implement add-player modal.

This commit is contained in:
MaxJa4
2024-01-16 20:19:40 +01:00
parent 8c4ed63359
commit fc084108ac
13 changed files with 134 additions and 91 deletions

View File

@@ -81,18 +81,35 @@
"Content-type": "application/json; charset=UTF-8"
}
})
.then((response) => {
if (response.ok) {
const newName = "[" + clanTag.value + "]" + " " + clanName.value;
selectedClanItem.innerText = newName;
otherSelClanItem.innerText = newName;
.then(() => {
const lastIndex = clanList.selectedIndex;
const otherLastIndex = otherClanList.selectedIndex;
editClanModalBS.hide();
clanName.value = "";
clanTag.value = "";
keepUpdated.checked = false;
} else
throw new Error(response.error)
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;
clanList.selectedIndex = lastIndex;
otherClanList.selectedIndex = otherLastIndex;
})
.catch(error => {
console.error('There has been a problem with your fetch operation:', error);
});
editClanModalBS.hide();
clanName.value = "";
clanTag.value = "";
keepUpdated.checked = false;
})
.catch((error) => {
throw new Error(error)
});
})
});