1(function (window, document) { 2 'use strict'; 3 if (window.gxWebsiteInventorySearchLoaded) return; 4 window.gxWebsiteInventorySearchLoaded = true; 5 6 // Capture runs before jQuery UI's Enter handler, even in saved custom themes. 7 // Reuse their source so matching, ordering and the 25-result cap stay identical. 8 document.addEventListener('keydown', function (event) { 9 var input = event.target; 10 if (!input || input.id !== 'searchInput' || (event.key !== 'Enter' && event.keyCode !== 13) 11 || event.isComposing || event.keyCode === 229 || !window.jQuery) return; 12 var $input = window.jQuery(input); 13 var autocomplete = $input.data('ui-autocomplete') || $input.data('autocomplete'); 14 if (!autocomplete || typeof autocomplete.source !== 'function') return; 15 16 event.preventDefault(); 17 event.stopImmediatePropagation(); 18 var term = input.value.trim(); 19 if (!term) return; 20 autocomplete.source.call(autocomplete, {term: term}, function (results) { 21 // A delayed source must not navigate after the visitor edits the search. 22 if (input.value.trim() !== term) return; 23 var ids = []; 24 (results || []).forEach(function (item) { 25 var id = item.vehicle && String(item.vehicle.ID); 26 if (id && /^[1-9][0-9]{0,9}$/.test(id) && ids.indexOf(id) === -1) ids.push(id); 27 }); 28 if (!ids.length) return; 29 window.location.href = '/inventory.php?searchvehicles=' + ids.slice(0, 25).join(',') 30 + '&searchtext=' + encodeURIComponent(term); 31 }); 32 }, true); 33 34 // Keep the result set when visitors refine it with the existing inventory form. 35 document.addEventListener('submit', function (event) { 36 var form = event.target; 37 if (!form || form.tagName !== 'FORM' || (form.method || 'get').toLowerCase() !== 'get' 38 || !form.querySelector('select[name="mid"], select[name="moid"], select[name="pr"], select[name="par"], select[name="ct"], select[name="at"], select[name="year"], select[name="cyl"], select[name="fuel"], select[name="transmission"], select[name="condition"]')) return; 39 var action = new URL(form.action || window.location.href, window.location.href); 40 if (action.origin !== window.location.origin || !/^\/(?:index\.php|inventory\.php)?$/.test(action.pathname)) return; 41 var params = new URL(window.location.href).searchParams; 42 if (!params.has('searchvehicles')) return; 43 ['searchvehicles', 'searchtext'].forEach(function (name) { 44 var field = form.querySelector('input[name="' + name + '"]'); 45 if (!field) { 46 field = document.createElement('input'); 47 field.type = 'hidden'; 48 field.name = name; 49 form.appendChild(field); 50 } 51 field.value = params.get(name) || ''; 52 }); 53 }, true); 54})(window, document);
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.