rDrama/files/assets/js/report_post_modal.js
2022-02-01 08:27:48 +02:00

33 lines
No EOL
981 B
JavaScript

function report_postModal(id) {
submitbutton=document.getElementById("reportPostButton");
document.getElementById("reportPostFormBefore").classList.remove('d-none');
document.getElementById("reportPostFormAfter").classList.add('d-none');
submitbutton.disabled = false;
submitbutton.innerHTML='Report post';
reason = document.getElementById("reason")
reason.value = ""
submitbutton.onclick = function() {
this.innerHTML='Reporting post';
this.disabled = true;
const xhr = new XMLHttpRequest();
xhr.open("POST", '/report/post/'+id);
xhr.setRequestHeader('xhr', 'xhr');
var form = new FormData()
form.append("formkey", formkey());
form.append("reason", reason.value);
xhr.onload=function() {
document.getElementById("reportPostFormBefore").classList.add('d-none');
document.getElementById("reportPostFormAfter").classList.remove('d-none');
};
xhr.onerror=function(){alert(errortext)};
xhr.send(form);
}
};