forked from rDrama/rDrama
33 lines
700 B
JavaScript
33 lines
700 B
JavaScript
function block_user() {
|
|
const usernameField = document.getElementById("block-username");
|
|
const isValidUsername = usernameField.checkValidity();
|
|
username = usernameField.value;
|
|
if (isValidUsername) {
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open("post", "/settings/block");
|
|
xhr.setRequestHeader('xhr', 'xhr');
|
|
f=new FormData();
|
|
f.append("username", username);
|
|
f.append("formkey", formkey());
|
|
xhr.onload=function(){
|
|
if (xhr.status<300) {
|
|
location.reload();
|
|
}
|
|
else {
|
|
showToast(false, "Error, please try again later.");
|
|
}
|
|
}
|
|
xhr.send(f)
|
|
}
|
|
}
|
|
|
|
function unblock_user(t, url) {
|
|
postToast(t, url,
|
|
{
|
|
},
|
|
() => {
|
|
t.parentElement.parentElement.remove();
|
|
}
|
|
);
|
|
}
|