2022-07-16 21:00:02 +00:00
|
|
|
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 form = new FormData(document.getElementById("banModalForm"));
|
2022-10-14 12:01:11 +00:00
|
|
|
const xhr = createXhrWithFormKey(`/ban_user/${id}?form`, "POST", form);
|
|
|
|
xhr[0].onload = function() {
|
2022-07-16 21:00:02 +00:00
|
|
|
let data
|
2022-10-19 18:00:33 +00:00
|
|
|
try {data = JSON.parse(xhr[0].response)}
|
2022-07-16 21:00:02 +00:00
|
|
|
catch(e) {console.log(e)}
|
2022-10-14 12:01:11 +00:00
|
|
|
success = xhr[0].status >= 200 && xhr[0].status < 300;
|
2022-10-14 10:15:06 +00:00
|
|
|
showToast(success, getMessageFromJsonData(success, data));
|
2022-07-16 21:00:02 +00:00
|
|
|
};
|
2022-09-04 23:15:37 +00:00
|
|
|
|
2022-10-14 12:01:11 +00:00
|
|
|
xhr[0].send(xhr[1]);
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
}
|