X-Git-Url: http://unremediatedgender.space/source?p=Ultimately_Untrue_Thought.git;a=blobdiff_plain;f=theme%2Fstatic%2Fjs%2Fcomment_counts.js;h=3bb58664a3dd5ae8d72a9a2381ad3134324130ee;hp=d0df09b98e80f307c981403bc6a5946a42100f00;hb=HEAD;hpb=b185f09fa25daa55ae4e50dbe00ada569377e744 diff --git a/theme/static/js/comment_counts.js b/theme/static/js/comment_counts.js index d0df09b..3bb5866 100644 --- a/theme/static/js/comment_counts.js +++ b/theme/static/js/comment_counts.js @@ -1,11 +1,15 @@ function placeCommentCounts() { let containers = Array.from(document.querySelectorAll(".comments-link-container")); let paths = containers.map(function(span) { return span.dataset.path; }); + if (paths.length === 0) { + return; + } let request = new XMLHttpRequest(); request.open('POST', 'http://unremediatedgender.space/isso/count', true); request.setRequestHeader("Content-Type", "application/json"); + request.send(JSON.stringify(paths)); request.onload = function() { @@ -14,6 +18,9 @@ function placeCommentCounts() { for (let [i, container] of containers.entries()) { let a = document.createElement('a'); let count = counts[i]; + if (count === 0) { + count = "no"; + } let pluralizer = count === 1 ? "" : "s"; let text = document.createTextNode(`${count} comment${pluralizer}`); a.appendChild(text);