22 lines
778 B
JavaScript
22 lines
778 B
JavaScript
function banModal(link, id, name) {
|
|
document.getElementById("banModalTitle").innerHTML = `Ban @${name}`;
|
|
document.getElementById("ban-modal-link").value = link;
|
|
document.getElementById("banUserButton").innerHTML = `Ban @${name}`;
|
|
|
|
document.getElementById("banUserButton").onclick = function() {
|
|
let fd = new FormData(document.getElementById("banModalForm"));
|
|
fd.append("formkey", formkey());
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
xhr.open("POST", `/ban_user/${id}?form`);
|
|
xhr.setRequestHeader('xhr', 'xhr');
|
|
|
|
xhr.onload = function(){
|
|
var myToast = bootstrap.Toast.getOrCreateInstance(document.getElementById('toast-post-success'));
|
|
myToast.show();
|
|
document.getElementById('toast-post-success-text').innerHTML = `@${name} banned`;
|
|
}
|
|
|
|
xhr.send(fd);
|
|
}
|
|
}
|