From 80e81e1648bef013e8206714d848c7f2e77ee25c Mon Sep 17 00:00:00 2001 From: Dmitry Prokashev Date: Thu, 9 Jun 2016 20:06:46 +0200 Subject: custom class name to highlight can be provided as an argument to the reset() function --- microlight.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/microlight.js b/microlight.js index ecf120a..400e003 100644 --- a/microlight.js +++ b/microlight.js @@ -30,13 +30,16 @@ _3px_0px_5 = '3px 0px 5', brace = ')', - el, // current microlighted element to run through + i, + microlighted, + el; // current microlighted element to run through - // dynamic set of nodes to highlight - microlighted = _document.getElementsByClassName('microlight'); - var reset = function(i) { + var reset = function(cls) { + // nodes to highlight + microlighted = _document.getElementsByClassName(cls||'microlight'); + for (i = 0; el = microlighted[i++];) { var text = el.textContent, pos = 0, // current position @@ -201,7 +204,7 @@ if (_document.readyState == 'complete') { reset(); } else { - _window.addEventListener('load', reset, 0); + _window.addEventListener('load', function(){reset()}, 0); } })); -- cgit v1.2.3