PageSourceSearch

https://frontrange.edu/_resources/js/ou-search-header.js

js frontrange.edu collected 2026-10-01 13:52:37 UTC 34,879 bytes, 756 lines download raw bytes

1// function to handle autocomplete callback
2function ouSearchAutoCompleteHeader(data) {
3    if (data.completions) {
4        // remove autocompletes with the value of the :infield
5        ouSearchObjectHeader.autoCompleteData = data.completions.filter(function (item) {
6            return (item.indexOf(ouSearchObjectHeader.infieldText) === -1)
7        });
8    }
9    else {
10        ouSearchObjectHeader.autoCompleteData = null;
11    }
12}
13
14// function to handle the callback of the search results
15function ousearchresults(data) {
16    ouSearchObjectHeader.determineData(data);
17}
18
19// function to handle the callback of the ousearch help
20function ousearchhelpHeader(data) {
21    if (data.ousearchhelplist.length != 0) { ouSearchObjectHeader.helpUrlItems = data.ousearchhelplist; }
22}
23
24// variables that should only be changed if needed.
25var ouSearchSettingsHeader = {
26    helpListUrl: "//websitesearch.moderncampus.net/custom/ou-search-help-list.json",
27    autoCompleteUrl: "//websitesearch.moderncampus.net/texis/search/autocomplete.json?callback=ouSearchAutoCompleteHeader",
28    autoCompleteScriptId: "ou-search-autocomplete-script",
29    brandingIcon: "//cdn.omniupdate.com/ou-search/v4.0/img/ou-search-logo.png",
30    brandingLink: "http://omniupdate.com/products/modules.html#ousearch",
31    searchDomain: "//websitesearch.moderncampus.net/texis/search/",
32    vueElementId: "#ou-header-search-output",
33    vueTemplateId: "#ou-header-search-template",
34    searchId: "ou-header-search-",
35    formSubmitId: "ou-header-search-submission",
36    cacheBuster: "&coryMaddensCacheBuster=",
37    advancedId: "ou-header-search-open-advanced",
38    parametricId: "ou-header-search-parametric-results",
39    parametricClass: "ou-header-search-parametric-display",
40    resultCallback: "ousearchresults",
41    helpListCallback: "ousearchhelpHeader",
42    infieldText: "infield:",
43    infieldTextEnc: "infield:enc:",
44    loadingImage: "//cdn.omniupdate.com/ou-search/v3.0/images/ou-search-loading.gif",
45    validOrder: ["r", "dd", "url"],
46    validProx: ["line", "sentence", "paragraph", "page"],
47    validSufs: [0, 1, 2, 3],
48    validOptions: [0, 250, 500, 750, 1000],
49    validOptionsTwo: [0, 31, 62, 125, 250]
50};
51
52/* create the Vue object for the search results */
53var ouSearchObjectHeader = new Vue({
54    el: ouSearchSettingsHeader.vueElementId,
55	template: ouSearchSettingsHeader.vueTemplateId,
56    data: {
57        // loading icon, most important
58        loadingImage: ouSearchControl.loadingImage || ouSearchSettingsHeader.loadingImage,
59        // new options added to the object, these shouldn't be used in the HTML
60        searchDomain: ouSearchSettingsHeader.searchDomain,
61        validOrder: ouSearchSettingsHeader.validOrder,
62        validProx: ouSearchSettingsHeader.validProx,
63        validSufs: ouSearchSettingsHeader.validSufs,
64        validOptions: ouSearchSettingsHeader.validOptions,
65        validOptionsTwo: ouSearchSettingsHeader.validOptionsTwo,
66        autoCompleteScriptId: ouSearchSettingsHeader.autoCompleteScriptId,
67        parametricId: ouSearchSettingsHeader.parametricId,
68        parametricClass: ouSearchSettingsHeader.parametricClass,
69        infieldTextEnc: ouSearchSettingsHeader.infieldTextEnc,
70        infieldText: ouSearchSettingsHeader.infieldText,
71        formSubmitId: ouSearchSettingsHeader.formSubmitId,
72        // helpListUrl: ouSearchSettingsHeader.helpListUrl,
73        autoCompleteUrl: ouSearchSettingsHeader.autoCompleteUrl,
74        formSubmitId: ouSearchSettingsHeader.formSubmitId,
75        advancedId: ouSearchSettingsHeader.advancedId,
76        cacheBuster: ouSearchSettingsHeader.cacheBuster,
77        // search profile
78        pr: ouSearchControl.pr,
79        // branding icon
80        brandingDisplay: ouSearchControl.brandingDisplay || false,
81        brandingIcon: ouSearchSettingsHeader.brandingIcon,
82        brandingLink: ouSearchSettingsHeader.brandingLink,
83        // id for the parametric fields
84        searchId: ouSearchSettingsHeader.searchId,
85        // advanced options
86        enableAdvanced: ouSearchControl.enableAdvanced,
87        advancedActive: false,
88        // queries
89        currentQueryName: "",
90        currentFullQuery: "",
91        currentFullQueryOther: "",
92        displayQuery: "",
93        tempQuery: "",
94        query: "",
95        uq: "",
96        directoryFilter: ouSearchControl.directoryFilter,
97        allowUqRemoval: true,
98        prox: "",
99        sufs: "",
100        order: "",
101        rorder: "",
102        rprox: "",
103        rdfreq: "",
104        rwfreq: "",
105        rlead: "",
106        rdepth: "",
107        // data that gets returned by OU Search
108        jump: 0,
109        fullJump: "",
110        results: null,
111        spelling: null,
112        bestbets: null,
113        pagination: null,
114        next: null,
115        prev: null,
116        total: null,
117        start: null,
118        end: null,
119        parametric: null,
120        selectedParametric: null,
121        helpUrlItems: null,
122        extraPaginationLinks: null,
123        itemsNotFound: false,
124        noResults: false,
125        // user text controls
126        formPlaceholder: ouSearchControl.formPlaceholder || "Search Site...",
127        errorMessage: ouSearchControl.errorMessage || "Sorry, no results were found for",
128        numberPagination: ouSearchControl.numberPagination,
129        totalResultsOutput: ouSearchControl.totalResultsOutput,
130        totalResultsRange: ouSearchControl.totalResultsRange || "to",
131        totalResultsText: ouSearchControl.totalResultsText || "Total Results:",
132        totalResultsDisplayText: ouSearchControl.totalResultsDisplayText || "Displaying:",
133        totalResultsAfterText: ouSearchControl.totalResultsAfter || "",
134        nextText: ouSearchControl.nextText || "Next",
135        prevText: ouSearchControl.prevText || "Previous",
136        parametricHeadingText: ouSearchControl.parametricHeadingText || "Refine Search",
137        bestBetHeadingText: ouSearchControl.bestBetHeadingText || "Featured Results",
138        didYouMeanText: ouSearchControl.didYouMeanText || "Did you mean:",
139        formSubmitButtonText: ouSearchControl.formSubmitButtonText || "Submit",
140        filteringByText: ouSearchControl.filteringByText || "Filtering by:",
141        filteringByButton: ouSearchControl.filteringByButton || "Remove",
142        parametricMobileButton: ouSearchControl.parametricMobileButton || "View Parametric",
143        // autocomplete
144        autoCompleteLength: ouSearchControl.autoCompleteLength || 2,
145        autoCompleteData: null,
146        autoCompleteFocus: -1,
147        showingAutoComplete: false
148    },
149    methods: {
150        // function to set all the items data
151        determineData: function (data) {
152            var checking = false;
153            if (data.results.length != 0) { this.results = data.results; } 
154            if (data.pages.length != 0) { this.pagination = data.pages; }
155            if (data.spelling.length != 0) { this.spelling = data.spelling; }
156            this.query = data.searchsummary[0].query;
157            this.next = data.next;
158            this.prev = data.prev;
159            this.total = data.searchsummary[0].total;
160            this.start = data.searchsummary[0].start;
161            this.end = data.searchsummary[0].end;
162            if (this.query === "") { checking = false; }
163            this.noResults = checking;
164            this.prox = data.searchsummary[0].proximity;
165            this.sufs = data.searchsummary[0].suffixes;
166            this.order = data.searchsummary[0].order;
167            this.rorder = data.searchsummary[0].rankorder;
168            this.rprox = data.searchsummary[0].rankproximity;
169            this.rdfreq = data.searchsummary[0].rankdatabasefrequency;
170            this.rwfreq = data.searchsummary[0].rankdocumentfrequency;
171            this.rlead = data.searchsummary[0].rankposition;
172            this.rdepth = data.searchsummary[0].rankdepth;
173            this.itemsNotFound = false;
174        },
175        // serialize the data into a query string format
176        serialize: function (obj) {
177            var str = [];
178            for (var p in obj) {
179                if (obj.hasOwnProperty(p)) {
180                    str.push(p + "=" + obj[p]);
181                }
182            }
183            return str.join("&");
184        },
185        // actually "fetch the data" by adding a script to the head
186        fetchData: function () {
187            var searchData;
188            this.itemsNotFound = true;
189            // if the query is not we, just need to fetch the settings
190            if (this.query === null) {
191                searchData = { "pr": this.pr };
192            }
193            else {
194                searchData = {
195                    "pr": this.pr,
196                    "rdepth": this.rdepth,
197                    "query": this.query,
198                    "jump": this.jump,
199                    "uq": this.uq,
200                    "prox": this.prox,
201                    "sufs": this.sufs,
202                    "order": this.order,
203                    "rorder": this.rorder,
204                    "rprox": this.rprox,
205                    "rdfreq": this.rdfreq,
206                    "rwfreq": this.rwfreq,
207                    "rlead": this.rlead,
208                };
209            }
210            if (this.query && this.query.indexOf(this.infieldTextEnc) > -1) {
211                var parametric = this.query.split(this.infieldTextEnc)
212                parametric[1] = encodeURIComponent(parametric[1])
213                searchData.query = parametric[0] + this.infieldTextEnc + parametric[1]
214            }
215            var script = document.createElement('script');
216            script.src = this.searchDomain + "?" + this.serialize(searchData) + this.cacheBuster + new Date().getTime();
217            document.getElementsByTagName('head')[0].appendChild(script);
218        },
219        /* function to calculate extra pagination links */
220        extraPaginationLinksFun: function () {
221            return window.location.search.replace(this.fullJump, "").replace(this.currentFullQuery, "").replace(this.currentFullQueryOther, "");
222        },
223        // check to see if in Array
224        inArray: function (target, array) {
225            for (var i = 0; i < array.length; i++) {
226                //number
227                if (array[i] == target) { return true; }
228                // string
229                if (array[i] === target) { return true; }
230            }
231            return false;
232        },
233        // function to get the parameters by name from the URL
234        getParameterByName: function (name, url) {
235            if (!url) url = window.location.href;
236            name = name.replace(/[\[\]]/g, "\\$&");
237            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
238                results = regex.exec(url);
239            if (!results) return null;
240            if (!results[2]) return "";
241            return decodeURIComponent(results[2].replace(/\+/g, " "));
242        },
243        // listen to the search box for certain keys on the up event, these events create the term for searching
244        autoCompleteSearchKeyUp: function (e) {
245            var searchVal = e.target.value;
246            // make sure it none of the arrow keys, however if the right arrow and the autoCompleteFocus is not the input field, redo the autcomplete suggestions
247            if (e.keyCode != 40 && (e.keyCode != 39 || this.autoCompleteFocus != -1) && e.keyCode != 38 && e.keyCode != 37 && e.keyCode != 27 && e.keyCode != 9) {
248                if (searchVal.length >= this.autoCompleteLength) {
249                    var script = document.createElement('script');
250                    var src = this.autoCompleteUrl + "&pr=" + this.pr + "&term=" + searchVal + this.cacheBuster + new Date().getTime();
251                    script.src = src;
252                    script.id = this.autoCompleteScriptId;
253                    var autoCompleteScriptTag = document.getElementById(this.autoCompleteScriptId);
254                    if (autoCompleteScriptTag !== null) {
255                        autoCompleteScriptTag.parentNode.removeChild(autoCompleteScriptTag);
256                    }
257                    document.getElementsByTagName('head')[0].appendChild(script);
258                    // something changed with the autcomplete so reset the active
259                    this.removeAutoCompleteActive();
260                    this.showingAutoComplete = true;
261                }
262                else {
263                    this.showingAutoComplete = false;
264                }
265                this.tempQuery = searchVal;
266            }
267            if (!e.target.value.length) {
268                this.resetAutoComplete();
269            }
270        },
271        // listen to the search box for certain keys on the down event
272        autoCompleteSearchKeyDown: function (e) {
273            var self = this;
274            // shift key and tab key
275            if (e.shiftKey && e.keyCode == 9) { self.showingAutoComplete = false; }
276            // tab key, close autocomplete and navigate to next item.
277            else if (e.keyCode == 9 && self.showingAutoComplete) {
278                e.preventDefault();
279                self.showingAutoComplete = false;
280                document.getElementById("ousearchq").blur()
281                if (document.getElementById(self.advancedId)) {
282                    window.setTimeout(function () {
283                        document.getElementById(self.advancedId).focus()
284                    }, 100);
285                }
286                if (document.getElementById(self.formSubmitId) && document.getElementById(self.advancedId) == null) {
287                    window.setTimeout(function () {
288                        document.getElementById(self.formSubmitId).focus()
289                    }, 100);
290                }
291            }
292            else if (e.keyCode == 37) {
293                this.removeAutoCompleteActive();
294            }
295            // escape key close the autocomplete
296            else if (e.keyCode == 27) {
297                e.preventDefault();
298                self.showingAutoComplete = false;
299            }
300            // up key allow navigating through the suggesstion list.
301            else if (e.keyCode == 40 && self.showingAutoComplete) {
302                e.preventDefault();
303                /* key down is pressed, increase the autoCompleteFocus variable:*/
304                self.autoCompleteFocus++;
305                self.determineCurrentAutoComplete(e);
306            }
307            // down key allow navigating through the suggesstion list.
308            else if (e.keyCode == 38 && self.showingAutoComplete) {
309                e.preventDefault();
310                self.autoCompleteFocus--;
311                /* key up is pressed, decrease the autoCompleteFocus variable:*/
312                self.determineCurrentAutoComplete(e);
313            }
314            if (!e.target.value.length) {
315                self.resetAutoComplete();
316            }
317        },
318        // function for determine the current autocomplete value that is selected
319        determineCurrentAutoComplete: function (e) {
320            if (this.autoCompleteData) {
321                if (this.autoCompleteFocus == -2) { this.autoCompleteFocus = this.autoCompleteData.length - 1; }
322                if (this.autoCompleteFocus < 0 || (this.autoCompleteFocus >= this.autoCompleteData.length)) {
323                    this.removeAutoCompleteActive();
324                    e.target.value = this.tempQuery;
325                }
326                else {
327                    e.target.value = this.autoCompleteData[this.autoCompleteFocus];
328                }
329            }
330        },
331        // function to reset the auto complete
332        resetAutoComplete: function () {
333            this.showingAutoComplete = false;
334            this.removeAutoCompleteActive();
335        },
336        // function to only un set the current focus
337        removeAutoCompleteActive: function () {
338            this.autoCompleteFocus = -1;
339        },
340        // set the active autocomplete value
341        setActiveAutoCompleteSearch: function (e, index) {
342            this.autoCompleteFocus = index;
343            if (e.target && e.target.value != "" && (e.target.value.length >= this.autoCompleteLength)) {
344                this.showingAutoComplete = true;
345            }
346        },
347        // function to set the autocomplete active state
348        setActiveAutoComplete: function (index) {
349            this.autoCompleteFocus = index;
350            this.showingAutoComplete = true;
351        },
352        // set document click to remove the autocomplete but show when you click in the for field
353        documentClickCheck: function (e, self) {
354            self.removeAutoCompleteActive();
355            if (e.target.getAttribute("id") == "ousearchq" && e.target.value && e.target.value.length >= self.autoCompleteLength) {
356                self.showingAutoComplete = true;
357            }
358            else {
359                self.showingAutoComplete = false;
360            }
361        },
362        // function to set the document click
363        setDocumentClick: function () {
364            var self = this;
365            document.addEventListener("click", function (e) {
366                self.documentClickCheck(e, self)
367            });
368        }
369    },
370    mounted: function () {
371        var self = this;
372        self.fetchData();
373        self.setDocumentClick();
374        document.getElementById("header-ousearchq").value = self.displayQuery
375        self.extraPaginationLinks = self.extraPaginationLinksFun();
376    }
377});
378
379
380// function to handle autocomplete callback
381function ouSearchStickyAutoCompleteHeader(data) {
382    if (data.completions) {
383        // remove autocompletes with the value of the :infield
384        ouSearchStickyObjectHeader.autoCompleteData = data.completions.filter(function (item) {
385            return (item.indexOf(ouSearchStickyObjectHeader.infieldText) === -1)
386        });
387    }
388    else {
389        ouSearchStickyObjectHeader.autoCompleteData = null;
390    }
391}
392
393// function to handle the callback of the search results
394function ousearchstickyresults(data) {
395    ouSearchStickyObjectHeader.determineData(data);
396}
397
398// function to handle the callback of the ousearch help
399function ousearchstickyhelpHeader(data) {
400    if (data.ousearchhelplist.length != 0) { ouSearchStickyObjectHeader.helpUrlItems = data.ousearchhelplist; }
401}
402
403// variables that should only be changed if needed.
404var ouSearchStickySettingsHeader = {
405    helpListUrl: "//websitesearch.moderncampus.net/custom/ou-search-help-list.json",
406    autoCompleteUrl: "//websitesearch.moderncampus.net/texis/search/autocomplete.json?callback=ouSearchStickyAutoCompleteHeader",
407    autoCompleteScriptId: "ou-search-autocomplete-script",
408    brandingIcon: "//cdn.omniupdate.com/ou-search/v4.0/img/ou-search-logo.png",
409    brandingLink: "http://omniupdate.com/products/modules.html#ousearch",
410    searchDomain: "//websitesearch.moderncampus.net/texis/search/",
411    vueElementId: "#search-desktop-sticky",
412    vueTemplateId: "#ou-header-search-template",
413    searchId: "ou-header-search-",
414    formSubmitId: "ou-header-search-submission",
415    cacheBuster: "&coryMaddensCacheBuster=",
416    advancedId: "ou-header-search-open-advanced",
417    parametricId: "ou-header-search-parametric-results",
418    parametricClass: "ou-header-search-parametric-display",
419    resultCallback: "ousearchstickyresults",
420    helpListCallback: "ousearchstickyhelpHeader",
421    infieldText: "infield:",
422    infieldTextEnc: "infield:enc:",
423    loadingImage: "//cdn.omniupdate.com/ou-search/v3.0/images/ou-search-loading.gif",
424    validOrder: ["r", "dd", "url"],
425    validProx: ["line", "sentence", "paragraph", "page"],
426    validSufs: [0, 1, 2, 3],
427    validOptions: [0, 250, 500, 750, 1000],
428    validOptionsTwo: [0, 31, 62, 125, 250]
429};
430
431/* create the Vue object for the search results */
432var ouSearchStickyObjectHeader = new Vue({
433    el: ouSearchStickySettingsHeader.vueElementId,
434	template: ouSearchStickySettingsHeader.vueTemplateId,
435    data: {
436        // loading icon, most important
437        loadingImage: ouSearchControl.loadingImage || ouSearchStickySettingsHeader.loadingImage,
438        // new options added to the object, these shouldn't be used in the HTML
439        searchDomain: ouSearchStickySettingsHeader.searchDomain,
440        validOrder: ouSearchStickySettingsHeader.validOrder,
441        validProx: ouSearchStickySettingsHeader.validProx,
442        validSufs: ouSearchStickySettingsHeader.validSufs,
443        validOptions: ouSearchStickySettingsHeader.validOptions,
444        validOptionsTwo: ouSearchStickySettingsHeader.validOptionsTwo,
445        autoCompleteScriptId: ouSearchStickySettingsHeader.autoCompleteScriptId,
446        parametricId: ouSearchStickySettingsHeader.parametricId,
447        parametricClass: ouSearchStickySettingsHeader.parametricClass,
448        infieldTextEnc: ouSearchStickySettingsHeader.infieldTextEnc,
449        infieldText: ouSearchStickySettingsHeader.infieldText,
450        formSubmitId: ouSearchStickySettingsHeader.formSubmitId,
451        // helpListUrl: ouSearchStickySettingsHeader.helpListUrl,
452        autoCompleteUrl: ouSearchStickySettingsHeader.autoCompleteUrl,
453        formSubmitId: ouSearchStickySettingsHeader.formSubmitId,
454        advancedId: ouSearchStickySettingsHeader.advancedId,
455        cacheBuster: ouSearchStickySettingsHeader.cacheBuster,
456        // search profile
457        pr: ouSearchControl.pr,
458        // branding icon
459        brandingDisplay: ouSearchControl.brandingDisplay || false,
460        brandingIcon: ouSearchStickySettingsHeader.brandingIcon,
461        brandingLink: ouSearchStickySettingsHeader.brandingLink,
462        // id for the parametric fields
463        searchId: ouSearchStickySettingsHeader.searchId,
464        // advanced options
465        enableAdvanced: ouSearchControl.enableAdvanced,
466        advancedActive: false,
467        // queries
468        currentQueryName: "",
469        currentFullQuery: "",
470        currentFullQueryOther: "",
471        displayQuery: "",
472        tempQuery: "",
473        query: "",
474        uq: "",
475        directoryFilter: ouSearchControl.directoryFilter,
476        allowUqRemoval: true,
477        prox: "",
478        sufs: "",
479        order: "",
480        rorder: "",
481        rprox: "",
482        rdfreq: "",
483        rwfreq: "",
484        rlead: "",
485        rdepth: "",
486        // data that gets returned by OU Search
487        jump: 0,
488        fullJump: "",
489        results: null,
490        spelling: null,
491        bestbets: null,
492        pagination: null,
493        next: null,
494        prev: null,
495        total: null,
496        start: null,
497        end: null,
498        parametric: null,
499        selectedParametric: null,
500        helpUrlItems: null,
501        extraPaginationLinks: null,
502        itemsNotFound: false,
503        noResults: false,
504        // user text controls
505        formPlaceholder: ouSearchControl.formPlaceholder || "Search Site...",
506        errorMessage: ouSearchControl.errorMessage || "Sorry, no results were found for",
507        numberPagination: ouSearchControl.numberPagination,
508        totalResultsOutput: ouSearchControl.totalResultsOutput,
509        totalResultsRange: ouSearchControl.totalResultsRange || "to",
510        totalResultsText: ouSearchControl.totalResultsText || "Total Results:",
511        totalResultsDisplayText: ouSearchControl.totalResultsDisplayText || "Displaying:",
512        totalResultsAfterText: ouSearchControl.totalResultsAfter || "",
513        nextText: ouSearchControl.nextText || "Next",
514        prevText: ouSearchControl.prevText || "Previous",
515        parametricHeadingText: ouSearchControl.parametricHeadingText || "Refine Search",
516        bestBetHeadingText: ouSearchControl.bestBetHeadingText || "Featured Results",
517        didYouMeanText: ouSearchControl.didYouMeanText || "Did you mean:",
518        formSubmitButtonText: ouSearchControl.formSubmitButtonText || "Submit",
519        filteringByText: ouSearchControl.filteringByText || "Filtering by:",
520        filteringByButton: ouSearchControl.filteringByButton || "Remove",
521        parametricMobileButton: ouSearchControl.parametricMobileButton || "View Parametric",
522        // autocomplete
523        autoCompleteLength: ouSearchControl.autoCompleteLength || 2,
524        autoCompleteData: null,
525        autoCompleteFocus: -1,
526        showingAutoComplete: false
527    },
528    methods: {
529        // function to set all the items data
530        determineData: function (data) {
531            var checking = false;
532            if (data.results.length != 0) { this.results = data.results; } 
533            if (data.pages.length != 0) { this.pagination = data.pages; }
534            if (data.spelling.length != 0) { this.spelling = data.spelling; }
535            this.query = data.searchsummary[0].query;
536            this.next = data.next;
537            this.prev = data.prev;
538            this.total = data.searchsummary[0].total;
539            this.start = data.searchsummary[0].start;
540            this.end = data.searchsummary[0].end;
541            if (this.query === "") { checking = false; }
542            this.noResults = checking;
543            this.prox = data.searchsummary[0].proximity;
544            this.sufs = data.searchsummary[0].suffixes;
545            this.order = data.searchsummary[0].order;
546            this.rorder = data.searchsummary[0].rankorder;
547            this.rprox = data.searchsummary[0].rankproximity;
548            this.rdfreq = data.searchsummary[0].rankdatabasefrequency;
549            this.rwfreq = data.searchsummary[0].rankdocumentfrequency;
550            this.rlead = data.searchsummary[0].rankposition;
551            this.rdepth = data.searchsummary[0].rankdepth;
552            this.itemsNotFound = false;
553        },
554        // serialize the data into a query string format
555        serialize: function (obj) {
556            var str = [];
557            for (var p in obj) {
558                if (obj.hasOwnProperty(p)) {
559                    str.push(p + "=" + obj[p]);
560                }
561            }
562            return str.join("&");
563        },
564        // actually "fetch the data" by adding a script to the head
565        fetchData: function () {
566            var searchData;
567            this.itemsNotFound = true;
568            // if the query is not we, just need to fetch the settings
569            if (this.query === null) {
570                searchData = { "pr": this.pr };
571            }
572            else {
573                searchData = {
574                    "pr": this.pr,
575                    "rdepth": this.rdepth,
576                    "query": this.query,
577                    "jump": this.jump,
578                    "uq": this.uq,
579                    "prox": this.prox,
580                    "sufs": this.sufs,
581                    "order": this.order,
582                    "rorder": this.rorder,
583                    "rprox": this.rprox,
584                    "rdfreq": this.rdfreq,
585                    "rwfreq": this.rwfreq,
586                    "rlead": this.rlead,
587                };
588            }
589            if (this.query && this.query.indexOf(this.infieldTextEnc) > -1) {
590                var parametric = this.query.split(this.infieldTextEnc)
591                parametric[1] = encodeURIComponent(parametric[1])
592                searchData.query = parametric[0] + this.infieldTextEnc + parametric[1]
593            }
594            var script = document.createElement('script');
595            script.src = this.searchDomain + "?" + this.serialize(searchData) + this.cacheBuster + new Date().getTime();
596            document.getElementsByTagName('head')[0].appendChild(script);
597        },
598        /* function to calculate extra pagination links */
599        extraPaginationLinksFun: function () {
600            return window.location.search.replace(this.fullJump, "").replace(this.currentFullQuery, "").replace(this.currentFullQueryOther, "");
601        },
602        // check to see if in Array
603        inArray: function (target, array) {
604            for (var i = 0; i < array.length; i++) {
605                //number
606                if (array[i] == target) { return true; }
607                // string
608                if (array[i] === target) { return true; }
609            }
610            return false;
611        },
612        // function to get the parameters by name from the URL
613        getParameterByName: function (name, url) {
614            if (!url) url = window.location.href;
615            name = name.replace(/[\[\]]/g, "\\$&");
616            var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
617                results = regex.exec(url);
618            if (!results) return null;
619            if (!results[2]) return "";
620            return decodeURIComponent(results[2].replace(/\+/g, " "));
621        },
622        // listen to the search box for certain keys on the up event, these events create the term for searching
623        autoCompleteSearchKeyUp: function (e) {
624            var searchVal = e.target.value;
625            // make sure it none of the arrow keys, however if the right arrow and the autoCompleteFocus is not the input field, redo the autcomplete suggestions
626            if (e.keyCode != 40 && (e.keyCode != 39 || this.autoCompleteFocus != -1) && e.keyCode != 38 && e.keyCode != 37 && e.keyCode != 27 && e.keyCode != 9) {
627                if (searchVal.length >= this.autoCompleteLength) {
628                    var script = document.createElement('script');
629                    var src = this.autoCompleteUrl + "&pr=" + this.pr + "&term=" + searchVal + this.cacheBuster + new Date().getTime();
630                    script.src = src;
631                    script.id = this.autoCompleteScriptId;
632                    var autoCompleteScriptTag = document.getElementById(this.autoCompleteScriptId);
633                    if (autoCompleteScriptTag !== null) {
634                        autoCompleteScriptTag.parentNode.removeChild(autoCompleteScriptTag);
635                    }
636                    document.getElementsByTagName('head')[0].appendChild(script);
637                    // something changed with the autcomplete so reset the active
638                    this.removeAutoCompleteActive();
639                    this.showingAutoComplete = true;
640                }
641                else {
642                    this.showingAutoComplete = false;
643                }
644                this.tempQuery = searchVal;
645            }
646            if (!e.target.value.length) {
647                this.resetAutoComplete();
648            }
649        },
650        // listen to the search box for certain keys on the down event
651        autoCompleteSearchKeyDown: function (e) {
652            var self = this;
653            // shift key and tab key
654            if (e.shiftKey && e.keyCode == 9) { self.showingAutoComplete = false; }
655            // tab key, close autocomplete and navigate to next item.
656            else if (e.keyCode == 9 && self.showingAutoComplete) {
657                e.preventDefault();
658                self.showingAutoComplete = false;
659                document.getElementById("ousearchq").blur()
660                if (document.getElementById(self.advancedId)) {
661                    window.setTimeout(function () {
662                        document.getElementById(self.advancedId).focus()
663                    }, 100);
664                }
665                if (document.getElementById(self.formSubmitId) && document.getElementById(self.advancedId) == null) {
666                    window.setTimeout(function () {
667                        document.getElementById(self.formSubmitId).focus()
668                    }, 100);
669                }
670            }
671            else if (e.keyCode == 37) {
672                this.removeAutoCompleteActive();
673            }
674            // escape key close the autocomplete
675            else if (e.keyCode == 27) {
676                e.preventDefault();
677                self.showingAutoComplete = false;
678            }
679            // up key allow navigating through the suggesstion list.
680            else if (e.keyCode == 40 && self.showingAutoComplete) {
681                e.preventDefault();
682                /* key down is pressed, increase the autoCompleteFocus variable:*/
683                self.autoCompleteFocus++;
684                self.determineCurrentAutoComplete(e);
685            }
686            // down key allow navigating through the suggesstion list.
687            else if (e.keyCode == 38 && self.showingAutoComplete) {
688                e.preventDefault();
689                self.autoCompleteFocus--;
690                /* key up is pressed, decrease the autoCompleteFocus variable:*/
691                self.determineCurrentAutoComplete(e);
692            }
693            if (!e.target.value.length) {
694                self.resetAutoComplete();
695            }
696        },
697        // function for determine the current autocomplete value that is selected
698        determineCurrentAutoComplete: function (e) {
699            if (this.autoCompleteData) {
700                if (this.autoCompleteFocus == -2) { this.autoCompleteFocus = this.autoCompleteData.length - 1; }
701                if (this.autoCompleteFocus < 0 || (this.autoCompleteFocus >= this.autoCompleteData.length)) {
702                    this.removeAutoCompleteActive();
703                    e.target.value = this.tempQuery;
704                }
705                else {
706                    e.target.value = this.autoCompleteData[this.autoCompleteFocus];
707                }
708            }
709        },
710        // function to reset the auto complete
711        resetAutoComplete: function () {
712            this.showingAutoComplete = false;
713            this.removeAutoCompleteActive();
714        },
715        // function to only un set the current focus
716        removeAutoCompleteActive: function () {
717            this.autoCompleteFocus = -1;
718        },
719        // set the active autocomplete value
720        setActiveAutoCompleteSearch: function (e, index) {
721            this.autoCompleteFocus = index;
722            if (e.target && e.target.value != "" && (e.target.value.length >= this.autoCompleteLength)) {
723                this.showingAutoComplete = true;
724            }
725        },
726        // function to set the autocomplete active state
727        setActiveAutoComplete: function (index) {
728            this.autoCompleteFocus = index;
729            this.showingAutoComplete = true;
730        },
731        // set document click to remove the autocomplete but show when you click in the for field
732        documentClickCheck: function (e, self) {
733            self.removeAutoCompleteActive();
734            if (e.target.getAttribute("id") == "ousearchq" && e.target.value && e.target.value.length >= self.autoCompleteLength) {
735                self.showingAutoComplete = true;
736            }
737            else {
738                self.showingAutoComplete = false;
739            }
740        },
741        // function to set the document click
742        setDocumentClick: function () {
743            var self = this;
744            document.addEventListener("click", function (e) {
745                self.documentClickCheck(e, self)
746            });
747        }
748    },
749    mounted: function () {
750        var self = this;
751        self.fetchData();
752        self.setDocumentClick();
753        document.getElementById("header-ousearchq").value = self.displayQuery
754        self.extraPaginationLinks = self.extraPaginationLinksFun();
755    }
756});

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.