1$(document).ready(function() { 2 3 var categoriesList = []; 4 5 function getSelectedCategories() { 6 var categoriesList = $(".filter-checkbox input[type=checkbox]:checked").map(function() { 7 return { 8 parentId: $(this).data('parent-uid'), 9 childId: $(this).data('uid'), 10 }; 11 }).get(); 12 var categoriesListSorted = []; 13 categoriesList.forEach(function(item) { 14 var existing = categoriesListSorted.filter(function(v, i) { 15 return v.parentId == item.parentId; 16 }); 17 if (existing.length) { 18 var existingIndex = categoriesListSorted.indexOf(existing[0]); 19 categoriesListSorted[existingIndex].childId = categoriesListSorted[existingIndex].childId.concat(item.childId); 20 } else { 21 if(typeof item.childId == 'number') 22 item.childId = [item.childId]; 23 categoriesListSorted.push(item); 24 } 25 }); 26 return categoriesListSorted; 27 } 28 29 $('.filter-checkbox input[type="checkbox"]').on('change',function(event){ 30 var categoriesListSorted = getSelectedCategories(); 31 console.log(categoriesListSorted); 32 filterProducts(categoriesListSorted); 33 }); 34 35 $(document).on('click', '.pagination-link', function(event) { 36 event.preventDefault(); 37 var page = $(this).data('page'); 38 var categoriesListSorted = getSelectedCategories(); 39 filterProducts(categoriesListSorted, page); 40 }); 41 42 $('.reset-filter').click(function(event) { 43 event.preventDefault(); 44 event.stopPropagation(); 45 46 $('.filter-checkbox input[type="checkbox"]').prop( "checked", false ); 47 catgoriesList = []; 48 filterProducts(catgoriesList); 49 }); 50}); 51 52xhrPool = []; 53var currentXhrRequest = null; 54 55function filterProducts(catgoriesList, currentPage){ 56 57 showGlobalSpinner(); 58 59 if(currentXhrRequest) { 60 try { 61 currentXhrRequest.abort(); 62 } catch(err) {} 63 } 64 65 var requestData = {'tx_oneproductsfilter_productsfilter': {'selectedCategories': catgoriesList}}; 66 if (currentPage) { 67 requestData['tx_oneproductsfilter_productsfilter']['currentPage'] = currentPage; 68 } 69 70 currentXhrRequest = $.ajax({ 71 method: "POST", 72 url: ajaxFilterUrl, 73 beforeSend: function () { 74 showGlobalSpinner(); 75 }, 76 complete: function(){ 77 hideGlobalSpinner(); 78 }, 79 dataType: "html", 80 data: requestData, 81 success:function(data) { 82 $('#filter-products').replaceWith($(data).find('#filter-products')); 83 try { 84 history.pushState({ 85 id: 'productsfilter' 86 }, '', $("input[name='tx_oneproductsfilter_productsfilter[defaultURL]']").val()); 87 } catch(err) {} 88 hideGlobalSpinner(); 89 }, 90 error: function(data){ 91 console.log("fail!"); 92 hideGlobalSpinner(); 93 } 94 }); 95} 96 97 98function showGlobalSpinner(){ 99 $('body').spin(optsGlobal); 100} 101 102function hideGlobalSpinner(){ 103 $('body').spin(false); 104} 105 106var optsGlobal = { 107 lines: 13 // The number of lines to draw 108 , length: 15 // The length of each line 109 , width: 12 // The line thickness 110 , radius: 25 // The radius of the inner circle 111 , scale: 0.5 // Scales overall size of the spinner 112 , corners: 1 // Corner roundness (0..1) 113 , color: '#000' // #rgb or #rrggbb or array of colors 114 , opacity: 0.4 // Opacity of the lines 115 , rotate: 0 // The rotation offset 116 , direction: 1 // 1: clockwise, -1: counterclockwise 117 , speed: 0.9 // Rounds per second 118 , trail: 60 // Afterglow percentage 119 , fps: 20 // Frames per second when using setTimeout() as a fallback for CSS 120 , zIndex: 2e9 // The z-index (defaults to 2000000000) 121 , className: 'spinner' // The CSS class to assign to the spinner 122 , top: '50%' // Top position relative to parent 123 , left: '50%' // Left position relative to parent 124 , shadow: false // Whether to render a shadow 125 , hwaccel: false // Whether to use hardware acceleration 126 , position: 'fixed' // Element positioning 127};
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.