2022-12-30 12:52:59 +00:00
|
|
|
function submitAddAlt(element, username) {
|
2022-12-29 14:20:27 +00:00
|
|
|
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);
|
2023-03-10 01:33:05 +00:00
|
|
|
xhr[0].onload = () => {
|
2022-12-29 14:20:27 +00:00
|
|
|
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();
|
2022-12-29 14:20:27 +00:00
|
|
|
} 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()
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|