1$(document).ready(function () { 2 var showContentOnFocus = false; 3 4 $('.search-block-weighted.predictive-search form').each(function () { 5 var searchTextInput = $(this).find('input.ccm-search-block-text'), 6 ajaxHolder = $(this).find('.ajax-results-holder'), 7 ajaxStatus = $(this).find('#ajax-results-status'), 8 resultsDiv = $(this).find('.ajax-results-holder'), 9 searchForm = $(this), 10 action = searchTextInput.attr('data-action'); 11 12 var typeCount = 0; 13 14 // Wait final keyup to search (ms defined at end of the function when it's called) 15 function delay(callback, ms) { 16 var timer = 0; 17 18 return function() { 19 var context = this, args = arguments; 20 clearTimeout(timer); 21 timer = setTimeout(function () { 22 callback.apply(context, args); 23 }, ms || 0); 24 }; 25 } 26 27 searchTextInput.on('keyup', delay(function() { 28 var search = $(this).val(); 29 var counter = 0; 30 31 counter++; 32 if(counter === 1) { 33 if(search.trim().length > 0) { 34 var data = searchForm.serialize(); 35 36 $.ajax({ 37 url: action, 38 data: data, 39 success: function (response) { 40 showContentOnFocus = true; 41 42 resultsDiv.html(response) 43 ajaxHolder.show(); 44 searchTextInput.addClass('predictive-active'); 45 46 var count = $('.predicted-results').data('count'); 47 48 var s = ''; 49 if(count > 1) { 50 var s = 's'; 51 } 52 53 if(count > 0) { 54 ajaxStatus.html('Quick search updated with ' + count + ' result' + s + '. Press the submit button to complete a full search.'); 55 56 } else { 57 ajaxStatus.html('Quick search found no results. Press the submit button to complete a full search.'); 58 } 59 }, 60 }); 61 62 } else { 63 resultsDiv.html('') 64 ajaxHolder.hide(); 65 searchTextInput.removeClass('predictive-active'); 66 ajaxStatus.html(''); 67 } 68 } 69 }, 300)); 70 71 searchTextInput.on('focus', function (e) { 72 if (showContentOnFocus) { 73 ajaxHolder.show(); 74 searchTextInput.addClass('predictive-active'); 75 } 76 }); 77 78 $('.main').on('click', function (e) { 79 ajaxHolder.hide() 80 searchTextInput.removeClass('predictive-active'); 81 }); 82 83 $('.main').find('*').on('focus', function (e) { 84 ajaxHolder.hide() 85 searchTextInput.removeClass('predictive-active'); 86 }); 87 }) 88});
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.