1$(document).ready(function() { 2 3 var suggestions = new Bloodhound({ 4 datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), 5 queryTokenizer: Bloodhound.tokenizers.whitespace, 6 remote: { 7 url: ECCSettings.contextPath + '/ajax/search/suggestions?searchString=%QUERY', 8 wildcard: '%QUERY', 9 transform: function(response) { 10 if (response.error || !response.data) { 11 return Array.of( { "displayName" : "---" } ); 12 } else { 13 var suggestionList = response.data; 14 return suggestionList; 15 } 16 } 17 } 18 }); 19 20 var displaySuggestion = function(suggestion) { 21 let sugg = suggestion.displayName; 22 23 // Strip out HTML tags and entities 24 sugg = sugg.replace(/<[^>]*>/g, ''); 25 sugg = sugg.replace(/&[^;]+;/g, ' '); 26 return sugg; 27 } 28 29 $('.autoSuggest').typeahead({ 30 hint: true, 31 highlight: true, 32 minLength: 1 33 }, 34 { 35 name: 'suggestions', 36 displayKey: 'displayName', 37 limit: 'Infinity', // Nothing else works! Limit it by adding &size=<limit> to the incoming URL in the ECCAutoCompleteTool options. 38 source: suggestions, 39 display: displaySuggestion, 40 templates: { 41 notFound: '---', 42 pending: '<img alt="Pending" src="/images/wait.gif"/>' 43 } 44 }); 45 46 // Go to the suggestion's link when it is selected 47 $('.autoSuggest').bind('typeahead:select', function(ev, suggestion) { 48 if (suggestion.link) { 49 document.location = suggestion.link; 50 } 51 }); 52 53});
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.