orcinus-search/orcinus/js/search.js

24 lines
651 B
JavaScript
Raw Normal View History

2023-04-12 23:08:00 +00:00
let remoteValue;
if (typeof os_return_all !== 'function') {
function os_return_all() { return []; }
remoteValue = { url: '?q=%QUERY&json', wildcard: '%QUERY' }
}
let os_bloodhound = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 5,
remote: remoteValue,
local: os_return_all
});
$('input[type="text"].os_typeahead').attr('autocomplete', 'off').typeahead({
hint: true,
highlight: true,
minLength: 3
}, {
source: os_bloodhound,
display: 'title'
}).bind('typeahead:selected', function (obj, datum) {
window.location.href = datum.url;
});