diff --git a/files/assets/js/comments.js b/files/assets/js/comments.js index dcef30689..5f2f5b222 100644 --- a/files/assets/js/comments.js +++ b/files/assets/js/comments.js @@ -14,4 +14,26 @@ function poll_vote_no_v() { var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); myToast.show(); document.getElementById('toast-post-error-text').innerText = "Only logged-in users can vote!"; +} + +function morecomments(cid) { + btn = document.getElementById(`btn-${cid}`); + btn.disabled = true; + btn.innerHTML = "Requesting..."; + var form = new FormData(); + form.append("formkey", formkey()); + var xhr = new XMLHttpRequest(); + xhr.open("post", `/morecomments/${cid}`); + xhr.withCredentials=true; + xhr.onload=function(){ + if (xhr.status==200) { + document.getElementById(`morecomments-${cid}`).innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, ''); + var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); + tooltipTriggerList.map(function(element){ + return new bootstrap.Tooltip(element); + }); + popovertrigger() + } + } + xhr.send(form) } \ No newline at end of file diff --git a/files/routes/posts.py b/files/routes/posts.py index 359b262c1..5a203a1ce 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -322,6 +322,14 @@ def viewmore(v, pid, sort, offset): return render_template("comments.html", v=v, comments=comments, render_replies=True, pid=pid, sort=sort, offset=offset) +@app.post("/morecomments/") +@limiter.limit("1/second") +@auth_desired +def morecomments(v, cid): + c = g.db.query(Comment).filter_by(id=cid).first() + comments = c.replies + return render_template("comments.html", v=v, comments=comments, render_replies=True) + @app.post("/edit_post/") @limiter.limit("1/second") @auth_required diff --git a/files/templates/comments.html b/files/templates/comments.html index fcb118593..94c85e0ed 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -485,8 +485,8 @@ More comments {% elif replies %} -
- More comments +
+
{% endif %} {% endif %} @@ -757,7 +757,7 @@ {% include "expanded_image_modal.html" %} - +