1(function($) { 2 $(document).ready(function() { 3 // Checkbox change event 4 $(".brand-filter-widget input[type='checkbox']").on("change", function() { 5 applyBrandFilter(); 6 }); 7 8 // Brand Reset button click event 9 $('.brand-filter-buttons .reset-button').on('click', function (e) { 10 e.preventDefault(); 11 var filterUrl = removeQueryStringParameter(window.location.href, 'brand'); 12 window.location.href = filterUrl; 13 }); 14 // Apply brand filter 15 function applyBrandFilter() { 16 var selectedBrands = $('input[name="brand[]"]:checked').map(function() { 17 return encodeURIComponent(this.value); 18 }).get(); 19 20 // Remove duplicate brands 21 selectedBrands = [...new Set(selectedBrands)]; 22 23 var filterUrl = updateQueryStringParameter(window.location.href, 'brand', selectedBrands.join(',')); 24 25 // Remove previous brand selection 26 if (selectedBrands.length === 0) { 27 filterUrl = removeQueryStringParameter(filterUrl, 'brand'); 28 } 29 30 window.location.href = filterUrl; 31 } 32 33 34 // Helper function to update query string parameter 35 function updateQueryStringParameter(url, key, value) { 36 var baseUrl = url.split('?')[0]; 37 var urlParameters = url.split('?')[1]; 38 39 if (urlParameters) { 40 var urlParams = new URLSearchParams(urlParameters); 41 urlParams.set(key, value); 42 return baseUrl + '?' + urlParams.toString(); 43 } else { 44 return baseUrl + '?' + key + '=' + value; 45 } 46 } 47 48 // Helper function to remove query string parameter 49 function removeQueryStringParameter(url, key) { 50 var urlParts = url.split('?'); 51 if (urlParts.length >= 2) { 52 var prefix = encodeURIComponent(key) + '='; 53 var params = urlParts[1].split(/[&;]/g); 54 var updatedParams = []; 55 56 for (var i = 0; i < params.length; i++) { 57 var param = params[i]; 58 var paramParts = param.split('='); 59 var paramName = decodeURIComponent(paramParts[0]); 60 61 if (paramName === key) { 62 continue; 63 } 64 65 updatedParams.push(param); 66 } 67 68 url = urlParts[0] + (updatedParams.length > 0 ? '?' + updatedParams.join('&') : ''); 69 } 70 return url; 71 } 72 }); 73})(jQuery);
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.