fix award modal

pull/83/head
Aevann 2022-12-30 17:16:49 +02:00
parent 3bdfa2b13f
commit 7141eafdf5
3 changed files with 9 additions and 6 deletions

View File

@ -91,15 +91,15 @@ function vote(type, id, dir) {
xhr[0].send(xhr[1]);
}
function pick(kind, canbuy1, canbuy2) {
function pick(kind, price, coins, marseybux) {
const buy1 = document.getElementById('buy1')
if (canbuy1 && kind != "grass")
if (coins >= price && kind != "grass")
buy1.disabled=false;
else
buy1.disabled=true;
const buy2 = document.getElementById('buy2')
if (canbuy2 && kind != "benefactor")
if (marseybux >= price && kind != "benefactor")
buy2.disabled=false;
else
buy2.disabled=true;

View File

@ -28,8 +28,6 @@ document.addEventListener("click", function(e){
insertGIF(e.target.src);
else if (element.classList.contains('gif-cat-overlay'))
searchGifs(e.target.firstElementChild.innerHTML);
else if (element.dataset.onclick)
execute(element, 'onclick');
else if (element.dataset.href)
location.href = element.dataset.href;
@ -38,6 +36,11 @@ document.addEventListener("click", function(e){
}
});
const onclick = document.querySelectorAll('[data-onclick]');
for (const element of onclick) {
element.onclick = ()=>{execute(element, 'onclick')};
}
const oninput = document.querySelectorAll('[data-oninput]');
for (const element of oninput) {
element.oninput = ()=>{execute(element, 'oninput')};

View File

@ -12,7 +12,7 @@
<div id="awardModalBody" class="modal-body mb-3">
<div class="awards-wrapper" style="text-align:center">
{% for award in v.user_awards %}
<div data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{award.description}}" id="{{award.kind}}" data-nonce="{{g.nonce}}" data-onclick="pick('{{award.kind}}', {{award.price}}*{{v.discount}} <= {{v.marseybux}}, {{award.price}}*{{v.discount}} <= {{v.coins}})">
<div data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{award.description}}" id="{{award.kind}}" data-nonce="{{g.nonce}}" data-onclick="pick('{{award.kind}}', {{(award.price*v.discount)|int}}, {{v.coins}}, {{v.marseybux}})">
<i class="{{award.icon}} {{award.color}}"></i>
<div class="pt-1 award-name">{{award.title}}</div>
<div class="text-muted award-owned"><span id="{{award.kind}}-owned">{{award.owned}}</span> owned</div>