From 09c84030b51e315adbae1897f834d209733a998d Mon Sep 17 00:00:00 2001 From: Yo Mama Date: Mon, 27 Sep 2021 23:20:26 +0200 Subject: [PATCH] Fix .js on removed comments. Removed duplicate post_comment --- files/assets/js/comments_v.js | 41 ++--------------------------------- files/templates/comments.html | 18 +++++++-------- 2 files changed, 11 insertions(+), 48 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 6797d73e4..dc79a9c5a 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -144,44 +144,6 @@ function delete_commentModal(id) { }; - -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", "/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"]; - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.hide(); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.show(); - } - else { - var commentError = document.getElementById("comment-error-text"); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.show(); - commentError.textContent = JSON.parse(xhr.response)["error"]; - } - } - xhr.send(form) - - document.getElementById('save-reply-to-'+fullname).classList.add('disabled'); - -} - post_reply=function(id){ var form = new FormData(); @@ -248,7 +210,7 @@ comment_edit=function(id){ } xhr.send(form) - } +} post_comment=function(fullname, postId){ @@ -259,6 +221,7 @@ post_comment=function(fullname, postId){ 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", "/comment"); xhr.withCredentials=true; diff --git a/files/templates/comments.html b/files/templates/comments.html index 33dc973fa..3875c0c21 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -64,9 +64,9 @@
@@ -518,15 +518,15 @@
-{% endif %} - +{% endif %} + {% endmacro %} {% for comment in comments %}