fdsfsd
parent
e90d3fa9b1
commit
bcfaad7c72
|
@ -205,7 +205,8 @@ def transfer_coins(v, username):
|
||||||
if not v.patron and not receiver.patron:
|
if not v.patron and not receiver.patron:
|
||||||
tax = math.ceil(amount*0.03)
|
tax = math.ceil(amount*0.03)
|
||||||
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
|
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
|
||||||
tax_receiver.coins += tax/3
|
if request.host == 'rdrama.net': tax_receiver.coins += tax/3
|
||||||
|
else: tax_receiver.coins += tax
|
||||||
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
|
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
|
||||||
send_notification(TAX_RECEIVER_ID, log_message)
|
send_notification(TAX_RECEIVER_ID, log_message)
|
||||||
g.db.add(tax_receiver)
|
g.db.add(tax_receiver)
|
||||||
|
|
|
@ -41,40 +41,44 @@
|
||||||
|
|
||||||
{% block desktopUserBanner %}
|
{% block desktopUserBanner %}
|
||||||
|
|
||||||
<script>
|
{% if v %}
|
||||||
const TRANSFER_TAX = 0.01;
|
<script>
|
||||||
|
const TRANSFER_TAX = {% if v.patron or u.patron %}0{% else %}0.03{% endif %};
|
||||||
|
|
||||||
function updateTax(mobile=false) {
|
function updateTax(mobile=false) {
|
||||||
let suf = mobile ? "-mobile" : "";
|
let suf = mobile ? "-mobile" : "";
|
||||||
let amount = parseInt(document.getElementById("coins-transfer-amount" + suf).value);
|
let amount = parseInt(document.getElementById("coins-transfer-amount" + suf).value);
|
||||||
if(isNaN(amount) || amount < 0) {
|
if(isNaN(amount) || amount < 0) {
|
||||||
amount = 0;
|
amount = 0;
|
||||||
|
}
|
||||||
|
document.getElementById("coins-transfer-taxed" + suf).innerText = amount - Math.ceil(amount*TRANSFER_TAX);
|
||||||
}
|
}
|
||||||
document.getElementById("coins-transfer-taxed" + suf).innerText = amount - Math.ceil(amount*TRANSFER_TAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
function transferCoins(mobile=false) {
|
function transferCoins(mobile=false) {
|
||||||
let t = event.target;
|
let t = event.target;
|
||||||
t.disabled = true;
|
t.disabled = true;
|
||||||
|
|
||||||
let amount = parseInt(document.getElementById("coins-transfer-amount").value);
|
let amount = parseInt(document.getElementById("coins-transfer-amount").value);
|
||||||
let transferred = amount - Math.ceil(amount*TRANSFER_TAX);
|
let transferred = amount - Math.ceil(amount*TRANSFER_TAX);
|
||||||
|
|
||||||
post_toast_callback("/@{{u.username}}/transfer_coins",
|
post_toast_callback("/@{{u.username}}/transfer_coins",
|
||||||
{"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value},
|
{"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value},
|
||||||
(xhr) => {
|
(xhr) => {
|
||||||
if(xhr.status == 200) {
|
if(xhr.status == 200) {
|
||||||
document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - amount;
|
document.getElementById("user-coins-amount").innerText = parseInt(document.getElementById("user-coins-amount").innerText) - amount;
|
||||||
document.getElementById("profile-coins-amount-mobile").innerText = parseInt(document.getElementById("profile-coins-amount-mobile").innerText) + transferred;
|
document.getElementById("profile-coins-amount-mobile").innerText = parseInt(document.getElementById("profile-coins-amount-mobile").innerText) + transferred;
|
||||||
document.getElementById("profile-coins-amount").innerText = parseInt(document.getElementById("profile-coins-amount").innerText) + transferred;
|
document.getElementById("profile-coins-amount").innerText = parseInt(document.getElementById("profile-coins-amount").innerText) + transferred;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(_ => t.disabled = false, 2000);
|
setTimeout(_ => t.disabled = false, 2000);
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if u.song %}
|
{% if u.song %}
|
||||||
|
<script>
|
||||||
var audio = new Audio('/songs/{{u.id}}');
|
var audio = new Audio('/songs/{{u.id}}');
|
||||||
audio.loop=true;
|
audio.loop=true;
|
||||||
|
|
||||||
|
@ -103,8 +107,8 @@
|
||||||
}, {once : true});
|
}, {once : true});
|
||||||
|
|
||||||
});
|
});
|
||||||
{% endif %}
|
</script>
|
||||||
</script>
|
{% endif %}
|
||||||
|
|
||||||
<div class="row d-none d-md-block">
|
<div class="row d-none d-md-block">
|
||||||
<div class="col px-0">
|
<div class="col px-0">
|
||||||
|
|
Loading…
Reference in New Issue