Clean up handling of "view more comments" button
This commit is contained in:
parent
4b935addb8
commit
2767d556ca
2 changed files with 17 additions and 13 deletions
|
@ -38,9 +38,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'usernote.html' %}
|
||||
{% include 'usernote.html' %}
|
||||
{% endif %}
|
||||
|
||||
{% macro single_comment(c, level=1) %}
|
||||
|
||||
|
@ -741,6 +741,16 @@
|
|||
|
||||
{% endfor %}
|
||||
|
||||
{% if offset %}
|
||||
{% if p %}
|
||||
{% set pid = p.id %}
|
||||
{% endif %}
|
||||
<div id="viewmore-{{offset}}">
|
||||
<br>
|
||||
<button id="viewbtn" class="btn btn-primary" onclick="viewmore({{pid}},'{{sort}}',{{offset}},{{ids}})">VIEW MORE COMMENTS</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not ajax %}
|
||||
{% if v %}
|
||||
{% include "gif_modal.html" %}
|
||||
|
@ -889,12 +899,4 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% if offset %}
|
||||
{% if p %}
|
||||
{% set pid = p.id %}
|
||||
{% endif %}
|
||||
<br>
|
||||
<div id="viewmore-{{offset}}"><button id="viewbtn" class="btn btn-primary" onclick="viewmore({{pid}},'{{sort}}',{{offset}},{{ids}})">VIEW MORE COMMENTS</a></div>
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
|
|
|
@ -539,9 +539,11 @@
|
|||
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)
|
||||
const e = document.getElementById(`viewmore-${offset}`);
|
||||
const html = xhr.response.replace(/data-src/g, "src").replace(/data-cfsrc/g, "src").replace(/style="display:none;visibility:hidden;"/g, "");
|
||||
const fragment = document.createRange().createContextualFragment(html);
|
||||
bs_trigger(fragment);
|
||||
e.replaceWith(fragment);
|
||||
|
||||
comments = JSON.parse(localStorage.getItem("old-comment-counts")) || {}
|
||||
lastCount = comments['{{p.id}}']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue