Fix viewmore on removed post. (#241)
parent
7c88c2e7e5
commit
8fb6067701
|
@ -74,8 +74,41 @@
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if offset %}
|
||||||
|
<script>
|
||||||
|
function viewmore(pid,sort,offset,ids) {
|
||||||
|
btn = document.getElementById("viewbtn");
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.innerHTML = "Requesting...";
|
||||||
|
var form = new FormData();
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("get", `/viewmore/${pid}/${sort}/${offset}?ids=${ids}`);
|
||||||
|
xhr.setRequestHeader('xhr', 'xhr');
|
||||||
|
xhr.onload=function(){
|
||||||
|
if (xhr.status==200) {
|
||||||
|
let e = document.getElementById(`viewmore-${offset}`);
|
||||||
|
e.innerHTML = xhr.response.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '');
|
||||||
|
bs_trigger(e)
|
||||||
|
|
||||||
|
comments = JSON.parse(localStorage.getItem("old-comment-counts")) || {}
|
||||||
|
lastCount = comments['{{p.id}}']
|
||||||
|
if (lastCount)
|
||||||
|
{
|
||||||
|
{% for c in p.comments %}
|
||||||
|
{% if not (v and v.id==c.author_id) and not c.voted %}
|
||||||
|
if ({{c.created_utc*1000}} > lastCount.t)
|
||||||
|
try {document.getElementById("comment-{{c.id}}-only").classList.add('unread')}
|
||||||
|
catch(e) {}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
btn.disabled = false;
|
||||||
|
}
|
||||||
|
xhr.send(form)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue