Optimize all modals (fetching). Implement add-player modal.
This commit is contained in:
@@ -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)
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user