diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 11:19:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 12:07:37 +0000 |
commit | b485aab7e71c1625cfc27e0f92c9509f42378458 (patch) | |
tree | ae9abe108601079d1679194de237c9a435ae5b55 /web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js | |
parent | Adding upstream version 1.44.3. (diff) | |
download | netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.tar.xz netdata-b485aab7e71c1625cfc27e0f92c9509f42378458.zip |
Adding upstream version 1.45.3+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js')
-rw-r--r-- | web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js b/web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js deleted file mode 100644 index 519e8876c..000000000 --- a/web/server/h2o/libh2o/misc/oktavia/lib/oktavia-jquery-highlight.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @fileOverview - * A UI script helper that provides search word highlight. - * Almost all code came from Sphinx - * @author Yoshiki Shibukawa, yoshiki@shibu.jp - */ - -(function ($) -{ - /** - * small helper function to urldecode strings - */ - function urldecode(x) - { - return decodeURIComponent(x).replace(/\+/g, ' '); - } - - /** - * This function returns the parsed url parameters of the - * current request. Multiple values per key are supported, - * it will always return arrays of strings for the value parts. - */ - function getQueryParameters(s) - { - if (typeof s == 'undefined') - s = document.location.search; - var parts = s.substr(s.indexOf('?') + 1).split('&'); - var result = {}; - for (var i = 0; i < parts.length; i++) - { - var tmp = parts[i].split('=', 2); - var key = urldecode(tmp[0]); - var value = urldecode(tmp[1]); - if (key in result) - { - result[key].push(value); - } - else - { - result[key] = [value]; - } - } - return result; - } - - /** - * highlight a given string on a jquery object by wrapping it in - * span elements with the given class name. - */ - jQuery.fn.highlightText = function(text, className) - { - function highlight(node) - { - if (node.nodeType == 3) - { - var val = node.nodeValue; - var pos = val.toLowerCase().indexOf(text); - if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) - { - var span = document.createElement("span"); - span.className = className; - span.appendChild(document.createTextNode(val.substr(pos, text.length))); - node.parentNode.insertBefore(span, node.parentNode.insertBefore( - document.createTextNode(val.substr(pos + text.length)), - node.nextSibling)); - node.nodeValue = val.substr(0, pos); - } - } - else if (!jQuery(node).is("button, select, textarea")) - { - jQuery.each(node.childNodes, function() { - highlight(this); - }); - } - } - return this.each(function() { - highlight(this); - }); - }; - - /** - * highlight the search words provided in the url in the text - */ - function highlightSearchWords(selector) - { - var params = getQueryParameters(); - var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; - if (terms.length) - { - var body = $(selector); - window.setTimeout(function() - { - $.each(terms, function() - { - body.highlightText(this.toLowerCase(), 'highlighted'); - }); - }, 10); - } - } - - jQuery(document).ready(function () { - highlightSearchWords('body'); - }); -})(jQuery); - |