This commit is contained in:
Aevann1 2021-12-11 02:05:01 +02:00
parent 2acfeec7ff
commit 66e96824f4
3 changed files with 33 additions and 3 deletions

View file

@ -14,4 +14,26 @@ function poll_vote_no_v() {
var myToast = new bootstrap.Toast(document.getElementById('toast-post-error')); var myToast = new bootstrap.Toast(document.getElementById('toast-post-error'));
myToast.show(); myToast.show();
document.getElementById('toast-post-error-text').innerText = "Only logged-in users can vote!"; 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)
} }

View file

@ -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) return render_template("comments.html", v=v, comments=comments, render_replies=True, pid=pid, sort=sort, offset=offset)
@app.post("/morecomments/<cid>")
@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/<pid>") @app.post("/edit_post/<pid>")
@limiter.limit("1/second") @limiter.limit("1/second")
@auth_required @auth_required

View file

@ -485,8 +485,8 @@
<a href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a> <a href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a>
</div> </div>
{% elif replies %} {% elif replies %}
<div id="morecomment-{{c.id}}" class="mt-2 more-comments text-small"> <div id="morecomments-{{c.id}}" class="mt-2 more-comments text-small">
<a href="{{c.shortlink}}">More comments <i class="fas fa-long-arrow-right ml-1"></i></a> <button id="btn-{{c.id}}" class="btn btn-primary" onclick="morecomments('{{c.id}}')">More comments</button>
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
@ -757,7 +757,7 @@
{% include "expanded_image_modal.html" %} {% include "expanded_image_modal.html" %}
<script src="/assets/js/comments+submission_listing.js?v=100"></script> <script src="/assets/js/comments+submission_listing.js?v=100"></script>
<script src="/assets/js/comments.js?v=13"></script> <script src="/assets/js/comments.js?v=14"></script>
<script> <script>
{% if p and (not v or v.highlightcomments) %} {% if p and (not v or v.highlightcomments) %}