From d99c77cba9aad6c8dee6286ae8084b66342ba78a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 6 Aug 2022 04:03:10 +0200 Subject: [PATCH] add confirmation dialog to buying awards --- files/assets/js/award_modal.js | 32 ++++++++++++++++++++++------ files/assets/js/bootstrap.js | 18 ++++++++++------ files/templates/award_modal.html | 8 +++++-- files/templates/shop.html | 20 +++++++++++------ files/templates/util/assetcache.html | 4 ++-- 5 files changed, 60 insertions(+), 22 deletions(-) diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index 67615f80c..0f94c9930 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -104,12 +104,32 @@ function vote(type, id, dir, vid) { } function pick(kind, canbuy1, canbuy2) { - let buy1 = document.getElementById('buy1') - if (canbuy1 && kind != "grass") buy1.disabled=false; - else buy1.disabled=true; - let buy2 = document.getElementById('buy2') - if (canbuy2 && kind != "benefactor") buy2.disabled=false; - else buy2.disabled=true; + const buy1 = document.getElementById('buy1') + const buy1go = document.getElementById('buy1-go') + if (canbuy1 && kind != "grass") + { + buy1.disabled=false; + buy1go.disabled=false; + } + else + { + buy1.disabled=true; + buy1go.disabled=true; + } + + const buy2 = document.getElementById('buy2') + const buy2go = document.getElementById('buy2-go') + if (canbuy2 && kind != "benefactor") + { + buy2.disabled=false; + buy2go.disabled=false; + } + else + { + buy2.disabled=true; + buy2go.disabled=true; + } + let ownednum = Number(document.getElementById(`${kind}-owned`).textContent); document.getElementById('giveaward').disabled = (ownednum == 0); document.getElementById('kind').value=kind; diff --git a/files/assets/js/bootstrap.js b/files/assets/js/bootstrap.js index fd1c5269f..32bd45875 100644 --- a/files/assets/js/bootstrap.js +++ b/files/assets/js/bootstrap.js @@ -178,8 +178,11 @@ if (document.readyState === "complete" || } function post_toast(t, url, button1, button2, classname) { - t.disabled = true; - t.classList.add("disabled"); + if (t.id != "buy1-go" && t.id != "buy2-go") + { + t.disabled = true; + t.classList.add("disabled"); + } const xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader('xhr', 'xhr'); @@ -209,10 +212,13 @@ function post_toast(t, url, button1, button2, classname) { if (data && data["error"]) document.getElementById('toast-post-error-text').innerText = data["error"]; bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-error')).show(); } - setTimeout(() => { - t.disabled = false; - t.classList.remove("disabled"); - }, 2000); + if (t.id != "buy1-go" && t.id != "buy2-go") + { + setTimeout(() => { + t.disabled = false; + t.classList.remove("disabled"); + }, 2000); + } }; xhr.send(form); diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index 47854ce41..139c752ff 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -28,8 +28,12 @@ - - + + + + + +
 					
diff --git a/files/templates/shop.html b/files/templates/shop.html index a85a69bda..405530575 100644 --- a/files/templates/shop.html +++ b/files/templates/shop.html @@ -6,10 +6,6 @@ }[SITE_NAME] -%} - - {% block title %} Shop {% endblock %} @@ -31,6 +27,12 @@ {% endblock %} {% block content %} + + {% if error %}