HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/RMourik/bassol.nl/CMS/CMSScripts/jquery/jquery-highlighter.js
/*

highlight v3

Highlights arbitrary terms.

<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>

MIT license.

Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>

*/

$cmsj.fn.highlight = function(pat, className, regExp) {
    function innerHighlight(node, pat, className, regExp) {
        var skip = 0;
        if (node.nodeType == 3) {
            if (regExp == 'True') {
                var regex = new RegExp(pat, "");
                var match = node.data.match(regex);
                if ((match != null) && (match.index >= 0)) {
                    skip = createSubNode(node, match.index, match[0].length, className);
                }
            }
            else {
                var pos = node.data.indexOf(pat);
                skip = createSubNode(node, pos, pat.length, className);
            }
        }
        else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
            for (var i = 0; i < node.childNodes.length; ++i) {
                i += innerHighlight(node.childNodes[i], pat, className, regExp);
            }
        }
        return skip;
    }
    function createSubNode(node, pos, length, className) {
        if (pos >= 0) {
            var spannode = document.createElement('span');
            if (typeof (className) == 'undefined') {
                spannode.className = 'highlight';
            }
            else {
                spannode.className = className;
            }
            var middlebit = node.splitText(pos);
            var endbit = middlebit.splitText(length);
            var middleclone = middlebit.cloneNode(true);
            spannode.appendChild(middleclone);
            middlebit.parentNode.replaceChild(spannode, middlebit);
            return 1;
        }
        return 0;
    }
    return this.each(function() {
        innerHighlight(this, pat, className, regExp);
    });
};