From 166599a2c8327bfec5dfe9bbd4ac7e5d3aaf5f46 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Thu, 2 Jan 2020 14:02:36 -0800 Subject: [PATCH] count.js: support data-page-id paths Closes https://gitlab.com/commento/commento/issues/255 --- frontend/js/count.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/js/count.js b/frontend/js/count.js index 7088a39..afebaa5 100644 --- a/frontend/js/count.js +++ b/frontend/js/count.js @@ -38,7 +38,7 @@ var scripts = tags("script") for (var i = 0; i < scripts.length; i++) { if (scripts[i].src.match(/\/js\/count\.js$/)) { - var customCommentsText = attrGet(scripts[i], "data-custom-text"); + var customCommentsText = attrGet(scripts[i], "data-custom-text"); if (customCommentsText !== undefined) { commentsText = eval(customCommentsText); } @@ -61,12 +61,15 @@ href = href.replace(/^.*\/\/[^\/]+/, ""); if (href.endsWith("#commento")) { - var path = href.substr(0, href.indexOf("#commento")); - if (path.startsWith(parent.location.host)) { - path = path.substr(parent.location.host.length); + var pageId = attrGet(as[i], "data-page-id"); + if (pageId === undefined) { + pageId = href.substr(0, href.indexOf("#commento")); + if (pageId.startsWith(parent.location.host)) { + pageId = pageId.substr(parent.location.host.length); + } } - paths.push(path); + paths.push(pageId); doms.push(as[i]); } }