PageSourceSearch

https://www.trafalgarstore.com/cdn/shop/t/241/assets/algolia-predictive.js?v=10124195327502923981785943334

js trafalgarstore.com collected 2026-09-25 18:40:54 UTC 8,532 bytes, 2 lines download raw bytes

1(function(){"use strict";customElements.whenDefined("predictive-search").then(function(){var cfg=window.algoliaConfig;if(!cfg||!cfg.app_id||!cfg.search_api_key||!cfg.index_prefix||!cfg._vendorUrl)return;var PS=customElements.get("predictive-search");if(!PS)return;var baseIndex=cfg.index_prefix+"products",client=null,clientPromise=null;function makeClient(){var ns=window["algoliasearch/lite"];return ns&&typeof ns.liteClient=="function"?ns.liteClient(cfg.app_id,cfg.search_api_key):null}function getClient(){if(client)return Promise.resolve(client);var existing=makeClient();return existing?(client=existing,Promise.resolve(client)):clientPromise||(clientPromise=new Promise(function(resolve,reject){var s=document.createElement("script");s.src=cfg._vendorUrl,s.onload=function(){if(client=makeClient(),!client)return reject(new Error("[algolia-predictive] liteClient not defined after load"));resolve(client)},s.onerror=reject,document.head.appendChild(s)}),clientPromise)}function esc(str){return String(str==null?"":str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function money(major){var theme=window.AlgoliaTheme||{},fmt=theme.moneyFormat||window.FoxTheme&&window.FoxTheme.settings&&window.FoxTheme.settings.moneyFormat||"${{amount}}",cents=Math.round(Number(major)*100),formatted=(cents/100).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g,",");return fmt.replace(/\{\{\s*amount[^}]*\}\}/,formatted)}function highlight(hit,attr){var hr=hit._highlightResult&&hit._highlightResult[attr];return hr&&typeof hr.value=="string"?hr.value:esc(hit[attr]||"")}function priceHTML(hit){var p=Number(hit.price),c=Number(hit.compare_at_price)||0,sale=c>p;return'<div class="aa-ItemContentPrice"><div class="aa-ItemContentPriceCurrent'+(sale?" aa-ItemContentPriceCurrent--sale":"")+'">'+money(p)+"</div>"+(sale?'<div class="aa-ItemContentPriceDiscounted"><s>'+money(c)+"</s></div>":"")+"</div>"}var ICONS={collections:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"/></svg>',articles:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/></svg>',pages:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>'};function productCard(hit,index,queryID){var titleHtml=highlight(hit,"title"),alt=esc(hit.title||""),url="/products/"+encodeURIComponent(hit.handle||""),img=hit.product_image||hit.image||"",imgTag=img?'<img src="'+esc(img+(img.indexOf("?")===-1?"?width=320":"&width=320"))+'" alt="'+alt+'" loading="lazy" width="160" height="160">':"",insightsAttrs="";return hit.objectID!=null&&(insightsAttrs+=' data-algolia-objectid="'+esc(String(hit.objectID))+'"'),queryID&&(insightsAttrs+=' data-algolia-queryid="'+esc(String(queryID))+'"'),insightsAttrs+=' data-algolia-position="'+(index+1)+'"','<a class="aa-ItemLink aa-ProductItem" href="'+url+'"'+insightsAttrs+'><div class="aa-ItemContent"><div class="aa-ItemPicture aa-ItemPicture--loaded">'+imgTag+'</div><div class="aa-ItemContentBody"><div class="aa-ItemContentTitleWrapper"><div class="aa-ItemContentTitle">'+titleHtml+"</div></div>"+priceHTML(hit)+"</div></div></a>"}function railItem(hit,href,iconKey){return'<a class="aa-ItemLink" href="'+esc(href)+'"><div class="aa-ItemWrapper"><div class="aa-ItemContent"><div class="aa-ItemIcon aa-ItemIcon--noBorder">'+ICONS[iconKey]+'</div><div class="aa-ItemContentBody"><div class="aa-ItemContentTitle">'+highlight(hit,"title")+"</div></div></div></div></a>"}function sourceHeader(title){return'<div class="aa-SourceHeader"><span class="aa-SourceHeaderTitle">'+esc(title)+'</span><div class="aa-SourceHeaderLine"></div></div>'}
1function railSource(title,hits,hrefFor,iconKey){if(!hits||!hits.length)return"";var rows=hits.map(function(hit){return railItem(hit,hrefFor(hit),iconKey)}).join("");return'<section class="aa-Source">'+sourceHeader(title)+'<div class="aa-List">'+rows+"</div></section>"}function collectionHref(hit){return"/collections/"+encodeURIComponent(hit.handle||"")}function pageHref(hit){return"/pages/"+encodeURIComponent(hit.handle||"")}function articleHref(hit){var blog=hit.blog&&hit.blog.handle;return blog?"/blogs/"+encodeURIComponent(blog)+"/"+encodeURIComponent(hit.handle||""):hit.url||"#"}function buildHTML(query,data){var products=data.products||{hits:[],queryID:void 0},hasLeft=data.collections&&data.collections.length||data.articles&&data.articles.length||data.pages&&data.pages.length;if(!products.hits.length&&!hasLeft)return'<div class="aa-PanelLayout aa-NoResults"><p class="aa-NoResultsHeader">No results for <q>'+esc(query)+'</q></p><p class="m-0 text-subtext">Try checking your spelling or use more general terms.</p></div>';var productCards=products.hits.map(function(hit,i){return productCard(hit,i,products.queryID)}).join(""),productsSection='<section class="aa-Source aa-Source--products">'+sourceHeader(query?"Products for "+query:"Products")+'<div id="predictive-search-results-products-list" class="aa-List aa-ProductGrid" role="listbox">'+productCards+"</div></section>";if(!hasLeft)return'<div class="aa-PanelLayout aa-Panel--scrollable"><div class="aa-PanelSection">'+productsSection+"</div></div>";var left=railSource("Collections",data.collections,collectionHref,"collections")+railSource("Articles",data.articles,articleHref,"articles")+railSource("Pages",data.pages,pageHref,"pages");return'<div class="aa-PanelLayout aa-Panel--scrollable"><div class="aa-PanelSections"><div class="aa-PanelSection--left">'+left+'</div><div class="aa-PanelSection--right">'+productsSection+"</div></div></div>"}var origRenderSection=PS.prototype.renderSection;PS.prototype.renderSection=function(url){var self=this,query=this.getQuery();if(!query){origRenderSection&&origRenderSection.call(this,url);return}self.setLoadingState(!0);var stockFilter=cfg.stock_policy==="deny"?"inventory_quantity > 0":cfg.stock_policy==="continue"?"inventory_available:true":"",hl={highlightPreTag:"<mark>",highlightPostTag:"</mark>"},queries=[{indexName:baseIndex,params:{query:query,hitsPerPage:cfg.products_autocomplete_hits_per_page||8,distinct:!!cfg.show_products,clickAnalytics:!!cfg.analytics_enabled,filters:stockFilter||void 0,highlightPreTag:hl.highlightPreTag,highlightPostTag:hl.highlightPostTag,attributesToRetrieve:["title","handle","price","compare_at_price","product_image","image"]}}],sources=["products"];function addSource(name,suffix,perPage){queries.push({indexName:cfg.index_prefix+suffix,params:{query:query,hitsPerPage:perPage,clickAnalytics:!!cfg.analytics_enabled,highlightPreTag:hl.highlightPreTag,highlightPostTag:hl.highlightPostTag}}),sources.push(name)}cfg.index_collections&&addSource("collections","collections",cfg.collections_autocomplete_hits_per_page||2),cfg.index_articles&&addSource("articles","articles",cfg.articles_autocomplete_hits_per_page||2),cfg.index_pages&&addSource("pages","pages",cfg.pages_autocomplete_hits_per_page||2),getClient().then(function(c){return c.search(queries)}).then(function(response){var results=response.results||[],data={products:{hits:[],queryID:void 0}};sources.forEach(function(name,i){var r=results[i]||{};name==="products"?data.products={hits:r.hits||[],queryID:r.queryID}:data[name]=r.hits||[]});var container=self.querySelector('[id^="PredictiveSearchResults-"]');container&&(container.innerHTML=buildHTML(query,data),self.setLoadingState(!1),self.searchContent&&self.searchContent.classList.remove("hidden"),self.setAttribute("results","true"),self.isHeaderSearch&&!document.body.classList.contains("search-open")&&(document.body.classList.add("search-open"),self.toggleNavButtonVisibility&&self.toggleNavButtonVisibility(!0)),self.classList.add("predictive-search-open"))}).catch(function(){self.setLoadingState(!1),origRenderSection&&origRenderSection.call(self,url)})}})})();
2//# sourceMappingURL=/cdn/shop/t/241/assets/algolia-predictive.js.map?v=10124195327502923981785943334

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.