MarseyWorld/files/assets/js/admin/alts.js

35 lines
829 B
JavaScript
Raw Normal View History

2022-12-30 12:52:59 +00:00
function submitAddAlt(element, username) {
element.disabled = true;
element.classList.add('disabled');
const form = new FormData();
form.append('other_username', document.getElementById('link-input-other').value);
2022-12-30 12:52:59 +00:00
const xhr = createXhrWithFormKey(`/@${username}/alts/`, 'POST', form);
xhr[0].onload = () => {
let data;
try {
data = JSON.parse(xhr[0].response);
}
catch(e) {
console.log(e);
}
if (xhr[0].status >= 200 && xhr[0].status < 300) {
showToast(true, getMessageFromJsonData(true, data));
2022-12-30 12:52:59 +00:00
location.reload();
} else {
showToast(false, getMessageFromJsonData(false, data));
element.disabled = false;
element.classList.remove('disabled');
}
}
xhr[0].send(xhr[1]);
}
2023-02-18 14:55:18 +00:00
function delink(t, url) {
postToast(t, url,
{},
() => {
t.parentElement.parentElement.remove()
}
);
}