1(() => { 2 const btn = document.querySelector('.authors .load__more[data-taxonomy]'); 3 if (!btn || !window.ajax_loadmore_terms_params) return; 4 5 const ajaxurl = window.ajax_loadmore_terms_params.ajaxurl; 6 const action = window.ajax_loadmore_terms_params.action; 7 const nonce = window.ajax_loadmore_terms_params.nonce; 8 const loadingText = window.ajax_loadmore_terms_params.loading || 'Loading...'; 9 10 const grid = document.querySelector('.authors__grid'); 11 const form = document.getElementById('terms__data'); 12 if (!grid || !form) return; 13 14 const taxonomy = form.querySelector('#terms__taxonomy').value; 15 const pppInput = form.querySelector('#terms__ppp'); 16 const offsetInput = form.querySelector('#terms__offset'); 17 const letterInput = form.querySelector('#terms__letter'); 18 19 let isLoading = false; 20 const originalText = btn.textContent; 21 22 btn.addEventListener('click', (e) => { 23 e.preventDefault(); 24 if (isLoading) return; 25 isLoading = true; 26 btn.textContent = loadingText; 27 28 const ppp = parseInt(pppInput.value, 10) || 10; 29 const offset = parseInt(offsetInput.value, 10) || 0; 30 31 const payload = new URLSearchParams(); 32 payload.set('action', action); 33 payload.set('nonce', nonce); 34 payload.set('taxonomy', taxonomy); 35 payload.set('ppp', String(ppp)); 36 payload.set('offset', String(offset)); 37 if (letterInput && letterInput.value) { 38 payload.set('letter', letterInput.value); 39 } 40 41 fetch(ajaxurl, { 42 method: 'POST', 43 headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, 44 body: payload.toString(), 45 credentials: 'same-origin', 46 }) 47 .then((res) => res.json()) 48 .then((data) => { 49 if (!data || !data.success) throw new Error('Request failed'); 50 if (data.data && data.data.html) { 51 const temp = document.createElement('div'); 52 temp.innerHTML = data.data.html; 53 const nodes = Array.from(temp.children); 54 nodes.forEach((n) => grid.appendChild(n)); 55 56 offsetInput.value = String(data.data.nextOffset || 0); 57 58 if (!data.data.has_more) { 59 btn.remove(); 60 } 61 } else { 62 btn.remove(); 63 } 64 }) 65 .catch(() => { 66 btn.textContent = originalText; 67 }) 68 .finally(() => { 69 isLoading = false; 70 if (document.body.contains(btn)) { 71 btn.textContent = originalText; 72 } 73 }); 74 }); 75})(); 76 77
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.