diff --git a/files/routes/comments.py b/files/routes/comments.py index 7b039567fd..5c443ea8dc 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -846,10 +846,10 @@ def undelete_comment(cid, v): return {"message": "Comment undeleted!"} -@app.post("/comment_pin/") +@app.post("/pin_comment/") @auth_required @validate_formkey -def toggle_comment_pin(cid, v): +def toggle_pin_comment(cid, v): comment = get_comment(cid, v=v) diff --git a/files/templates/comments.html b/files/templates/comments.html index d947c580c3..e7402520f0 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -32,24 +32,18 @@ } else if (xhr.status >= 300 && xhr.status < 400) { window.location.href = JSON.parse(xhr.response)["redirect"] } else { + try { data=JSON.parse(xhr.response); + } catch(e) {} - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.hide(); - myToast.show(); - document.getElementById('toast-post-error-text').innerText = data["error"]; - return false - } catch(e) { - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.hide(); - myToast.show(); - document.getElementById('toast-post-error-text').innerText = "Error. Try again later."; - return false - } + var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); + myToast.hide(); + var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); + myToast.hide(); + myToast.show(); + document.getElementById('toast-post-error-text').innerText = "Error. Try again later."; + return false } }; @@ -350,93 +344,6 @@ document.getElementById(button2).classList.toggle("d-none"); } } - - - admin_comment=function(cid,button1,button2,distinguish){ - - - var xhr = new XMLHttpRequest(); - xhr.open("post", "/distinguish_comment/"+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"); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.hide(); - myToast.show(); - - commentError.textContent = JSON.parse(xhr.response)["error"]; - } - } - xhr.send(form) - - document.getElementById(button1).classList.toggle("d-md-inline-block"); - document.getElementById(button2).classList.toggle("d-md-inline-block"); - - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - myToast.show(); - - if (distinguish=='yes') { - document.getElementById('toast-post-success-text').innerText = "Comment distinguished!"; - } - else { - document.getElementById('toast-post-success-text').innerText = "Comment undistinguished!"; - } - } - - - admin_comment2=function(cid,button1,button2,distinguish){ - var xhr = new XMLHttpRequest(); - xhr.open("post", "/distinguish_comment/"+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"); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); - myToast.hide(); - myToast.show(); - - commentError.textContent = JSON.parse(xhr.response)["error"]; - } - } - xhr.send(form) - - document.getElementById(button1).classList.toggle("d-none"); - document.getElementById(button2).classList.toggle("d-none"); - - var myToast = new bootstrap.Toast(document.getElementById('toast-post-success')); - myToast.hide(); - myToast.show(); - if (distinguish=='yes') { - document.getElementById('toast-post-success-text').innerText = "Comment distinguished!"; - } - else { - document.getElementById('toast-post-success-text').innerText = "Comment undistinguished!"; - } - } {% endif %} @@ -768,10 +675,9 @@ {% endif %} {% endif %} - {% if v and v.admin_level==6 and v.id==c.author_id %} -
  • Undistinguish
  • -
  • Distinguish
  • +
  • Undistinguish
  • +
  • Distinguish
  • {% endif %} @@ -781,9 +687,9 @@ {% endif %} {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %} -
  • Unpin
  • +
  • Unpin
  • -
  • Pin
  • +
  • Pin
  • {% endif %} @@ -925,14 +831,14 @@ {% endif %} {% if v and c.post and (v.admin_level >= 1 or v.id == c.post.author_id) and c.level == 1 %} -
  • Pin
  • -
  • Unpin
  • +
  • Pin
  • +
  • Unpin
  • {% endif %} {% if v %} {% if v.admin_level>=1 and v.id==c.author_id %} -
  • Distinguish
  • -
  • Undistinguish
  • +
  • Distinguish
  • +
  • Undistinguish
  • {% endif %} {% if v.admin_level>=3 %} {% if "/reported/" in request.path %}