diff --git a/files/assets/js/casino/game_screen.js b/files/assets/js/casino/game_screen.js
index 2271efe96..4aff946cc 100644
--- a/files/assets/js/casino/game_screen.js
+++ b/files/assets/js/casino/game_screen.js
@@ -12,15 +12,15 @@ function initializeGame() {
function updatePlayerCurrencies(updated) {
if (updated.coins) {
- document.getElementById("user-coins-amount").textContent = updated.coins;
- document.getElementById("user-coins-amount-mobile").textContent = updated.coins;
- document.getElementById("user-coins-amount-casino").textContent = updated.coins;
+ document.getElementById("user-coins-amount").textContent = formatter.format(updated.coins);
+ document.getElementById("user-coins-amount-mobile").textContent = formatter.format(updated.coins);
+ document.getElementById("user-coins-amount-casino").textContent = formatter.format(updated.coins);
}
if (updated.marseybux) {
- document.getElementById("user-bux-amount").textContent = updated.marseybux;
- document.getElementById("user-bux-amount-mobile").textContent = updated.marseybux;
- document.getElementById("user-bux-amount-casino").textContent = updated.marseybux;
+ document.getElementById("user-bux-amount").textContent = formatter.format(updated.marseybux);
+ document.getElementById("user-bux-amount-mobile").textContent = formatter.format(updated.marseybux);
+ document.getElementById("user-bux-amount-casino").textContent = formatter.format(updated.marseybux);
}
}
diff --git a/files/assets/js/core.js b/files/assets/js/core.js
index a42a24b4e..94cb3094b 100644
--- a/files/assets/js/core.js
+++ b/files/assets/js/core.js
@@ -796,3 +796,9 @@ function toggleElement(id, id2) {
document.getElementById(id).classList.toggle('d-none');
document.getElementById(id2).focus()
}
+
+const formatter = new Intl.NumberFormat('en-US');
+function change_currency(id, amount) {
+ const el = document.getElementById(id)
+ el.textContent = formatter.format(parseInt(el.textContent.replaceAll(',', '')) + amount);
+}
diff --git a/files/assets/js/userpage_v.js b/files/assets/js/userpage_v.js
index 22188fe84..749ffedbe 100644
--- a/files/assets/js/userpage_v.js
+++ b/files/assets/js/userpage_v.js
@@ -29,11 +29,10 @@ function transferCoins(t, mobile=false) {
"reason": document.getElementById(mobile ? "coin-transfer-reason-mobile" : "coin-transfer-reason").value
},
() => {
- const newcoins = parseInt(document.getElementById("user-coins-amount").textContent) - amount;
- document.getElementById("user-coins-amount").textContent = newcoins;
- document.getElementById("user-coins-amount-mobile").textContent = newcoins;
- document.getElementById("profile-coins-amount-mobile").textContent = parseInt(document.getElementById("profile-coins-amount-mobile").textContent) + transferred;
- document.getElementById("profile-coins-amount").textContent = parseInt(document.getElementById("profile-coins-amount").textContent) + transferred;
+ change_currency("user-coins-amount", -amount)
+ change_currency("user-coins-amount-mobile", -amount)
+ change_currency("profile-coins-amount", amount)
+ change_currency("profile-coins-amount-mobile", amount)
}
);
}
@@ -54,11 +53,10 @@ function transferBux(t, mobile=false) {
"reason": document.getElementById(mobile ? "bux-transfer-reason-mobile" : "bux-transfer-reason").value
},
() => {
- const newbux = parseInt(document.getElementById("user-bux-amount").textContent) - amount;
- document.getElementById("user-bux-amount").textContent = newbux;
- document.getElementById("user-bux-amount-mobile").textContent = newbux;
- document.getElementById("profile-bux-amount-mobile").textContent = parseInt(document.getElementById("profile-bux-amount-mobile").textContent) + amount;
- document.getElementById("profile-bux-amount").textContent = parseInt(document.getElementById("profile-bux-amount").textContent) + amount;
+ change_currency("user-bux-amount", -amount)
+ change_currency("user-bux-amount-mobile", -amount)
+ change_currency("profile-bux-amount", amount)
+ change_currency("profile-bux-amount-mobile", amount)
}
);
}
diff --git a/files/templates/casino/game_screen.html b/files/templates/casino/game_screen.html
index a24630b67..5c141a12d 100644
--- a/files/templates/casino/game_screen.html
+++ b/files/templates/casino/game_screen.html
@@ -46,7 +46,7 @@
- {{v.coins}}
+ {{v.coins|commas}}
@@ -56,7 +56,7 @@
- {{v.marseybux}}
+ {{v.marseybux|commas}}
diff --git a/files/templates/header.html b/files/templates/header.html
index 16046ff4a..a3249a3d5 100644
--- a/files/templates/header.html
+++ b/files/templates/header.html
@@ -341,9 +341,9 @@