1jQuery(document).ready(function($){ 2 3 $('form.dwkb-search .dwkb-search-input').autocomplete({ 4 appendTo: 'form.dwkb-search', 5 source: function( request, resp ) { 6 $.ajax({ 7 url: dwkb.ajax_url, 8 type: 'POST', 9 dataType: 'json', 10 data: { 11 action: 'dwkb-auto-suggest-search-result', 12 title: request.term, 13 nonce: $('form.dwkb-search .dwkb-search-input').data('nonce') 14 }, 15 success: function( data ) { 16 console.log( data ); 17 resp( $.map( data.data, function( item ) { 18 if ( true == data.success ) { 19 return { 20 label: item.title, 21 value: item.title, 22 url: item.url, 23 } 24 } 25 })) 26 } 27 }); 28 }, 29 select: function( e, ui ) { 30 if ( ui.item.url !== '#' ) { 31 window.location.href = ui.item.url; 32 } else { 33 return true; 34 } 35 }, 36 open: function( e, ui ) { 37 var acData = $(this).data( 'uiAutocomplete' ); 38 acData.menu.element.addClass('dwkb-autocomplete').find('li').each(function(){ 39 var $self = $(this), 40 keyword = $.trim( acData.term ).split(' ').join('|'); 41 $self.html( $self.text().replace( new RegExp( "(" + keyword + ")", "gi" ), '<span class="dwkb-text-highlight">$1</span>' ) ); 42 }); 43 } 44 }); 45});
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.