rDrama/files/assets/js/report_post_modal.js
2021-10-06 00:02:54 +02:00

27 lines
No EOL
877 B
JavaScript

report_postModal = function(id) {
submitbutton=document.getElementById("reportPostButton");
submitbutton.onclick = function() {
this.innerHTML='<span class="spinner-border spinner-border-sm mr-2" role="status" aria-hidden="true"></span>Reporting post';
this.disabled = true;
var xhr = new XMLHttpRequest();
xhr.open("POST", '/flag/post/'+id, true);
var form = new FormData()
form.append("formkey", formkey());
form.append("reason", document.getElementById("reason").value);
xhr.withCredentials=true;
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);
}
};