1"use strict"; 2 3// Unified loader: reveal hidden groups if present; otherwise fetch the next page (?pg=N) and append 4document.addEventListener('click', function (e) { 5 var b = e.target.closest('[data-action="nhm-load-more"]'); 6 if (!b) return; 7 e.preventDefault(); 8 var r = b.closest('.nhm-results'); 9 if (!r) return; 10 11 // 1) Reveal hidden items (back-compat) 12 var n = parseInt(r.getAttribute('data-batch') || '5', 10); 13 var h = r.querySelectorAll('.card-branch[data-hidden]'); 14 if (h.length) { 15 var m = Math.min(n, h.length); 16 for (var i = 0; i < m; i++) { 17 var s = h[i]; 18 s.classList.remove('d-none'); 19 s.style.display = ''; 20 s.removeAttribute('data-hidden'); 21 var hr = s.nextElementSibling; 22 if (hr && hr.tagName === 'HR' && hr.hasAttribute('data-hidden')) { 23 hr.classList.remove('d-none'); 24 hr.style.display = ''; 25 hr.removeAttribute('data-hidden'); 26 } 27 } 28 h = r.querySelectorAll('.card-branch[data-hidden]'); 29 if (!h.length) b.classList.add('d-none'); 30 return; 31 } 32 33 // 2) Fetch next page and append 34 var href = b.getAttribute('href'); 35 if (!href) return; 36 r.setAttribute('aria-busy', 'true'); 37 fetch(href, { 38 credentials: 'same-origin' 39 }).then(function (resp) { 40 return resp.text(); 41 }).then(function (html) { 42 var tmp = document.createElement('div'); 43 tmp.innerHTML = html; 44 var nextWrap = tmp.querySelector('.nhm-results'); 45 if (!nextWrap) { 46 window.location.href = href; 47 return; 48 } 49 50 // Insert new groups before the Load more container so the button stays last 51 var groups = nextWrap.querySelectorAll('.card-branch'); 52 var container = b.parentElement; 53 var appended = 0; 54 groups.forEach(function (g) { 55 var id = g.getAttribute('data-branch-id'); 56 if (id && r.querySelector('.card-branch[data-branch-id="' + id + '"]')) return; // skip dupes 57 var clone = g.cloneNode(true); 58 r.insertBefore(clone, container); 59 appended++; 60 }); 61 62 // Update next link 63 var nextLink = nextWrap.querySelector('[data-action="nhm-load-more"]'); 64 if (nextLink && nextLink.getAttribute('href')) { 65 b.setAttribute('href', nextLink.getAttribute('href')); 66 b.classList.remove('d-none'); 67 } else { 68 b.classList.add('d-none'); 69 } 70 71 // Live announcement and busy state 72 var live = document.getElementById((r.id || '') + '-live'); 73 if (live && appended > 0) { 74 live.textContent = 'Loaded ' + appended + ' more branches'; 75 } 76 r.removeAttribute('aria-busy'); 77 })["catch"](function () { 78 r.removeAttribute('aria-busy'); 79 window.location.href = href; 80 }); 81});
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.