1class QsrSidebar { 2 locationsorting = (selector) =>{ 3 const selectorS = document.getElementById(selector); 4 if(selectorS){ 5 const sidebarId = selectorS.querySelector('#dashboard-qsr-sidebar'); 6 if(sidebarId){ 7 const products = Array.from(sidebarId.getElementsByClassName('slider_view_part')); 8 if(products){ 9 products.sort(function(a, b) { 10 const orderA = a.getAttribute('data-order'); 11 const orderB = b.getAttribute('data-order'); 12 return orderB - orderA; 13 }); 14 // Reorder the list items 15 products.forEach(function(item) { 16 sidebarId.appendChild(item); 17 }); 18 } 19 } 20 } 21 }; 22 23 filterDashboardQsrSidebar = (selector) => { 24 const sidebarId = document.getElementById(selector); 25 if(sidebarId){ 26 const selectedCountry = sidebarId.querySelector('#dashboard_qsr_country').value; 27 const QSRsidebaritems = sidebarId.querySelectorAll('.slider_view_part'); 28 QSRsidebaritems.forEach(function(qsritem) { 29 const country = qsritem.dataset.country.split('+'); 30 const countryMatch = (selectedCountry == '-1') ? true : country.includes(selectedCountry); 31 32 if ( countryMatch ){ 33 qsritem.style.display = 'flex'; 34 qsritem.classList.add('active'); 35 } 36 else{ 37 qsritem.style.display = 'none'; 38 qsritem.classList.remove('active'); 39 } 40 qsrsidebar.showHideSidebarQsrParts(selector,1, 6); 41 qsrsidebar.locationsorting(selector); 42 }); 43 }; 44 }; 45 showHideSidebarQsrParts = ( selector, currentPage, itemsPerPage) => { 46 const sidebarId = document.getElementById(selector); 47 if(sidebarId){ 48 var sliderParts = sidebarId.querySelectorAll('.slider_view_part.active'); 49 for (var i = 0; i < sliderParts.length; i++) { 50 sliderParts[i].style.display = 'none'; 51 } 52 53 var startIndex = (currentPage - 1) * itemsPerPage; 54 var endIndex = Math.min(startIndex + itemsPerPage, sliderParts.length); 55 for (var j = startIndex; j < endIndex; j++) { 56 sliderParts[j].style.display = 'flex'; 57 } 58 } 59 }; 60 61 widgetNavigation = (selector) => { 62 var currentPage = 1; 63 const postPerPage = 6; 64 const sidebarId = document.getElementById(selector); 65 if(sidebarId){ 66 // Function to handle pagination when clicking the next button 67 const nextBtnSidebarQSR = sidebarId.querySelector('#nextBtnSidebarQSR'); 68 if(nextBtnSidebarQSR){ 69 nextBtnSidebarQSR.addEventListener('click', function() { 70 var sliderParts = sidebarId.querySelectorAll('.slider_view_part.active'); 71 if(sliderParts){ 72 // Calculate the total number of pages 73 var totalPages = Math.ceil(sliderParts.length / postPerPage); 74 if( currentPage < totalPages ) { 75 currentPage++; 76 this.showHideSidebarQsrParts(selector,currentPage,postPerPage); 77 } 78 } 79 }.bind(this)); 80 } 81 82 const prevBtnSidebarQSR = sidebarId.querySelector('#prevBtnSidebarQSR'); 83 if(prevBtnSidebarQSR){ 84 prevBtnSidebarQSR.addEventListener('click', function() { 85 var sliderParts = sidebarId.querySelectorAll('.slider_view_part.active'); 86 if( currentPage > 1 ) { 87 currentPage--; 88 this.showHideSidebarQsrParts(selector,currentPage,postPerPage); 89 } 90 }); 91 } 92 } 93 }; 94 95 saveQSRLocation = (selector,ajaxAction) => { 96 const widget = document.getElementById(selector); 97 if(widget){ 98 const activeBtns = widget.querySelectorAll('.slider_view_part .star_img_part a'); 99 if(activeBtns){ 100 activeBtns.forEach(function(activeBtn){ 101 102 activeBtn.addEventListener('click',function(elem){ 103 let locationArr = []; 104 let location = ''; 105 const parentclass = activeBtn.closest('.slider_view_part'); 106 if(activeBtn.classList.contains('active')){ 107 activeBtn.classList.remove('active'); 108 activeBtn.closest('.star_img_part').classList.remove('active'); 109 if(parentclass){ 110 parentclass.dataset.order = 0; 111 } 112 } 113 else{ 114 activeBtn.classList.add('active'); 115 activeBtn.closest('.star_img_part').classList.add('active'); 116 if(parentclass){ 117 parentclass.dataset.order = 1; 118 } 119 } 120 const selectedLocation = widget.querySelectorAll('.slider_view_part .star_img_part.active'); 121 if(selectedLocation){ 122 selectedLocation.forEach(function(location){ 123 let locid = location.closest('.slider_view_part').dataset.locationid; 124 locationArr.push(locid); 125 }); 126 } 127 qsrsidebar.locationsorting(selector); 128 129 if(locationArr.length != 0){ 130 location = locationArr.join(','); 131 } 132 var ajaxdata = {'action' : ajaxAction, 'resaler':location} 133 jQuery.ajax({ 134 url : kvaser_Obj.ajaxurl, 135 type: 'POST', 136 data: ajaxdata, 137 success: function(response){ 138 139 } 140 }); 141 142 }.bind(this)); 143 }); 144 } 145 } 146 }; 147 148 149 150 dashboardQSRWidget = () => { 151 const selector = 'dash_sidebar_qsr'; 152 const qsrWidget = document.getElementById(selector); 153 if(qsrWidget){ 154 const selectedCountry = qsrWidget.querySelector('#dashboard_qsr_country'); 155 if(selectedCountry){ 156 this.filterDashboardQsrSidebar(selector); 157 this.locationsorting(selector); 158 selectedCountry.addEventListener('change',function(){ 159 this.filterDashboardQsrSidebar(selector); 160 }.bind(this)); 161 } 162 this.widgetNavigation(selector); 163 this.saveQSRLocation(selector, 'save_local_resalser'); 164 } 165 }; 166 dashboardTAQSRWidget = () => { 167 const selector = 'dash_sidebar_ta_qsr'; 168 const qsrWidget = document.getElementById(selector); 169 if(qsrWidget){ 170 const selectedCountry = qsrWidget.querySelector('#dashboard_qsr_country'); 171 if(selectedCountry){ 172 this.filterDashboardQsrSidebar(selector); 173 this.locationsorting(selector); 174 selectedCountry.addEventListener('change',function(){ 175 this.filterDashboardQsrSidebar(selector); 176 }.bind(this)); 177 } 178 this.widgetNavigation(selector); 179 this.saveQSRLocation(selector, 'save_resalser_for_tecnical_associated'); 180 } 181 } 182} 183const qsrsidebar = new QsrSidebar(); 184qsrsidebar.dashboardQSRWidget(); 185qsrsidebar.dashboardTAQSRWidget();
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.