From 457acd43cb09713fb0839e007cb38b4615a54d5c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 19 Oct 2022 19:54:18 +0200 Subject: [PATCH] decrease the number of owned awards when u give one --- files/assets/js/award_modal.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/files/assets/js/award_modal.js b/files/assets/js/award_modal.js index e51c60c40..1d7438e0a 100644 --- a/files/assets/js/award_modal.js +++ b/files/assets/js/award_modal.js @@ -152,10 +152,18 @@ function buy(mb) { } function giveaward(t) { + const kind = document.getElementById('kind').value; post_toast_callback(t.dataset.action, { - "kind": document.getElementById('kind').value, + "kind": kind, "note": document.getElementById('note').value - } + }, + (xhr) => { + if(xhr.status == 200) { + let owned = document.getElementById(`${kind}-owned`) + let ownednum = Number(owned.textContent); + owned.textContent = ownednum - 1 + } + } ); }