add commas for coins and mbux

master
Aevann 2024-04-09 16:44:01 +02:00
parent e378e6cf07
commit 0fe765c391
7 changed files with 31 additions and 27 deletions

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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)
}
);
}

View File

@ -46,7 +46,7 @@
<img id="wagerCoinsImg" loading="lazy" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8" alt="coin" data-bs-toggle="tooltip"
data-bs-placement="bottom" title="Coin">
</label>
<span id="user-coins-amount-casino">{{v.coins}}</span>
<span id="user-coins-amount-casino">{{v.coins|commas}}</span>
</span>
<span class="unbreakable">
@ -56,7 +56,7 @@
<img id="wagerMarseybuxImg" loading="lazy" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8" alt="marseybux" data-bs-toggle="tooltip"
data-bs-placement="bottom" title="Marseybux">
</label>
<span id="user-bux-amount-casino">{{v.marseybux}}</span>
<span id="user-bux-amount-casino">{{v.marseybux|commas}}</span>
</span>
</div>
</div>

View File

@ -341,9 +341,9 @@
</div>
<div class="text-left pl-2" id="header--username--outerdiv">
<div style="color: #{{v.name_color}}" class="text-small font-weight-bold"><span id="header--username" {% if v.patron %}class="patron" style="background-color:#{{v.name_color}}"{% endif %} {% if v.pride_username(v) %}pride_username{% endif %}>{{v.username}}</span></div>
<div class="header--currency"><img loading="lazy" alt="coins" class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8" title="Coins"><span id="user-coins-amount">{{v.coins}}</span>{% if not FEATURES['MARSEYBUX'] %} Coin{{macros.plural(v.coins)}}{% endif %}</div>
<div class="header--currency"><img loading="lazy" alt="coins" class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8" title="Coins"><span id="user-coins-amount">{{v.coins|commas}}</span>{% if not FEATURES['MARSEYBUX'] %} Coin{{macros.plural(v.coins)}}{% endif %}</div>
{% if FEATURES['MARSEYBUX'] %}
<div class="header--currency"><img loading="lazy" alt="marseybux" class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8" title="Marseybux"><span id="user-bux-amount">{{v.marseybux}}</span></div>
<div class="header--currency"><img loading="lazy" alt="marseybux" class="mr-1 ml-1" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8" title="Marseybux"><span id="user-bux-amount">{{v.marseybux|commas}}</span></div>
{% endif %}
</div>
</div>
@ -420,12 +420,12 @@
<li class="nav-item">
<div class="header--currency ml-2 pl-1 my-2">
<img loading="lazy" alt="coins" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8" title="Coins">
<span id="user-coins-amount-mobile">{{v.coins}}</span>
<span id="user-coins-amount-mobile">{{v.coins|commas}}</span>
</div>
{% if FEATURES['MARSEYBUX'] %}
<div class="header--currency">
<img loading="lazy" alt="marseybux" class="ml-3" data-bs-toggle="tooltip" data-bs-placement="bottom" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8" title="Marseybux">
<span id="user-bux-amount-mobile">{{v.marseybux}}</span>
<span id="user-bux-amount-mobile">{{v.marseybux|commas}}</span>
</div>
{% endif %}
</li>

View File

@ -106,11 +106,11 @@
<a class="mx-1" href="/@{{u.username}}/muting" id="profile--muting">mutes {{u.mute_count}} user{{'s' if u.mute_count != 1 else ''}}</a>
</div>
<span id="profile-coins-amount">{{u.coins}}</span>
<span id="profile-coins-amount">{{u.coins|commas}}</span>
<img loading="lazy" alt="coins" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Coins" height="20" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8">
{% if FEATURES['MARSEYBUX'] %}
<span id="profile-bux-amount">{{u.marseybux}}</span>
<span id="profile-bux-amount">{{u.marseybux|commas}}</span>
<img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="20" width="46" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8">
{% endif %}
</div>
@ -421,11 +421,11 @@
<a class="mx-1" href="/@{{u.username}}/muting" id="profile-mobile--muting">mutes {{u.mute_count}} user{{'s' if u.mute_count != 1 else ''}}</a>
</div>
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins}}</span>
<span id="profile-coins-amount-mobile" class="font-weight-bold">{{u.coins|commas}}</span>
<img loading="lazy" alt="coins" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Coins" height="15" src="{{SITE_FULL_IMAGES}}/i/coins.webp?x=8">
{% if FEATURES['MARSEYBUX'] %}
<span id="profile-bux-amount-mobile" class="font-weight-bold">{{u.marseybux}}</span>
<span id="profile-bux-amount-mobile" class="font-weight-bold">{{u.marseybux|commas}}</span>
<img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="15" width="35" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=8">
{% endif %}

View File

@ -43,7 +43,7 @@
u.username ~ "'s profile" %}
{% set description %}
{{u.coins}} coins - Joined {{u.created_date}} -
{{u.coins|commas}} coins - Joined {{u.created_date}} -
{%- if u.stored_subscriber_count >=1 and not u.is_private -%}
{{u.stored_subscriber_count}} Followers -
{%- endif -%}