Sync both clan lists.
This commit is contained in:
@@ -37,10 +37,11 @@
|
||||
const editClanModalBS = new bootstrap.Modal('#editClanModal');
|
||||
if (editClanModal) {
|
||||
editClanModal.addEventListener('show.bs.modal', event => {
|
||||
const button = event.relatedTarget;
|
||||
const clanListId = button.getAttribute('data-bs-list');
|
||||
const clanList = document.querySelector(clanListId);
|
||||
const selectedClanItem = clanList.options[clanList.selectedIndex];
|
||||
const [clanList, otherClanList] = getClanLists(event);
|
||||
|
||||
const selectedClanIndex = clanList.selectedIndex;
|
||||
const selectedClanItem = clanList.options[selectedClanIndex];
|
||||
const otherSelClanItem = otherClanList.options[selectedClanIndex];
|
||||
|
||||
const clanName = editClanModal.querySelector('#editClanName');
|
||||
const clanTag = editClanModal.querySelector('#editClanTag');
|
||||
@@ -66,7 +67,9 @@
|
||||
throw new Error(error);
|
||||
});
|
||||
|
||||
submitButton.addEventListener('click', function () {
|
||||
submitButton.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
submitButton.onclick = function () {}
|
||||
fetch("/clan/" + clanId, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({
|
||||
@@ -80,7 +83,10 @@
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
selectedClanItem.innerText = "[" + clanTag.value + "]" + " " + clanName.value;
|
||||
const newName = "[" + clanTag.value + "]" + " " + clanName.value;
|
||||
selectedClanItem.innerText = newName;
|
||||
otherSelClanItem.innerText = newName;
|
||||
|
||||
editClanModalBS.hide();
|
||||
clanName.value = "";
|
||||
clanTag.value = "";
|
||||
|
||||
Reference in New Issue
Block a user