This commit is contained in:
Aevann1 2021-07-21 12:58:23 +02:00
parent 684e2ee923
commit e9ad5855ff
5 changed files with 116 additions and 113 deletions

View file

@ -937,115 +937,6 @@ $(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
post_comment=function(fullname){
var form = new FormData();
form.append('formkey', formkey());
form.append('parent_fullname', fullname);
form.append('submission', document.getElementById('reply-form-submission-'+fullname).value);
form.append('body', document.getElementById('reply-form-body-'+fullname).value);
form.append('file', document.getElementById('file-upload-reply-'+fullname).files[0]);
var xhr = new XMLHttpRequest();
xhr.open("post", "/api/comment");
xhr.withCredentials=true;
xhr.onload=function(){
if (xhr.status==200) {
commentForm=document.getElementById('comment-form-space-'+fullname);
commentForm.innerHTML=JSON.parse(xhr.response)["html"];
$('#toast-comment-success').toast('dispose');
$('#toast-comment-error').toast('dispose');
$('#toast-comment-success').toast('show');
}
else {
var commentError = document.getElementById("comment-error-text");
$('#toast-comment-success').toast('dispose');
$('#toast-comment-error').toast('dispose');
$('#toast-comment-error').toast('show');
commentError.textContent = JSON.parse(xhr.response)["error"];
}
}
xhr.send(form)
document.getElementById('save-reply-to-'+fullname).classList.add('disabled');
}
herald_comment=function(bid,cid){
var xhr = new XMLHttpRequest();
xhr.open("post", "/mod/distinguish_comment/"+bid+'/'+cid);
var form = new FormData();
form.append('formkey', formkey());
xhr.withCredentials=true;
xhr.onload=function(){
if (xhr.status==200) {
comment=document.getElementById('comment-'+cid+'-only');
comment.innerHTML=JSON.parse(xhr.response)["html"];
}
else {
var commentError = document.getElementById("comment-error-text");
$('#toast-comment-success').toast('dispose');
$('#toast-comment-error').toast('dispose');
$('#toast-comment-error').toast('show');
commentError.textContent = JSON.parse(xhr.response)["error"];
}
}
xhr.send(form)
}
//part of submit page js
hide_image=function(){
x=document.getElementById('image-upload-block');
url=document.getElementById('post-URL').value;
if (url.length>=1){
x.classList.add('d-none');
}
else {
x.classList.remove('d-none');
}
}
comment_edit=function(id){
var commentError = document.getElementById("comment-error-text");
var form = new FormData();
form.append('formkey', formkey());
form.append('body', document.getElementById('comment-edit-body-'+id).value);
form.append('file', document.getElementById('file-edit-reply-'+id).files[0]);
var xhr = new XMLHttpRequest();
xhr.open("post", "/edit_comment/"+id);
xhr.withCredentials=true;
xhr.onload=function(){
if (xhr.status==200) {
commentForm=document.getElementById('comment-text-'+id);
commentForm.innerHTML=JSON.parse(xhr.response)["html"];
document.getElementById('cancel-edit-'+id).click()
$('#toast-comment-success').toast('dispose');
$('#toast-comment-error').toast('dispose');
$('#toast-comment-success').toast('show');
}
else {
$('#toast-comment-success').toast('dispose');
$('#toast-comment-error').toast('dispose');
$('#toast-comment-error').toast('show');
commentError.textContent = JSON.parse(xhr.response)["error"];
}
}
xhr.send(form)
}
$('.mention-user').click(function (event) {