PageSourceSearch

https://www.blausee.ch/(cms)/module/static/default/content/libs/js/jquery-highlight-3/jquery.highlight-3.js

js blausee.ch collected 2026-09-26 10:07:04 UTC 2,380 bytes, 71 lines download raw bytes

1/*
2 highlight v3
3 Highlights arbitrary terms.
4 <http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>
5 MIT license.
6 Johann Burkard
7 <http://johannburkard.de>
8 <mailto:[email protected]>
9 */
10/*
11 * [email protected]: replaced highlight with searchword for backwards-compatibility (line 28 and 50)
12 */
13jQuery.fn.highlight = function(options){
14    function innerHighlight(node, settings){
15        var skip = 0;
16        if (node.nodeType == 3) {
17            var pos = node.data.toUpperCase().indexOf(settings.pat);
18            if (pos >= 0) {
19                var spannode = document.createElement(settings.tagname);
20                spannode.className = settings.classname + ' jquery_highlighter';
21                
22                jQuery.each(settings.attributes, function(key, value){
23                    spannode[key] = value;
24                });
25                
26                var middlebit = node.splitText(pos);
27                var endbit = middlebit.splitText(settings.pat.length);
28                var middleclone = middlebit.cloneNode(true);
29                spannode.appendChild(middleclone);
30                middlebit.parentNode.replaceChild(spannode, middlebit);
31                skip = 1;
32                settings.callback(spannode);
33            }
34        }
35        else 
36            if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
37                for (var i = 0; i < node.childNodes.length; ++i) {
38                    i += innerHighlight(node.childNodes[i], settings);
39                }
40            }
41        return skip;
42    }
43    return this.each(function(){
44        var defaults = {
45			classname: 'searchword',
46            tagname: 'span',
47            attributes: {},
48            callback: function(){
49            }
50        };
51        
52        if (typeof options == 'string') {
53            defaults.pat = options;
54        }
55        
56        var settings = jQuery.extend(true, defaults, options);
57        settings.pat = settings.pat.toUpperCase();
58        
59        innerHighlight(this, settings);
60    });
61};
62
63jQuery.fn.removeHighlight = function(){
64    return this.find('.jquery_highlighter').each(function(){
65        this.parentNode.firstChild.nodeName;
66        with (this.parentNode) {
67            replaceChild(this.firstChild, this);
68            normalize();
69        }
70    }).end();
71};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.