1function LoadMore(t){function e(){s.classList.add("loading");const t=new URL(n.loadPath,window.location.origin);new URLSearchParams(window.location.search).forEach((e,o)=>t.searchParams.append(o,e)),t.searchParams.set("offset",i),t.searchParams.set("limit",Math.min(l,h));const e=t.toString();fetch(e).then(t=>{if(!t.ok)throw new Error(`Load more: ${t.status} from ${e}`);return t.text()}).then(t=>{s.classList.remove("loading"),o(t)}).catch(t=>{s.classList.remove("loading"),console.log(t)})}function o(t){const e=document.createElement("template");e.innerHTML=t;const o=Array.from(e.content.children);r.appendChild(e.content),n.onAppend(o),i+=o.length,l=Math.min(h,u-i),c.textContent=l,d.textContent=i,i>=u&&s.setAttribute("hidden","")}const n={...{onAppend:()=>{}},...t};if(!n.id)throw new Error("id is required");if(!n.appendToId)throw new Error("appendToId is required");if(!n.loadPath)throw new Error("loadPath is required");const a=document.getElementById(n.id),r=document.getElementById(n.appendToId);if(!a||!r)return void console.warn("Load more controls and container are required");const s=a.querySelector("[data-load-more-button]"),c=a.querySelector("[data-load-more-next-page-count]"),d=a.querySelector("[data-load-more-loaded-count]");let i=parseInt(d.textContent),l=parseInt(c.textContent);const u=parseInt(a.dataset.loadMoreTotalCount),h=parseInt(a.dataset.loadMorePerPage);s.addEventListener("click",e)}function initSortTabs(){const t=document.querySelectorAll("[data-sort-btn]");if(!t.length)return;const e=new URLSearchParams(window.location.search).get("sort")||"popular";t.forEach(function(t){updateSortBtnState(t,t.dataset.sortBtn===e),t.addEventListener("click",function(){applySort(t.dataset.sortBtn)})})}function updateSortBtnState(t,e){t.setAttribute("aria-pressed",e),t.classList.toggle("button--secondary",!e)}function updateURL(t){const e=t.toString();window.history.pushState({},"",e?"?"+e:window.location.pathname)}function fetchResults(t,e){const o=document.getElementById("thumbnail-grid-results-container");o.classList.add("loading"),fetch(sortResultsPath+"?"+t.toString()).then(function(t){if(!t.ok)throw new Error("Request failed: "+t.status);return t.text()}).then(function(t){o.classList.remove("loading"),o.innerHTML=t,htmx.process(o),initLoadMore(),e&&e(o)}).catch(function(t){o.classList.remove("loading"),console.error(t)})}function applySort(t){document.querySelectorAll("[data-sort-btn]").forEach(function(e){updateSortBtnState(e,e.dataset.sortBtn===t)});const e=new URLSearchParams(window.location.search);"popular"===t?e.delete("sort"):e.set("sort",t),updateURL(e);const o=new URLSearchParams({sort:t}),n=e.get("search");n&&o.set("search",n),fetchResults(o)}function initLoadMore(){LoadMore({id:"thumbnail-grid-load-more",appendToId:"thumbnail-grid-courses-container",loadPath:loadMorePath,onAppend:function(t){t.forEach(function(t){htmx.process(t)})}})}function TopicSearch(){function t(){const t=e.value.trim(),o=new URLSearchParams(window.location.search);if(t?(o.set("search",t),o.delete("sort")):o.delete("search"),updateURL(o),t)a.setAttribute("hidden","");else{a.removeAttribute("hidden");document.querySelectorAll("[data-sort-btn]").forEach(function(t){updateSortBtnState(t,"popular"===t.dataset.sortBtn)})}const n=new URLSearchParams;n.set("sort","popular"),t&&n.set("search",t),fetchResults(n,function(e){const o=e.querySelector("[data-total-count]"),n=o?o.dataset.totalCount:"",a=document.getElementById("thumbnail-grid-topic-count");a&&n&&(a.textContent=t?n+" "+("1"===n?"result":"results"):n+" "+("1"===n?"class":"classes"))})}const e=document.getElementById("topic-search-input"),o=document.getElementById("topic-search-clear-button"),n=document.getElementById("topic-search-button"),a=document.getElementById("topic-sort-container");e.addEventListener("keydown",function(e){"Enter"===e.key&&(e.preventDefault(),t())}),n.addEventListener("click",function(){t()}),o.addEventListener("click",function(){e.value="",t(),e.focus()})}const wrapper=document.querySelector("[data-testimonials-load-more]");wrapper&&LoadMore({id:"testimonials-load-more",appendToId:"testimonials-l
1ist",loadPath:wrapper.dataset.loadPath});const container=document.querySelector("[data-topic-id]"),sortResultsPath=container.dataset.sortResultsPath,loadMorePath=container.dataset.loadMorePath;initSortTabs(),initLoadMore(),"enableSearch"in container.dataset&&TopicSearch();
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.