2022-07-16 21:00:02 +00:00
|
|
|
function toggleElement(id, id2) {
|
|
|
|
for(let el of document.getElementsByClassName('toggleable')) {
|
2023-08-06 03:33:34 +00:00
|
|
|
if (el.id != id) {
|
2022-07-16 21:00:02 +00:00
|
|
|
el.classList.add('d-none');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById(id).classList.toggle('d-none');
|
|
|
|
document.getElementById(id2).focus()
|
|
|
|
}
|
|
|
|
|
|
|
|
let TRANSFER_TAX = document.getElementById('tax').innerHTML
|
|
|
|
|
|
|
|
function updateTax(mobile=false) {
|
|
|
|
let suf = mobile ? "-mobile" : "";
|
|
|
|
let amount = parseInt(document.getElementById("coin-transfer-amount" + suf).value);
|
2023-08-06 03:33:34 +00:00
|
|
|
if (amount > 0) document.getElementById("coins-transfer-taxed" + suf).innerText = amount - Math.ceil(amount*TRANSFER_TAX);
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateBux(mobile=false) {
|
|
|
|
let suf = mobile ? "-mobile" : "";
|
|
|
|
let amount = parseInt(document.getElementById("bux-transfer-amount" + suf).value);
|
2023-08-06 03:33:34 +00:00
|
|
|
if (amount > 0) document.getElementById("bux-transfer-taxed" + suf).innerText = amount;
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
2022-11-03 19:07:08 +00:00
|
|
|
function transferCoins(t, mobile=false) {
|
2022-07-16 21:00:02 +00:00
|
|
|
|
|
|
|
for(let el of document.getElementsByClassName('toggleable')) {
|
|
|
|
el.classList.add('d-none');
|
|
|
|
}
|
|
|
|
|
2022-09-13 17:45:00 +00:00
|
|
|
let amount = parseInt(document.getElementById(mobile ? "coin-transfer-amount-mobile" : "coin-transfer-amount").value);
|
2022-07-16 21:00:02 +00:00
|
|
|
let transferred = amount - Math.ceil(amount*TRANSFER_TAX);
|
|
|
|
let username = document.getElementById('username').innerHTML;
|
|
|
|
|
2022-11-03 19:08:22 +00:00
|
|
|
postToast(t, `/@${username}/transfer_coins`,
|
2022-07-16 21:00:02 +00:00
|
|
|
{
|
|
|
|
"amount": document.getElementById(mobile ? "coin-transfer-amount-mobile" : "coin-transfer-amount").value,
|
|
|
|
"reason": document.getElementById(mobile ? "coin-transfer-reason-mobile" : "coin-transfer-reason").value
|
|
|
|
},
|
2022-11-03 19:07:08 +00:00
|
|
|
() => {
|
2022-07-16 21:00:02 +00:00
|
|
|
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").innerText = parseInt(document.getElementById("profile-coins-amount").innerText) + transferred;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-11-03 19:07:08 +00:00
|
|
|
function transferBux(t, mobile=false) {
|
2022-07-16 21:00:02 +00:00
|
|
|
for(let el of document.getElementsByClassName('toggleable')) {
|
|
|
|
el.classList.add('d-none');
|
|
|
|
}
|
|
|
|
|
2022-09-13 17:45:00 +00:00
|
|
|
let amount = parseInt(document.getElementById(mobile ? "bux-transfer-amount-mobile" : "bux-transfer-amount").value);
|
2022-07-16 21:00:02 +00:00
|
|
|
let username = document.getElementById('username').innerHTML
|
|
|
|
|
2022-11-03 19:08:22 +00:00
|
|
|
postToast(t, `/@${username}/transfer_bux`,
|
2022-07-16 21:00:02 +00:00
|
|
|
{
|
|
|
|
"amount": document.getElementById(mobile ? "bux-transfer-amount-mobile" : "bux-transfer-amount").value,
|
|
|
|
"reason": document.getElementById(mobile ? "bux-transfer-reason-mobile" : "bux-transfer-reason").value
|
|
|
|
},
|
2022-11-03 19:07:08 +00:00
|
|
|
() => {
|
2022-07-16 21:00:02 +00:00
|
|
|
document.getElementById("user-bux-amount").innerText = parseInt(document.getElementById("user-bux-amount").innerText) - amount;
|
|
|
|
document.getElementById("profile-bux-amount-mobile").innerText = parseInt(document.getElementById("profile-bux-amount-mobile").innerText) + amount;
|
|
|
|
document.getElementById("profile-bux-amount").innerText = parseInt(document.getElementById("profile-bux-amount").innerText) + amount;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-30 12:52:59 +00:00
|
|
|
function sendMessage(form) {
|
2022-07-16 21:00:02 +00:00
|
|
|
document.getElementById('message').classList.add('d-none');
|
|
|
|
document.getElementById('message-mobile').classList.add('d-none');
|
|
|
|
document.getElementById('message-preview').classList.add('d-none');
|
|
|
|
document.getElementById('message-preview-mobile').classList.add('d-none');
|
2022-12-30 12:52:59 +00:00
|
|
|
sendFormXHR(form,
|
2022-11-07 06:08:50 +00:00
|
|
|
() => {
|
2023-02-27 15:02:35 +00:00
|
|
|
for (const substr of ['', '-mobile']) {
|
|
|
|
const ta = document.getElementById(`input-message${substr}`);
|
|
|
|
ta.value = '';
|
|
|
|
const input = ta.parentElement.querySelector('input[type="file"]');
|
|
|
|
input.previousElementSibling.innerHTML = '';
|
|
|
|
input.value = null;
|
2023-08-08 10:52:07 +00:00
|
|
|
oldfiles[ta.id] = new DataTransfer();
|
2023-02-27 15:02:35 +00:00
|
|
|
}
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
2022-11-07 06:08:50 +00:00
|
|
|
)
|
2022-10-22 22:10:36 +00:00
|
|
|
}
|