PageSourceSearch

https://benjitrapp.github.io/js/search-script.js

js benjitrapp.github.io collected 2026-10-03 08:42:11 UTC 12,816 bytes, 222 lines download raw bytes

vendor: 12,816 bytes, lines 1-222
1/*!
2  * Simple-Jekyll-Search
3  * Copyright 2015-2020, Christian Fei
4  * Licensed under the MIT License.
5  */
6! function() {
7    "use strict";
8    var f = {
9        compile: function(r) {
10            return i.template.replace(i.pattern, function(t, e) {
11                var n = i.middleware(e, r[e], i.template);
12                return void 0 !== n ? n : r[e] || t
13            })
14        },
15        setOptions: function(t) {
16            i.pattern = t.pattern || i.pattern, i.template = t.template || i.template, "function" == typeof t.middleware && (i.middleware = t.middleware)
17        }
18    };
19    const i = {
20        pattern: /\{(.*?)\}/g,
21        template: "",
22        middleware: function() {}
23    };
24    var n = function(t, e) {
25            var n = e.length,
26                r = t.length;
27            if (n < r) return !1;
28            if (r === n) return t === e;
29            t: for (var i = 0, o = 0; i < r; i++) {
30                for (var u = t.charCodeAt(i); o < n;)
31                    if (e.charCodeAt(o++) === u) continue t;
32                return !1
33            }
34            return !0
35        },
36        e = new function() {
37            this.matches = function(t, e) {
38                return n(e.toLowerCase(), t.toLowerCase())
39            }
40        },
41        r = new function() {
42            this.matches = function(e, t) {
43                return !!e && (e = e.trim().toLowerCase(), (t = t.trim().toLowerCase()).split(" ").filter(function(t) {
44                    return 0 <= e.indexOf(t)
45                }).length === t.split(" ").length)
46            }
47        },
48        d = {
49            put: function(t) {
50                if (l(t)) return a(t);
51                if (function(t) {
52                        return Boolean(t) && "[object Array]" === Object.prototype.toString.call(t)
53                    }(t)) return function(n) {
54                    const r = [];
55                    s();
56                    for (let t = 0, e = n.length; t < e; t++) l(n[t]) && r.push(a(n[t]));
57                    return r
58                }(t);
59                return undefined
60            },
61            clear: s,
62            search: function(t) {
63                return t ? function(e, n, r, i) {
64                    const o = [];
65                    for (let t = 0; t < e.length && o.length < i.limit; t++) {
66                        var u = function(t, e, n, r) {
67                            for (const i in t)
68                                if (! function(n, r) {
69                                        for (let t = 0, e = r.length; t < e; t++) {
70                                            var i = r[t];
71                                            if (new RegExp(i).test(n)) return !0
72                                        }
73                                        return !1
74                                    }(t[i], r.exclude) && n.matches(t[i], e)) return t
75                        }(e[t], n, r, i);
76                        u && o.push(u)
77                    }
78                    return o
79                }(u, t, c.searchStrategy, c).sort(c.sort) : []
80            },
81            setOptions: function(t) {
82                c = t || {}, c.fuzzy = t.fuzzy || !1, c.limit = t.limit || 10, c.searchStrategy = t.fuzzy ? e : r, c.sort = t.sort || o, c.exclude = t.exclude || []
83            }
84        };
85
86    function o() {
87        return 0
88    }
89    const u = [];
90    let c = {};
91
92    function s() {
93        return u.length = 0, u
94    }
95
96    function l(t) {
97        return Boolean(t) && "[object Object]" === Object.prototype.toString.call(t)
98    }
99
100    function a(t) {
101        return u.push(t), u
102    }
103    c.fuzzy = !1, c.limit = 10, c.searchStrategy = c.fuzzy ? e : r, c.sort = o, c.exclude = [];
104    var p = {
105        load: function(t, e) {
106            const n = window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
107            n.open("GET", t, !0), n.onreadystatechange = h(n, e), n.send()
108        }
109    };
110
111    function h(e, n) {
112        return function() {
113            if (4 === e.readyState && 200 === e.status) try {
114                n(null, JSON.parse(e.responseText))
115            } catch (t) {
116                n(t, null)
117            }
118        }
119    }
120    var m = function y(t) {
121            if (!(e = t) || !("undefined" != typeof e.required && e.required instanceof Array)) throw new Error("-- OptionsValidator: required options missing");
122            var e;
123            if (!(this instanceof y)) return new y(t);
124            const r = t.required;
125            this.getRequiredOptions = function() {
126                return r
127            }, this.validate = function(e) {
128                const n = [];
129                return r.forEach(function(t) {
130                    "undefined" == typeof e[t] && n.push(t)
131                }), n
132            }
133        },
134        w = {
135            merge: function(t, e) {
136                const n = {};
137                for (const r in t) n[r] = t[r], "undefined" != typeof e[r] && (n[r] = e[r]);
138                return n
139            },
140            isJSON: function(t) {
141                try {
142                    return t instanceof Object && JSON.parse(JSON.stringify(t)) ? !0 : !1
143                } catch (e) {
144                    return !1
145                }
146            }
147        };
148    ! function(t) {
149        let i = {
150                searchInput: null,
151                resultsContainer: null,
152                json: [],
153                success: Function.prototype,
154                searchResultTemplate: '<li><a href="{url}" title="{desc}">{title}</a></li>',
155                templateMiddleware: Function.prototype,
156                sortMiddleware: function() {
157                    return 0
158                },
159                noResultsText: "No results found",
160                limit: 10,
161                fuzzy: !1,
162                debounceTime: null,
163                exclude: []
164            },
165            n;
166        const e = function(t, e) {
167            e ? (clearTimeout(n), n = setTimeout(t, e)) : t.call()
168        };
169        var r = ["searchInput", "resultsContainer", "json"];
170        const o = m({
171            required: r
172        });
173
174        function u(t) {
175            d.put(t), i.searchInput.addEventListener("input", function(t) {
176                -1 === [13, 16, 20, 37, 38, 39, 40, 91].indexOf(t.which) && (c(), e(function() {
177                    l(t.target.value)
178                }, i.debounceTime))
179            })
180        }
181
182        function c() {
183            i.resultsContainer.innerHTML = ""
184        }
185
186        function s(t) {
187            i.resultsContainer.innerHTML += t
188        }
189
190        function l(t) {
191            var e;
192            (e = t) && 0 < e.length && (c(), function(e, n) {
193                var r = e.length;
194                if (0 === r) return s(i.noResultsText);
195                for (let t = 0; t < r; t++) e[t].query = n, s(f.compile(e[t]))
196            }(d.search(t), t))
197        }
198
199        function a(t) {
200            throw new Error("SimpleJekyllSearch --- " + t)
201        }
202        t.SimpleJekyllSearch = function(t) {
203            var n;
204            0 < o.validate(t).length && a("You must specify the following required options: " + r), i = w.merge(i, t), f.setOptions({
205                template: i.searchResultTemplate,
206                middleware: i.templateMiddleware
207            }), d.setOptions({
208                fuzzy: i.fuzzy,
209                limit: i.limit,
210                sort: i.sortMiddleware,
211                exclude: i.exclude
212            }), w.isJSON(i.json) ? u(i.json) : (n = i.json, p.load(n, function(t, e) {
213                t && a("failed to get JSON (" + n + ")"), u(e)
214            }));
215            t = {
216                search: l
217            };
218            return "function" == typeof i.success && i.success.call(t), t
219        }
220    }(window)
221}();
222//!function () { "use strict"; var f = { compile: function (r) { return i.template.replace(i.pattern, function (t, e) { var n = i.middleware(e, r[e], i.template); return void 0 !== n ? n : r[e] || t }) }, setOptions: function (t) { i.pattern = t.pattern || i.pattern, i.template = t.template || i.template, "function" == typeof t.middleware && (i.middleware = t.middleware) } }; const i = { pattern: /\{(.*?)\}/g, template: "", middleware: function () { } }; var n = function (t, e) { var n = e.length, r = t.length; if (n < r) return !1; if (r === n) return t === e; t: for (var i = 0, o = 0; i < r; i++) { for (var u = t.charCodeAt(i); o < n;)if (e.charCodeAt(o++) === u) continue t; return !1 } return !0 }, e = new function () { this.matches = function (t, e) { return n(e.toLowerCase(), t.toLowerCase()) } }, r = new function () { this.matches = function (e, t) { return !!e && (e = e.trim().toLowerCase(), (t = t.trim().toLowerCase()).split(" ").filter(function (t) { return 0 <= e.indexOf(t) }).length === t.split(" ").length) } }, d = { put: function (t) { if (l(t)) return a(t); if (function (t) { return Boolean(t) && "[object Array]" === Object.prototype.toString.call(t) }(t)) return function (n) { const r = []; s(); for (let t = 0, e = n.length; t < e; t++)l(n[t]) && r.push(a(n[t])); return r }(t); return undefined }, clear: s, search: function (t) { return t ? function (e, n, r, i) { const o = []; for (let t = 0; t < e.length && o.length < i.limit; t++) { var u = function (t, e, n, r) { for (const i in t) if (!function (n, r) { for (let t = 0, e = r.length; t < e; t++) { var i = r[t]; if (new RegExp(i).test(n)) return !0 } return !1 }(t[i], r.exclude) && n.matches(t[i], e)) return t }(e[t], n, r, i); u && o.push(u) } return o }(u, t, c.searchStrategy, c).sort(c.sort) : [] }, setOptions: function (t) { c = t || {}, c.fuzzy = t.fuzzy || !1, c.limit = t.limit || 10, c.searchStrategy = t.fuzzy ? e : r, c.sort = t.sort || o, c.exclude = t.exclude || [] } }; function o() { return 0 } const u = []; let c = {}; function s() { return u.length = 0, u } function l(t) { return Boolean(t) && "[object Object]" === Object.prototype.toString.call(t) } function a(t) { return u.push(t), u } c.fuzzy = !1, c.limit = 10, c.searchStrategy = c.fuzzy ? e : r, c.sort = o, c.exclude = []; var p = { load: function (t, e) { const n = window.XMLHttpRequest ? new window.XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"); n.open("GET", t, !0), n.onreadystatechange = h(n, e), n.send() } }; function h(e, n) { return function () { if (4 === e.readyState && 200 === e.status) try { n(null, JSON.parse(e.responseText)) } catch (t) { n(t, null) } } } var m = function y(t) { if (!(e = t) || !("undefined" != typeof e.required && e.required instanceof Array)) throw new Error("-- OptionsValidator: required options missing"); var e; if (!(this instanceof y)) return new y(t); const r = t.required; this.getRequiredOptions = function () { return r }, this.validate = function (e) { const n = []; return r.forEach(function (t) { "undefined" == typeof e[t] && n.push(t) }), n } }, w = { merge: function (t, e) { const n = {}; for (const r in t) n[r] = t[r], "undefined" != typeof e[r] && (n[r] = e[r]); return n }, isJSON: function (t) { try { return t instanceof Object && JSON.parse(JSON.stringify(t)) ? !0 : !1 } catch (e) { return !1 } } }; !function (t) { let i = { searchInput: null, resultsContainer: null, json: [], success: Function.prototype, searchResultTemplate: '<li><a href="{url}" title="{desc}">{title}</a></li>', templateMiddleware: Function.prototype, sortMiddleware: function () { return 0 }, noResultsText: "No results found", limit: 10, fuzzy: !1, debounceTime: null, exclude: [] }, n; const e = function (t, e) { e ? (clearTimeout(n), n = setTimeout(t, e)) : t.call() }; var r = ["searchInput", "resultsContainer", "json"]; const o = m({ required: r }); function u(t) { d.put(t), i.searchInput.addEventListener("input", function (t) { -1 === [13, 16, 20, 37, 38, 39, 40, 91].indexOf(t.which) && (c(), e(function () { l(t.target.value) }, i.debounceTime)) }) } function c() { i.resultsContainer.innerHTML = "" } function s(t) { i.resultsContainer.innerHTML += t } function l(t) { var e; (e = t) && 0 < e.length && (c(), function (e, n) { var r = e.length; if (0 === r) return s(i.noResultsText); for (let t = 0; t < r; t++)e[t].query = n, s(f.compile(e[t])) }(d.search(t), t)) } function a(t) { throw new Error("SimpleJekyllSearch --- " + t) } t.SimpleJekyllSearch = function (t) { var n; 0 < o.validate(t).length && a("You must specify the following required options: " + r), i = w.merge(i, t), f.setOptions({ template: i.searchResultTemplate, middleware: i.templateMiddleware }), d.setOptions({ fuzzy: i.fuzzy, limit: i.limit, sort: i.sortMiddleware, exclude: i.exclude }), w.isJSON(i.json) ? u(i.json) : (n = i.json, p.load(n, function (t, e) { t && a("failed to get JSON (" + n + ")"), u(e) })); t = { search: l }; return "function" == typeof i.success && i.success.call(t), t } }(window) }();

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.