From 9b47ad166bc5f1a8e1eae36193e55070dd39e045 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 23 Oct 2022 17:51:46 +0200 Subject: [PATCH] small refactor to approving psots and comments --- files/assets/js/comments_admin.js | 87 ++++++++++--------------------- files/templates/comments.html | 20 ++----- 2 files changed, 33 insertions(+), 74 deletions(-) diff --git a/files/assets/js/comments_admin.js b/files/assets/js/comments_admin.js index ff4222c1b..73dd4a613 100644 --- a/files/assets/js/comments_admin.js +++ b/files/assets/js/comments_admin.js @@ -1,75 +1,44 @@ -function removeComment(post_id,button1,button2) { +function removeComment(post_id,button1,button2,cls) { url="/remove_comment/"+post_id post(url) - try { - document.getElementById("comment-"+post_id+"-only").classList.add("banned"); - } catch(e) { - document.getElementById("context").classList.add("banned"); + if (window.location.pathname == '/admin/reported/comments') + { + document.getElementById("post-info-"+post_id).remove() + document.getElementById("comment-"+post_id).remove() } - - var button=document.getElementById("remove-"+post_id); - button.onclick=function(){approveComment(post_id)}; - button.innerHTML='Approve' - - if (typeof button1 !== 'undefined') { - document.getElementById(button1).classList.toggle("d-md-block"); - document.getElementById(button2).classList.toggle("d-md-block"); + else + { + try { + document.getElementById("comment-"+post_id+"-only").classList.add("banned"); + } catch(e) { + document.getElementById("context").classList.add("banned"); + } + document.getElementById(button1).classList.toggle(cls); + document.getElementById(button2).classList.toggle(cls); } }; -function approveComment(post_id,button1,button2) { +function approveComment(post_id,button1,button2,cls) { url="/approve_comment/"+post_id post(url) - try { - document.getElementById("comment-"+post_id+"-only").classList.remove("banned"); - } catch(e) { - document.getElementById("context").classList.remove("banned"); + if (window.location.pathname == '/admin/reported/comments') + { + document.getElementById("post-info-"+post_id).remove() + document.getElementById("comment-"+post_id).remove() } - - var button=document.getElementById("remove-"+post_id); - button.onclick=function(){removeComment(post_id)}; - button.innerHTML='Remove' - - if (typeof button1 !== 'undefined') { - document.getElementById(button1).classList.toggle("d-md-block"); - document.getElementById(button2).classList.toggle("d-md-block"); - } -} - - -function removeComment2(post_id,button1,button2) { - url="/remove_comment/"+post_id - - post(url) - - document.getElementById("comment-"+post_id+"-only").classList.add("banned"); - var button=document.getElementById("remove-"+post_id); - button.onclick=function(){approveComment(post_id)}; - button.innerHTML='Approve' - - if (typeof button1 !== 'undefined') { - document.getElementById(button1).classList.toggle("d-none"); - document.getElementById(button2).classList.toggle("d-none"); - } -}; - -function approveComment2(post_id,button1,button2) { - url="/approve_comment/"+post_id - - post(url) - - document.getElementById("comment-"+post_id+"-only").classList.remove("banned"); - var button=document.getElementById("remove-"+post_id); - button.onclick=function(){removeComment(post_id)}; - button.innerHTML='Remove' - - if (typeof button1 !== 'undefined') { - document.getElementById(button1).classList.toggle("d-none"); - document.getElementById(button2).classList.toggle("d-none"); + else + { + try { + document.getElementById("comment-"+post_id+"-only").classList.remove("banned"); + } catch(e) { + document.getElementById("context").classList.remove("banned"); + } + document.getElementById(button1).classList.toggle(cls); + document.getElementById(button2).classList.toggle(cls); } } diff --git a/files/templates/comments.html b/files/templates/comments.html index e3687899b..1548c566c 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -71,7 +71,7 @@ {% endif %} {% if standalone and level==1 %} -
+