1(() => { 2 document.querySelectorAll('.acf-load-more').forEach((btn) => { 3 btn.addEventListener('click', async () => { 4 const grid = document.getElementById(btn.dataset.grid); 5 if (!grid) return; 6 7 const offset = parseInt(btn.dataset.offset || "0", 10); 8 const perPage = parseInt(btn.dataset.perPage || "10", 10); 9 10 btn.disabled = true; 11 const old = btn.textContent; 12 btn.textContent = "Chargementâ¦"; 13 14 const form = new FormData(); 15 form.append('action', 'acf_block_load_more'); 16 form.append('nonce', btn.dataset.nonce); 17 form.append('offset', String(offset)); 18 form.append('perPage', String(perPage)); 19 form.append('template', btn.dataset.template); 20 form.append('ids', btn.dataset.ids || "[]"); 21 22 try { 23 const res = await fetch(window.ajaxurl || "/wp-admin/admin-ajax.php", { 24 method: "POST", 25 credentials: "same-origin", 26 body: form 27 }); 28 29 const data = await res.json(); 30 if (!data?.success) throw new Error("AJAX failed"); 31 32 if (data.data?.html) grid.insertAdjacentHTML("beforeend", data.data.html); 33 34 btn.dataset.offset = String(data.data.newOffset || (offset + perPage)); 35 36 if (!data.data.hasMore) btn.remove(); 37 else { 38 btn.textContent = old; 39 btn.disabled = false; 40 } 41 } catch (e) { 42 console.error(e); 43 btn.textContent = "Erreur"; 44 btn.disabled = false; 45 setTimeout(() => (btn.textContent = old), 1200); 46 } 47 }); 48 }); 49})();
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.