update post comments to api
This commit is contained in:
parent
1c68d60f2b
commit
f06a42cb69
@ -4,6 +4,28 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i class="fa fa-comment" aria-hidden="true" {% if include.tooltip %} title="{{site.data.locales[include.lang].post.comments}}"
|
<i class="fa fa-comment" aria-hidden="true" {% if include.tooltip %}
|
||||||
data-bs-toggle="tooltip" data-bs-placement="bottom" {% endif %}></i>
|
title="{{site.data.locales[include.lang].post.comments}}" data-bs-toggle="tooltip" data-bs-placement="bottom" {%
|
||||||
|
endif %}></i>
|
||||||
<span class="remark42__counter"></span>
|
<span class="remark42__counter"></span>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function commentTextChange() {
|
||||||
|
var target = document.querySelector('.remark42__counter');
|
||||||
|
if(!target){
|
||||||
|
window.setTimeout(commentTextChange, 500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var observer = new MutationObserver(function (mutations) {
|
||||||
|
const comments = document.querySelector(".remark42__counter");
|
||||||
|
var commentsCount = 0;
|
||||||
|
if(Number(comments.innerText) !== NaN){
|
||||||
|
commentsCount = Number(comments.innerText);
|
||||||
|
}
|
||||||
|
ajax(serviceUrl + "/UpdatePostCommentsCount?blogUrl=" + siteId + "&postSlug=" + postId, "POST", commentsCount);
|
||||||
|
});
|
||||||
|
var config = { childList: true };
|
||||||
|
observer.observe(target, config);
|
||||||
|
}
|
||||||
|
commentTextChange();
|
||||||
|
</script>
|
||||||
@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
{% include views.html tooltip=true onload=false lang=lang %}
|
{% include views.html tooltip=true onload=false lang=lang %}
|
||||||
{% include likes.html tooltip=true onload=false lang=lang %}
|
{% include likes.html tooltip=true onload=false lang=lang %}
|
||||||
{% include comments-counter.html tooltip=true lang=lang %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const views = document.getElementById("views-count");
|
const views = document.getElementById("views-count");
|
||||||
|
|||||||
@ -36,7 +36,7 @@ tail_includes:
|
|||||||
<!-- post counter -->
|
<!-- post counter -->
|
||||||
<div id="likes-views">
|
<div id="likes-views">
|
||||||
{% include likes-views.html tooltip=true lang=lang %}
|
{% include likes-views.html tooltip=true lang=lang %}
|
||||||
<!-- {% include comments-counter.html tooltip=true lang=lang %} -->
|
{% include comments-counter.html tooltip=true lang=lang %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user