https://static.sourceitstore.com/wp-content/themes/woodmart-child/ajaxSearchReplacement.js?ver=1.0.5
1jQuery(document).ready(function ($) { 2 console.log('hello replace'); 3 4 // Find and change class on form.woodmart-ajax-search 5 var searchForm = $('form.searchform.wd-with-cat.wd-style-with-bg.woodmart-ajax-search'); 6 7 //console.log(searchForm); 8 9 var searchFormInput = searchForm.find('[type="text"]'); 10 11 //console.log(searchFormInput); 12 13 searchFormInput.off('focus keyup'); 14 15 var searchForm = $('form.searchform.wd-style-with-bg.woodmart-ajax-search'); 16 17 //console.log(searchForm); 18 19 var searchFormInput = searchForm.find('[type="text"]'); 20 21 //console.log(searchFormInput); 22 23 searchFormInput.off('focus keyup'); 24 25 if (typeof ($.fn.devbridgeAutocomplete) == 'undefined') { 26 return; 27 } 28 29 var escapeRegExChars = function(value) { 30 return value.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'); 31 }; 32 33 $('form.woodmart-ajax-search').each(function() { 34 var $this = $(this), 35 number = parseInt($this.data('count')), 36 thumbnail = parseInt($this.data('thumbnail')), 37 symbols_count = parseInt($this.data('symbols_count')), 38 productCat = $this.find('[name="product_cat"]'), 39 $results = $this.parent().find('.wd-dropdown-results > .wd-scroll-content'), 40 postType = $this.data('post_type'), 41 url = '/wp-json/benchmark/v1/benchmark/', 42 price = parseInt($this.data('price')), 43 sku = $this.data('sku'); 44 excerpt = $this.data('excerpt'); 45 46 $this.find('.wd-search-cat').hide(); 47 48 searchFormInput.on('focus keyup', function() { 49 var $input = $(this); 50 51 if ($input.hasClass('wd-search-inited')) { 52 return; 53 } 54 55 $input.devbridgeAutocomplete({ 56 serviceUrl : url, 57 appendTo : $results, 58 minChars : symbols_count, 59 deferRequestBy : woodmart_settings.ajax_search_delay, 60 onSelect : function(suggestion) { 61 if (suggestion.permalink.length > 0) { 62 window.location.href = suggestion.permalink; 63 } 64 }, 65 onHide : function() { 66 $results.parent().removeClass('wd-opened'); 67 }, 68 onSearchStart : function() { 69 $this.addClass('search-loading'); 70 }, 71 beforeRender : function(container) { 72 $(container).find('.suggestion-divider-title').parent().addClass('suggestion-divider'); 73 if (container[0].childElementCount > 2) { 74 $(container).append('<div class="view-all-results"><span>' + woodmart_settings.all_results + '</span></div>'); 75 } 76 77 $(container).removeAttr('style'); 78 }, 79 onSearchComplete: function() { 80 $this.removeClass('search-loading'); 81 82 woodmartThemeModule.$document.trigger('wood-images-loaded'); 83 84 }, 85 formatResult : function(suggestion, currentValue) { 86 if (currentValue === '&') { 87 currentValue = '&'; 88 } 89 var pattern = '(' + escapeRegExChars(currentValue) + ')', 90 returnValue = ''; 91 92 if (suggestion.divider) { 93 returnValue += ' <h5 class="suggestion-divider-title">' + suggestion.divider + '</h5>'; 94 } 95 96 if (thumbnail && suggestion.thumbnail) { 97 returnValue += ' <div class="suggestion-thumb">' + suggestion.thumbnail + '</div>'; 98 } 99 100 if (suggestion.value) { 101 returnValue += ' <div class="suggestion-content set-cont-mb-s reset-last-child">'; 102 returnValue += '<h4 class="wd-entities-title">' + suggestion.value 103 .replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>') 104 .replace(/<(\/?strong)>/g, '<$1>') + '</h4>'; 105 } 106 107 if (sku && suggestion.sku) { 108 returnValue += ' <p class="suggestion-sku">' + suggestion.excerpt + '</p>'; 109 } 110 111 if (excerpt && suggestion.excerpt) { 112 returnValue += ' <p class="suggestion-sku">' + suggestion.excerpt + '</p>'; 113 } 114 115 if (price && suggestion.price) { 116 returnValue += ' <p class="price">' + suggestion.price + '</p>'; 117 } 118 119 if (suggestion.value) { 120 returnValue += ' </div>'; 121 } 122 123 if (suggestion.no_found) { 124 returnValue = '<span class="no-found-msg">' + suggestion.value + '</span>'; 125 } 126 127 $results.parent().addClass('wd-opened'); 128 129 return returnValue; 130 } 131 }); 132 133 if (productCat.length) { 134 var searchForm = $this.find('[type="text"]').devbridgeAutocomplete(),
135 serviceUrl = woodmart_settings.ajaxurl + '?action=woodmart_ajax_search'; 136 137 if (number > 0) { 138 serviceUrl += '&number=' + number; 139 } 140 141 serviceUrl += '&post_type=' + postType; 142 143 productCat.on('cat_selected', function() { 144 if (productCat.val() !== '') { 145 searchForm.setOptions({ 146 serviceUrl: serviceUrl + '&product_cat=' + productCat.val() 147 }); 148 } else { 149 searchForm.setOptions({ 150 serviceUrl: serviceUrl 151 }); 152 } 153 154 155 }); 156 } 157 158 //searchForm.hide(); 159 //searchForm.onValueChange(); 160 161 $input.addClass('wd-search-inited'); 162 }); 163 164 }); 165});
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.