From ff04981cf57d37d5488e130ea2d17d182399d811 Mon Sep 17 00:00:00 2001 From: pawurb Date: Wed, 17 Apr 2019 18:48:03 +0200 Subject: [PATCH] count.js: allow customizing no comments text Optional 'data-hide-no-comments-count' allows to hide comments count when there are no comments. --- frontend/js/count.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/js/count.js b/frontend/js/count.js index 5fbbdc8..734447b 100644 --- a/frontend/js/count.js +++ b/frontend/js/count.js @@ -55,7 +55,13 @@ count = resp.commentCounts[paths[i]]; } - doms[i].innerText = count + " " + (count === 1 ? "comment" : "comments"); + var useCustomCommentsText = doms[i].getAttribute("data-custom-comments-text") !== null; + + if(useCustomCommentsText) { + doms[i].innerText = eval(doms[i].getAttribute("data-custom-comments-text"))(count); + } else { + doms[i].innerText = count + " " + (count === 1 ? "comment" : "comments"); + } } }); }