From 67028c34166e65ee95498c2d14496934bf68b16f Mon Sep 17 00:00:00 2001 From: Blaise Date: Mon, 31 Oct 2022 13:07:08 -0500 Subject: Remove framework code, improve minification --- proselight.js | 55 +++++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/proselight.js b/proselight.js index b4df7f4..d92797b 100644 --- a/proselight.js +++ b/proselight.js @@ -9,41 +9,29 @@ */ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - define(['exports'], factory); - } else if (typeof exports !== 'undefined') { - factory(exports); - } else { - factory((root.proselight = {})); - } -}(this, function (exports) { +( function () { // for better compression var _window = window, _document = document, appendChild = 'appendChild', test = 'test', - i, + i, j, proselighted, - cn, //child nodes - el; // current proselighted element to run through - - - - var reset = function() { - // nodes to highlight - proselighted = _document.querySelectorAll('p'); - - for (i = 0; el = proselighted[i++];) { - cn = Array.from(el.childNodes); - for (j = 0; j < cn.length; j++) { - if (cn[j].nodeType != Node.TEXT_NODE) { - el.appendChild(cn[j]); - continue; - } - el.removeChild(cn[j]); - var text = cn[j].textContent, + cna, //child node array + cn, //child node + el; // current proselighted element to run through + + // nodes to highlight + proselighted = _document.querySelectorAll('p'); + + for (i = 0; el = proselighted[i++];) { + cna = Array.from(el.childNodes); + for (j = 0; cn = cna[j++];) { + el[appendChild](cn); + if (cn.nodeType == Node.TEXT_NODE) { + el.removeChild(cn); + var text = cn.textContent, pos = 0, // current position next1 = text[0], // next character chr = 1, // current character @@ -110,13 +98,4 @@ } } } - - exports.reset = reset; - - if (_document.readyState == 'complete') { - reset(); - } else { - _window.addEventListener('load', function(){reset()}, 0); - } -})); - +} )(); -- cgit v1.2.3