From f4921693ec6b73b5906eb921d4d943c940b1669c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 4 Mar 2022 20:04:27 +0200 Subject: [PATCH] treappy --- files/templates/comments.html | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/files/templates/comments.html b/files/templates/comments.html index fd9c7f18c3..2941b910d9 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -903,6 +903,41 @@ {% endfor %} } {% endif %} + + + function morecomments(cid) { + btn = document.getElementById(`btn-${cid}`); + btn.disabled = true; + btn.innerHTML = "Requesting..."; + var form = new FormData(); + form.append("formkey", formkey()); + const xhr = new XMLHttpRequest(); + xhr.open("get", `/morecomments/${cid}`); + xhr.setRequestHeader('xhr', 'xhr'); + 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, ''); + bs_trigger() + + {% if p %} + comments = JSON.parse(localStorage.getItem("old-comment-counts")) || {} + lastCount = comments['{{p.id}}'] + if (lastCount) + { + {% for c in p.comments2 %} + {% if not (v and v.id==c[0]) %} + if ({{c[1]*1000}} > lastCount.t) + try {document.getElementById("comment-{{c.id}}-only").classList.add('unread2')} + catch(e) {} + {% endif %} + {% endfor %} + } + {% endif %} + } + btn.disabled = false; + } + xhr.send(form) + } {% endif %}