rDrama/files/assets/js/report_post_modal.js
Aevann1 d1c79b2305 v
2022-01-28 00:43:59 +02:00

27 lines
No EOL
749 B
JavaScript

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