1 jQuery( document ).ready(function() { 2 console.log('shop-search-form.js.ready'); 3 setValuesFromQueryString(); //only do this onload. 4 //detectFieldValues(); 5 6 initAdvancedSearchForm(); 7 8 }); 9 10 function initAdvancedSearchForm() { 11 console.log('shop-searc-form.js.initAdvancedSearchForm'); 12 13 //jQuery('#cmsShopSearchWidget').remove(); 14 jQuery('.cmsProductAdvancedSearch :input').off().change(advSearchPageComboChanged); 15 16 if (window.innerWidth < 728 && window.innerWidth < window.innerHeight) { 17 18 var jqSS = $('.cmsAccordianWhenMobile .cmsProductAdvancedSearch'); 19 jqSS.parent().addClass('accordianSection accordionSection'); 20 jqSS.before('<div class="clickToRevealSection accordianTitleButton">Filters</div>').attr('title','Filter search'); 21 jqSS.addClass('sectionAutoReveal'); 22 23 applyAccordianToForm($('.cmsAccordianWhenMobile')); 24 25 } 26 27 applyAccordionRules() ; 28 29 30 $('.cmsSortByOptions a').on('click',function(){ 31 console.log('cmsSortByOptions.click'); 32 var sortMode = $(this).attr('value'); 33 console.log('cmsSortByOptions.sortMode='+sortMode); 34 let containerDiv = $(this).closest('#cmsAdvancedSearchDiv'); 35 if (!containerDiv.length) 36 containerDiv = $(this).closest('#cmsSearchFormFiltersTopExpandAndSort'); 37 let fm = containerDiv.find('form#cmsAdvancedSearchForm')[0]; 38 fm.overrideSorting.value = sortMode; 39 fm.submit(); 40 }); 41 42 } 43 44 function applyAccordianToForm(jq) { 45 jq.find('.cmsFormElement').addClass('accordianItem'); 46 jq.find('.cmsFormPrompt').addClass('clickToReveal'); 47 jq.find('.cmsFormData').addClass('revealable'); 48 jq.find('.hasValue').addClass('revealTheRevealable'); 49 50 } 51 52 // function detectFieldValues() { 53 // $('.cmsFormElement').each(function(){ 54 // /* all fields, but ignore unchecked radio/checkboxes */ 55 // const $fld = $(this).find('input, textarea, select > option:selected') 56 // .not('.ignoreable, :submit, :button, :checkbox, :radio') 57 // .not('input[type=hidden]').not('select[name=find_groupid]'); 58 // const fldVal = reducedValue($fld.val()); 59 // if (fldVal && fldVal!='All') { 60 // $(this).show(); 61 // $(this).addClass('hasValue'); 62 // } 63 // }); 64 // } 65 66 67 function advSearchPageComboChanged() { 68 69 console.log('advSearchPageComboChanged '+ this.name + ' = ' + $(this).val()); 70 if (this.name == 'find_pextra1' && jQuery('select#find_pextra2').length) { 71 //only applies in select mode 72 refreshAdvancedSearchForm() 73 } else if (this.name == 'find_pextra2' && jQuery('select#find_pextra3').length) { 74 //only applies in select mode 75 refreshAdvancedSearchForm(); 76 } else if (this.name == 'find_appl_mark') { 77 refreshAdvancedSearchForm(); 78 } else if (this.name == 'find_appl_model') { 79 refreshAdvancedSearchForm(); 80 } 81 return true; 82 } 83 84 function refreshAdvancedSearchForm() { 85 jqForm = jQuery('form#cmsAdvancedSearchForm'); 86 console.log('refreshAdvancedSearchForm ' + jqForm.serializeArray()); 87 jQuery('#cmsAdvancedSearchFormWrapper').load(jqForm[0].action+'/shopping/include/search-form-advanced.html form', jqForm.serializeArray(), function(data) { 88 console.log(data); 89 initAdvancedSearchForm(); 90 initForms(); 91 }); 92 93 } 94 95 96 function setValuesFromQueryString() { 97 console.log('setValuesFromQueryString ' + window.location.search); 98 if (!window.location.search) return; 99 100 let jqForm = jQuery('form#cmsAdvancedSearchForm'); 101 102 // Get the URLSearchParams object from the current URL's query string 103 const urlParams = new URLSearchParams(window.location.search); 104 105 // Iterate over all query parameters 106 for (const [key, value] of urlParams.entries()) { 107 if (value.length) { 108 console.log('setValuesFromQueryString ' + key + " = " + value); 109 jqForm.find('input[type=checkbox][name='+key+'][value=\"'+value+'\"]').prop('checked',true); 110 jqForm.find(':input[name="'+key+'"]').not('input[type=checkbox]').not('input[type=radio]').not('input[type=submit]').not('input[type=button]').val(value); 111 } 112 } 113 }
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.