1(function(){'use strict';var productsList=document.querySelector('#shop-main ul.products');if(!productsList)return;var shopMain=document.getElementById('shop-main');var countEl=document.querySelector('.woocommerce-result-count');var nativePager=document.querySelector('.woocommerce-pagination');function getPageFromPath(path){var m=(path||location.pathname).match(/\/page\/(\d+)\/?/);return m?parseInt(m[1],10):1;} 2function buildPageUrl(page){var base=location.pathname.replace(/\/page\/\d+\/?/,'/').replace(/\/$/,'');var path=page>1?base+'/page/'+page+'/':base+'/';return path+location.search;} 3function parseCount(){if(!countEl)return null;var m=countEl.textContent.match(/(\d+)\s*[\u2013\-]\s*(\d+)\s+di\s+(\d+)/);return m?{from:+m[1],to:+m[2],total:+m[3]}:null;} 4function refreshCountDisplay(){var parsed=parseCount();if(!parsed)return;var shown=Math.min(productsList.querySelectorAll('li').length,parsed.total);countEl.textContent=countEl.textContent.replace(/\d+\s*[\u2013\-]\s*\d+/,'1\u2013'+shown);} 5function fetchPageHTML(page){return fetch(buildPageUrl(page),{credentials:'same-origin',headers:{'Accept':'text/html'}}).then(function(r){if(!r.ok)throw new Error('HTTP '+r.status);return r.text();});} 6function extractItems(html){return(new DOMParser()).parseFromString(html,'text/html').querySelectorAll('ul.products li');} 7function htmlHasNext(html){return!!(new DOMParser()).parseFromString(html,'text/html').querySelector('.woocommerce-pagination a.next');} 8var currentPage=getPageFromPath();var earliestPage=currentPage;var isLoading=false;var isDone=false;var perPage=productsList.querySelectorAll('li').length;function updatePrevBtn(){if(earliestPage<=1){if(prevBtn){prevBtn.remove();prevBtn=null;} 9return;} 10var targetPage=earliestPage-1;var label='Pagina '+targetPage+' ('+perPage+' prodotti)';if(prevBtn){prevBtn.querySelector('.sn-load-prev__label').textContent=label;}else{prevBtn=document.createElement('button');prevBtn.className='sn-load-prev';prevBtn.setAttribute('type','button');prevBtn.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" '+'stroke="currentColor" stroke-width="2.5" aria-hidden="true">'+'<path d="M12 19V5M5 12l7-7 7 7"/></svg>'+'<span class="sn-load-prev__prefix">Carica </span>'+'<span class="sn-load-prev__label">'+label+'</span>';prevBtn.addEventListener('click',loadPrev);shopMain.insertBefore(prevBtn,productsList);}} 11function loadPrev(){if(isLoading)return;isLoading=true;var targetPage=earliestPage-1;prevBtn.classList.add('is-loading');prevBtn.querySelector('.sn-load-prev__label').textContent='Caricamento\u2026';fetchPageHTML(targetPage).then(function(html){var items=extractItems(html);var ref=productsList.firstChild;items.forEach(function(item){productsList.insertBefore(item,ref);});earliestPage=targetPage;history.replaceState(null,'',buildPageUrl(earliestPage));refreshCountDisplay();isLoading=false;prevBtn.classList.remove('is-loading');updatePrevBtn();}).catch(function(){isLoading=false;prevBtn.classList.remove('is-loading');prevBtn.querySelector('.sn-load-prev__label').textContent='Errore. Riprova.';});} 12var prevBtn=null;if(currentPage>1)updatePrevBtn();if(nativePager)nativePager.hidden=true;if(!document.querySelector('.woocommerce-pagination a.next')){isDone=true;} 13var sentinel=document.createElement('div');sentinel.className='sn-scroll-sentinel';shopMain.appendChild(sentinel);function createLoader(){var el=document.createElement('div');el.className='sn-is-loader';el.setAttribute('role','status');el.setAttribute('aria-label','Caricamento prodotti in corso');el.innerHTML='<span></span><span></span><span></span>';return el;} 14function showEnd(){var p=parseCount();var total=p?p.total:'';var msg=document.createElement('p');msg.className='sn-is-end';msg.textContent=total?'Hai visto tutti i '+total+' prodotti':'Hai visto tutti i prodotti';shopMain.insertBefore(msg,sentinel);sentinel.remove();} 15function loadNext(){if(isLoading||isDone)return;var nextPage=currentPage+1;isLoading=true;var loader=createLoader();shopMain.insertBefore(loader,sentinel);fetchPageHTML(nextPage).then(function(html){loader.remove();var items=extractItems(html);if(!items.length){isDone=true;observer.disconnect();showEnd();return;}
16items.forEach(function(item){productsList.appendChild(item);});currentPage=nextPage;history.replaceState(null,'',buildPageUrl(currentPage));refreshCountDisplay();if(!htmlHasNext(html)){isDone=true;observer.disconnect();showEnd();}else{isLoading=false;}}).catch(function(){loader.remove();isLoading=false;});} 17var observer=new IntersectionObserver(function(entries){if(entries[0].isIntersecting)loadNext();},{rootMargin:'400px 0px'});observer.observe(sentinel);})();
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.