PageSourceSearch

https://northspore.com/cdn/shop/t/343/assets/collection-filters-DJ6vZTVJ.js

js northspore.com collected 2026-10-03 21:06:13 UTC 7,085 bytes, 1 lines download raw bytes

1const b=(c,e)=>{let i;return(...t)=>{clearTimeout(i),i=setTimeout(()=>c(...t),e)}},v=()=>window.__FACETS_DEBUG__===!0,s=(...c)=>{v()&&console.log("[facets]",...c)},y=()=>{typeof window.jdgm?.batchRenderBadges=="function"&&window.requestAnimationFrame(()=>{window.jdgm.batchRenderBadges()})};document.addEventListener("alpine:init",()=>{window.Alpine.data("collectionFilters",c=>({basePath:c.basePath||"/collections/"+(window.collection?.handle||""),ajax:!!c.ajax,debounceMs:c.debounceMs||400,activeFilters:new Map,priceFilters:{min:null,max:null},currentSort:"",initFromLocation(){try{const e=new URL(window.location.href);for(const[n,o]of e.searchParams.entries())if(n.startsWith("filter.")){const d=this.activeFilters.get(n)||new Set,l=o.trim();l&&d.add(l),this.activeFilters.set(n,d)}const i=e.searchParams.get("filter.v.price.gte"),t=e.searchParams.get("filter.v.price.lte");i&&(this.priceFilters.min=parseFloat(i)),t&&(this.priceFilters.max=parseFloat(t));const r=e.searchParams.get("sort_by");r&&(this.currentSort=r),s("initFromLocation",{href:window.location.href,activeFilters:Array.from(this.activeFilters.entries()).map(([n,o])=>({key:n,values:Array.from(o)})),priceFilters:{...this.priceFilters},currentSort:this.currentSort})}catch(e){console.warn("Error parsing filter URL:",e)}},isFilterSelected(e,i){const t=this.activeFilters.get(e);return t?t.has(i):!1},toggleFilter(e,i,t){this.activeFilters.has(e)||this.activeFilters.set(e,new Set);const r=this.activeFilters.get(e);t.target.checked?r.add(i):r.delete(i),s("toggleFilter",{name:t?.target?.name||e,value:i,checked:!!t?.target?.checked}),s("toggleFilter",{name:t?.target?.name||e,value:i,checked:!!t?.target?.checked}),r.size===0&&this.activeFilters.delete(e),this.applyFilters()},getPriceFilterValue(e){return e==="gte"?this.priceFilters.min||"":this.priceFilters.max||""},updatePriceFilter(e,i){e==="gte"?this.priceFilters.min=i?parseFloat(i):null:this.priceFilters.max=i?parseFloat(i):null},applyPriceFilters(){this.activeFilters.delete("filter.v.price.gte"),this.activeFilters.delete("filter.v.price.lte"),this.priceFilters.min!==null&&this.activeFilters.set("filter.v.price.gte",new Set([this.priceFilters.min.toString()])),this.priceFilters.max!==null&&this.activeFilters.set("filter.v.price.lte",new Set([this.priceFilters.max.toString()])),this.applyFilters()},clearPriceFilters(){this.priceFilters.min=null,this.priceFilters.max=null,this.activeFilters.delete("filter.v.price.gte"),this.activeFilters.delete("filter.v.price.lte"),this.applyFilters()},hasPriceFilters(){return this.priceFilters.min!==null||this.priceFilters.max!==null},getCurrentSortBy(){return this.currentSort},getCurrentSortLabel(){return this.currentSort===""?"Sort By":{featured:"Featured","title-ascending":"A-Z","title-descending":"Z-A","price-ascending":"Price: Low to High","price-descending":"Price: High to Low","created-descending":"Date: New to Old","created-ascending":"Date: Old to New","best-selling":"Best Selling"}[this.currentSort]||"Sort By"},applySortBy(e){this.currentSort=e,this.applyFilters()},resetFilters(){this.activeFilters.clear(),this.priceFilters={min:null,max:null},this.currentSort="",this.applyFilters(!1)},applyFilters(e=!0){try{const i=new URL(this.basePath,window.location.origin),t=new URLSearchParams;for(const[d,l]of this.activeFilters.entries())t.delete(d),l.forEach(a=>{t.append(d,a)});this.currentSort&&this.currentSort!=="featured"&&t.set("sort_by",this.currentSort);const r=t.toString(),n=r?`${i.pathname}?${r}`:i.pathname,o=i.origin+n;s("applyFilters",{queryString:r,finalUrl:n,fullUrl:o}),e?window.history.pushState({filters:!0},"",n):window.history.replaceState({filters:!0},"",n),this.ajax?window.dispatchEvent(new CustomEvent("collectionFiltersChanged",{detail:{url:o}})):window.location.href=o}catch(i){s("applyFilters error",i),s("applyFilters error",i),console.error("Error applying filters:",i),window.location.reload()}},handlePopState(e){this.activeFilters.clear(),this.priceFilters={min:null,max:null},this.currentSort="",this.initFromLocation(),window.dispatchEvent(new CustomEvent("collectionFiltersChanged",{detail:{url:window.location.href}}))},init(){this.initFromLocation(),s("collectionFilters init",{basePath:this.basePath,ajax:this.ajax}),s("collectionFilters init",{basePath:this.basePath,ajax:this.ajax}),window.addEventListener("popstate",this.handlePopState.bind(this))}})),window.Alpine.data("collectionGrid",c=>({sectionId:c.sectionId,debouncedFetchSection:null,loading:!1,executeScripts(e){e.querySelectorAll("script").forEach(t=>{const r=document.createElement("script");
1Array.from(t.attributes).forEach(n=>{r.setAttribute(n.name,n.value)}),t.src?r.src=t.src:r.textContent=t.textContent,t.src?document.head.appendChild(r):document.body.appendChild(r),t.remove()})},async fetchSection(e,i={}){this.loading=!0,window.__FACETS_DEBUG__===!0&&document.body.classList.add("facets-debug-loading");try{s("fetchSection request",{url:e,sectionId:this.sectionId});const t=e.includes("?")?"&":"?",r=`${e}${t}section_id=${this.sectionId}`,n=await fetch(r);if(!n.ok)throw new Error("Bad response");const o=await n.text();if(s("fetchSection response",{status:n.status,contentType:n.headers.get("content-type")||"",responseSnippet:o.slice(0,200)}),!o){window.location.href=e;return}const l=new DOMParser().parseFromString(o,"text/html"),a=l.querySelector(`[data-section-id="${this.sectionId}"]`)||l.body.firstElementChild;if(!a){window.location.href=e;return}const w=parseInt(a.dataset.totalResults||"0",10),p=a.querySelector("[data-collection-grid]"),g=a.querySelector("[data-collection-pagination]"),F=document.querySelector("[data-collection-grid]"),m=document.querySelector("[data-collection-pagination]"),S=p?p.querySelectorAll(".product-card-wrapper").length:0;if(s("domReplacement",{sectionId:this.sectionId,totalResults:w,cardCount:S}),w>0&&S===0){window.location.href=e;return}if(F&&p){const h=document.importNode(p,!0);if(this.executeScripts(h),F.replaceWith(h),window.Alpine&&window.Alpine.initTree(h),y(),m&&g){const u=document.importNode(g,!0);m.replaceWith(u),window.Alpine&&window.Alpine.initTree(u)}}else{const h=this.$root.querySelector("[data-collection-results]"),u=a.querySelector("[data-collection-results]");if(!h||!u){window.location.href=e;return}const f=document.importNode(u,!0);this.executeScripts(f),h.replaceWith(f),window.Alpine&&window.Alpine.initTree(f),y()}window.dispatchEvent(new CustomEvent("collectionResultsUpdated",{detail:{count:w}})),this.loading=!1}catch(t){this.loading=!1,s("fetchSection error",t),s("fetchSection error",t),console.error("Error fetching section:",t),window.location.href=e}window.__FACETS_DEBUG__===!0&&document.body.classList.remove("facets-debug-loading"),window.__FACETS_DEBUG__===!0&&document.body.classList.remove("facets-debug-loading")},init(){this.debouncedFetchSection=b(this.fetchSection.bind(this),400),s("collectionGrid init",{sectionId:this.sectionId}),s("collectionGrid init",{sectionId:this.sectionId}),window.addEventListener("collectionFiltersChanged",e=>{this.debouncedFetchSection(e.detail.url)})}}))});

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.