forked from rDrama/rDrama
use postToast in report_comment_modal
parent
0e10dd6b32
commit
82579cdb71
|
@ -27,22 +27,13 @@ function report_commentModal(id, author) {
|
||||||
|
|
||||||
reportCommentButton.onclick = function() {
|
reportCommentButton.onclick = function() {
|
||||||
this.innerHTML='Reporting comment';
|
this.innerHTML='Reporting comment';
|
||||||
this.disabled = true;
|
|
||||||
this.classList.add('disabled');
|
|
||||||
const form = new FormData();
|
|
||||||
form.append("reason", reason_comment.value);
|
|
||||||
const xhr = createXhrWithFormKey("/report/comment/" + id, "POST", form);
|
|
||||||
|
|
||||||
xhr[0].onload = function() {
|
postToast(this, `/report/comment/${id}`,
|
||||||
let data
|
{
|
||||||
try {data = JSON.parse(xhr[0].response)}
|
"reason": reason_comment.value
|
||||||
catch(e) {console.log(e)}
|
},
|
||||||
success = xhr[0].status >= 200 && xhr[0].status < 300;
|
() => {}
|
||||||
showToast(success, getMessageFromJsonData(success, data));
|
);
|
||||||
};
|
|
||||||
|
|
||||||
xhr[0].onerror=function(){alert(errortext)};
|
|
||||||
xhr[0].send(xhr[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue