1/* ***** Orcinus Site Search - Default Search Result Javascript **** */ 2 3// When offline, this script relies on being in the [root]/orcinus/js/ 4// directory in order for offline URLs to resolve correctly. If you 5// have placed your Orcinus Site Search installation in a different 6// location, you will need to edit the pathOffline value below. 7let scrElem = document.currentScript; 8let pathOnline = scrElem.src.replace(/\/js\/[^\/]+$/, '/search.php'); 9let pathOffline = scrElem.src.replace(/\/orcinus\/js\/[^\/]+$/, ''); 10 11let remoteValue; 12if (typeof os_return_all !== 'function') { 13 var os_return_all = function() { return []; } 14 remoteValue = { 15 url: pathOnline + '?q=%QUERY&json', 16 wildcard: '%QUERY' 17 }; 18} 19 20$('input.os_typeahead').attr('autocomplete', 'off').typeahead({ 21 hint: true, 22 highlight: true, 23 minLength: 3 24}, { 25 source: new Bloodhound({ 26 datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'), 27 queryTokenizer: Bloodhound.tokenizers.whitespace, 28 limit: 5, 29 remote: remoteValue, 30 local: os_return_all 31 }), 32 display: 'title' 33}).bind('typeahead:selected', function (obj, datum) { 34 35 // If we are online 36 if (window.location.protocol != 'file:') { 37 38 // On user click of a search suggestion, add this search query to 39 // the query log and cache 40 fetch(new Request(pathOnline), { 41 method: 'POST', 42 headers: { 'Content-type': 'application/json' }, 43 body: JSON.stringify({ q: datum.query, log: 'log' }) 44 }) 45 .then((response) => response.text()) 46 .then((data) => { window.location.href = datum.url; }); 47 48 // Else we are offline 49 } else window.location.href = pathOffline + datum.url; 50});
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.