33 lines
1.1 KiB
HTML
33 lines
1.1 KiB
HTML
<style>
|
|
.fa-comment {
|
|
margin-left: 4px;
|
|
}
|
|
</style>
|
|
|
|
<i class="fa fa-comment" aria-hidden="true" {% if include.tooltip %}
|
|
title="{{site.data.locales[include.lang].post.comments}}" data-bs-toggle="tooltip" data-bs-placement="bottom" {%
|
|
endif %}></i>
|
|
<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);
|
|
}
|
|
if(commentsCount !== commentsCountFromResponse){
|
|
ajax(serviceUrl + "/UpdatePostCommentsCount?blogUrl=" + siteId + "&postSlug=" + postId, "POST", commentsCount);
|
|
}
|
|
});
|
|
var config = { childList: true };
|
|
observer.observe(target, config);
|
|
}
|
|
commentTextChange();
|
|
</script> |