1let urlTerm = ''; 2switch(categoryTerms.queryTaxonomy) { 3 case 'category': 4 urlTerm = 'cat'; 5 break; 6 case 'signature': 7 urlTerm = 'signature'; 8 break; 9 case 'latest': 10 urlTerm = 'latest'; 11 break; 12 default: 13 urlTerm = 'tags'; 14 break; 15} 16const urlTermID = categoryTerms.queryTermID; 17const chunkSize = categoryTerms.query_limits ?? 10; 18let pagingState = '1'; 19 20 21const articleContainerSelector = '.right-area .article-wrapper'; 22const articleThreshold = 11; 23 24/** 25 * 26 * @param {String} urlTerm 27 * @param {Number} urlTermID 28 * @param {Number} pagenum 29 * @param {String} chunkSize 30 * @returns {String} 31 */ 32const catQuery = (urlTerm, urlTermID, pagenum, chunkSize) => `${location.origin}/wp-json/loadmore/category/articles?tax=${urlTerm}&taxID=${urlTermID}&pagingState=${pagenum}&per_page=${chunkSize}&excluded=${categoryTerms.excluded.join(',')}` 33 34/** 35 * 36 * @param {String} urlTerm 37 * @param {Number} urlTermID 38 * @param {Number} pagenum 39 * @param {String} chunkSize 40 * @returns {Promise} 41 */ 42const getArticleBatch = (urlTerm, urlTermID, pagenum, chunkSize) => { 43 const fetchHeaders = generalTerms.status === 'dev' ? { 44 'Accept': 'application/json', 45 'Content-Type': 'application/json', 46 'Authorization': `Basic ${btoa('demo:demo')}`, 47 } : { 48 'Accept': 'application/json', 49 'Content-Type': 'application/json', 50 }; 51 const fetchOptions = { 52 method: 'GET', 53 headers: fetchHeaders, 54 credentials: 'same-origin', 55 mode: 'cors', 56 }; 57 const fetchURL = catQuery(urlTerm, urlTermID, pagenum, chunkSize); 58 console.log(fetchURL); 59 return fetch(fetchURL, fetchOptions) 60 .then(response => response.json()) 61 .then(articles => { 62 document.querySelector(`${articleContainerSelector}`).lastElementChild.insertAdjacentHTML('afterend', `${articles.join(' ')}`); 63 document.querySelector(`${articleContainerSelector} .observable`).classList.remove('observable') 64 document.querySelector(`${articleContainerSelector} .card:last-of-type`).classList.add('observable'); 65 loadMoreObserver.observe(document.querySelector(`${articleContainerSelector} .observable`)); 66 lazyload(); 67 }) 68} 69 70const loadMoreArticles = (entries, observer) => { 71 entries.forEach(entry => { 72 if (entry.isIntersecting) { 73 if (document.querySelector(`${articleContainerSelector}`).childElementCount > articleThreshold) { 74 console.log('incoming...'); 75 const incrCounter = parseInt(pagingState) + 1; 76 console.log('pagingState is ', pagingState) 77 pagingState = incrCounter 78 if (incrCounter < 15) { 79 getArticleBatch(urlTerm, urlTermID, incrCounter, chunkSize) 80 const nextObservable = document.querySelector(`${articleContainerSelector} .observable`); 81 observer.observe(nextObservable) 82 }; 83 observer.unobserve(entry.target); 84 } 85 } 86 }); 87} 88 89const loadMoreObserver = new IntersectionObserver(loadMoreArticles, { 90 rootMargin: "0px 0px -100px 0px" 91}); 92 93 94 95/* ================================== 96 SWIPERS 97================================== */ 98 99const archiveType = document.querySelector('main')?.dataset?.archiveType; 100 101const podcastHomeSwiper = archiveType == 'podcast' 102? new Swiper('.podcast-archive-swiper', { 103 slidesPerView: 2.5, 104 spaceBetween: 8, 105 loop: true, 106 breakpoints: { 107 330: { slidesPerView: 1.2 }, 108 860: { slidesPerView: 1.8 }, 109 1080: { slidesPerView: 2.5 } 110 }, 111}) 112: {}; 113 114document.addEventListener('DOMContentLoaded', () => { 115 if (document.querySelector('main.archive')) { 116 document.querySelector(`${articleContainerSelector} .card:last-of-type`).classList.add('observable'); 117 loadMoreObserver.observe(document.querySelector(`${articleContainerSelector} .observable`)); 118 } 119}); 120 121window.addEventListener('load', () => { 122 if (archiveType == 'podcast') document.querySelector('.podcast-archive-swiper').addEventListener('mousemove', moveCursor.bind(this)); 123})
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.