PageSourceSearch

https://chioaachencampus.com/classes/plugins/ngpluginlayout/ngpluginlayoutflexr/js/searchbox.js

js chioaachencampus.com collected 2026-10-07 20:02:44 UTC 5,557 bytes, 134 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    $.fn.sqrSearchBox = function () {
5        $(this).each(function () {
6            let that = $(this),
7                inputcriteria = that.find('input'),
8                searchform = that.find('form'),
9                restsuggest = searchform.attr('data-rest'),
10                previewmode = searchform.attr('data-previewmode')==='true',
11                maxbooster = parseInt(searchform.attr('data-maxbooster')),
12                div = that.find('div'),
13                criteria = '',
14                activesuggestion = -1,
15                allsuggestions = [];
16
17            function hideSuggest() {
18                div.empty().css('display', 'none');
19            }
20
21
22            function handleSuggestKeyUp(e) {
23                switch (e.keyCode) {
24                    case 40:
25                    case 38:
26                        e.preventDefault();
27                        return;
28                    case 13:
29                    case 27:
30                        return;
31                }
32
33                activesuggestion = -1;
34                criteria = inputcriteria.val();
35
36                if (criteria !== '') {
37                    $.ajax({
38                        url: restsuggest,
39                        data: {
40                            criteria: criteria,
41                            previewmode: previewmode,
42                            maxbooster: maxbooster
43                        },
44                        dataType: 'json',
45                        type: 'GET',
46                        success: handleSuggestSuccess
47                    });
48                } else {
49                    hideSuggest();
50                }
51            }
52
53            function setActiveSuggestion() {
54                for (let i = 0; i < allsuggestions.length; i++) {
55                    if (activesuggestion === i) {
56                        allsuggestions.eq(i).addClass('sqrsearchboxsuggestion');
57                        if (allsuggestions.eq(i).attr('href') === '#') inputcriteria.val(allsuggestions.eq(i).text());
58                    } else {
59                        allsuggestions.eq(i).removeClass('sqrsearchboxsuggestion');
60                    }
61                }
62            }
63
64            function handleSuggestKeyDown(e) {
65                switch (e.keyCode) {
66                    case 40:
67                        if (activesuggestion < allsuggestions.length - 1) {
68                            activesuggestion++;
69                            setActiveSuggestion();
70                        }
71                        e.preventDefault();
72                        break;
73                    case 38:
74                        if (activesuggestion > 0) {
75                            activesuggestion--;
76                            setActiveSuggestion();
77                        }
78                        e.preventDefault();
79                        break;
80                    case 27:
81                        hideSuggest();
82                        e.preventDefault();
83                        break;
84                    case 13:
85                        if (activesuggestion >= 0 && allsuggestions.eq(activesuggestion).attr('href') !== '#') {
86                            e.preventDefault();
87                            window.location.href = allsuggestions.eq(activesuggestion).attr('href');
88                        } else {
89                            hideSuggest();
90                        }
91
92                        break;
93                }
94            }
95
96            function handleSuggestSuccess(data) {
97                if (data.result.criteria === criteria) {
98                    hideSuggest();
99
100                    const svg = '<svg width="24" height="24" viewBox="0 0 24.00 24.00"><path fill="currentColor" d="M 7.69406,19.1143L 12.9996,16.518L 16.3059,19.149L 15.1779,14.2281L 18.9702,10.9477L 13.9819,10.5032L 11.9996,5.85588L 10.0174,10.4691L 5.02835,10.913L 8.82133,14.2281L 7.69406,19.1143 Z M 4.58452,23.4019L 6.54272,14.9696L -3.2472e-005,9.29913L 8.63243,8.55028L 11.9996,0.598557L 15.3661,8.55028L 24,9.29913L 17.4565,14.9696L 19.4147,23.4019L 11.9996,18.9281L 4.58452,23.4019 Z "/></svg>';
101                    for (let i = 0; i < data.result.booster.length; i++) {
102                        div.append($('<a>').attr('href', data.result.booster[i].url).append(svg).append($('<span>').css('font-weight', 'bold').text(data.result.booster[i].caption)));
103                    }
104
105                    for (let i = 0; i < data.result.items.length; i++) {
106                        div.append($('<a>').attr('href', '#').on('click', handleSuggestClick).append('<span>').append($('<b>').text(data.result.items[i].substring(0, criteria.length))).append(data.result.items[i].substring(criteria.length)));
107                    }
108                    allsuggestions = div.children('a');
109                    div.css('display', 'block');
110                }
111            }
112
113            function handleSuggestClick(e) {
114                e.preventDefault();
115                criteria = $(this).text()
116                inputcriteria.val(criteria);
117                hideSuggest();
118                searchform.submit();
119            }
120
121            if (restsuggest !== undefined) {
122                inputcriteria.on('keyup', handleSuggestKeyUp);
123                inputcriteria.on('keydown', handleSuggestKeyDown);
124            }
125
126        });
127    }
128
129
130}(jQuery));
131
132$(function () {
133    $('#searchbox').sqrSearchBox();
134});

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.