From 91c2d047d52f90a3d1e6f424dc9261396216d4b7 Mon Sep 17 00:00:00 2001 From: Adhityaa Date: Sat, 16 Jun 2018 18:52:46 +0530 Subject: [PATCH] commento.js: add config to control auto-init --- frontend/js/commento.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/js/commento.js b/frontend/js/commento.js index f5e1b14..202c302 100644 --- a/frontend/js/commento.js +++ b/frontend/js/commento.js @@ -1301,16 +1301,20 @@ for (var i = 0; i < scripts.length; i++) { if (scripts[i].src.match(/\/js\/commento\.js$/)) { cssOverride = attrGet(scripts[i], "data-css-override"); + + autoInit = attrGet(scripts[i], "data-auto-init"); + + ID_ROOT = attrGet(scripts[i], "data-id-root"); + if (ID_ROOT === undefined) + ID_ROOT = "commento"; } } } - function main(callback) { + global.main = function(callback) { root = $(ID_ROOT); classAdd(root, "root"); - dataTagsLoad(); - loginBoxCreate(); errorElementCreate(); @@ -1335,7 +1339,12 @@ return; autoInitted = true; - main(); + dataTagsLoad(); + + if (autoInit == "true" || autoInit === undefined) + main(undefined); + else if (autoInit != "false") + console.log("[commento] error: invalid value for data-auto-init; allowed values: true, false"); } if (document.readyState != "complete" && document.readyState != "interactive")