diff --git a/files/assets/js/bottom.js b/files/assets/js/bottom.js index d7a753495..21869aa07 100644 --- a/files/assets/js/bottom.js +++ b/files/assets/js/bottom.js @@ -102,31 +102,6 @@ for (const element of TH) { element.addEventListener('click', () => {sort_table(element)}); } -const btns_to_disable = document.querySelectorAll('[type="submit"]') -for (const element of btns_to_disable) { - if (!element.classList.contains("donotdisable")) - element.addEventListener('click', () => {disable_btn(element)}) -} - -function disable_btn(t) { - if (!t.classList.contains('disabled')) { - const isShopConfirm = t.id.startsWith('buy-') || t.id.startsWith('giveaward') - - if (!isShopConfirm) { - t.classList.add('disabled'); - - setTimeout(() => { - t.disabled = true; - }, 0.1); - - setTimeout(() => { - t.classList.remove("disabled"); - t.disabled = false; - }, 2000); - } - } -} - function register_new_elements(e) { const oninput = e.querySelectorAll('[data-oninput]'); for (const element of oninput) { diff --git a/files/assets/js/core.js b/files/assets/js/core.js index bd032bd10..7f8a6dd92 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -291,6 +291,10 @@ function prepare_to_pause(audio) { } function sendFormXHR(form, extraActionsOnSuccess) { + const submit_btn = form.querySelector('[type="submit"]') + submit_btn.disabled = true; + submit_btn.classList.add("disabled"); + const xhr = new XMLHttpRequest(); formData = new FormData(form); @@ -318,6 +322,8 @@ function sendFormXHR(form, extraActionsOnSuccess) { bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } } + submit_btn.disabled = false; + submit_btn.classList.remove("disabled"); }; xhr.send(formData);