forked from rDrama/rDrama
1
0
Fork 0

remove isShopConfirm exception

master
Aevann 2023-08-10 18:59:40 +03:00
parent 8a2f593186
commit 4a4f709c63
1 changed files with 2 additions and 12 deletions

View File

@ -35,14 +35,6 @@ function createXhrWithFormKey(url, method="POST", form=new FormData()) {
} }
function postToast(t, url, data, extraActionsOnSuccess, method="POST") { function postToast(t, url, data, extraActionsOnSuccess, method="POST") {
const isShopConfirm = t.id.startsWith('buy-') || t.id.startsWith('giveaward')
if (!isShopConfirm)
{
t.disabled = true;
t.classList.add("disabled");
}
let form = new FormData(); let form = new FormData();
if (typeof data === 'object' && data !== null) { if (typeof data === 'object' && data !== null) {
for(let k of Object.keys(data)) { for(let k of Object.keys(data)) {
@ -51,6 +43,8 @@ function postToast(t, url, data, extraActionsOnSuccess, method="POST") {
} }
const xhr = createXhrWithFormKey(url, method, form); const xhr = createXhrWithFormKey(url, method, form);
xhr[0].onload = function() { xhr[0].onload = function() {
t.disabled = false;
t.classList.remove("disabled");
let result let result
let message; let message;
let success = xhr[0].status >= 200 && xhr[0].status < 300; let success = xhr[0].status >= 200 && xhr[0].status < 300;
@ -62,10 +56,6 @@ function postToast(t, url, data, extraActionsOnSuccess, method="POST") {
let oldToast = bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-' + (success ? 'error': 'success'))); // intentionally reversed here: this is the old toast let oldToast = bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-' + (success ? 'error': 'success'))); // intentionally reversed here: this is the old toast
oldToast.hide(); oldToast.hide();
showToast(success, message); showToast(success, message);
if (!isShopConfirm) {
t.disabled = false;
t.classList.remove("disabled");
}
if (success && extraActionsOnSuccess) result = extraActionsOnSuccess(xhr[0]); if (success && extraActionsOnSuccess) result = extraActionsOnSuccess(xhr[0]);
return success; return success;
}; };