1document.addEventListener('DOMContentLoaded', function () { 2 const btn = document.querySelector('.load-more'); 3 if (!btn) return; 4 5 const grid = document.querySelector('grid-content.news .container'); 6 let page = 2; 7 8 btn.addEventListener('click', async function () { 9 btn.disabled = true; 10 btn.textContent = 'Loading...'; 11 12 const formData = new FormData(); 13 formData.append('action', 'load_more_posts'); 14 formData.append('page', page); 15 16 try { 17 const res = await fetch(loadMore.ajaxurl, { 18 method: 'POST', 19 body: formData, 20 }); 21 const html = await res.text(); 22 23 const wrapper = btn.closest('.load-more-wrapper'); 24 wrapper.insertAdjacentHTML('beforebegin', html); 25 26 // Accessibility announcement 27 const status = document.createElement('div'); 28 status.setAttribute('aria-live', 'polite'); 29 status.className = 'sr-only'; 30 status.textContent = 'More posts loaded'; 31 document.body.appendChild(status); 32 setTimeout(() => status.remove(), 1000); 33 34 page++; 35 36 if (page > loadMore.maxPages) { 37 wrapper.remove(); 38 } else { 39 btn.disabled = false; 40 btn.innerHTML = 'Load More'; 41 } 42 } catch { 43 btn.disabled = false; 44 btn.innerHTML = 'Load More'; 45 } 46 }); 47});
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.