PageSourceSearch

https://reirei.se/cdn/shop/t/19/assets/product-card.js?v=160777944390790430501731678514

js reirei.se collected 2026-10-03 21:32:06 UTC 4,305 bytes, 4 lines download raw bytes

1if(!customElements.get("product-cart-element")){class ProductCartElement extends HTMLElement{constructor(){super(),this.sectionId=this.dataset.sectionId,this.productUrl=this.dataset.productUrl,this.variants=JSON.parse(this.querySelector("script").textContent),this.currentVariant=this.variants[0]||{},this.bundlePriceElement=this.querySelector(".bundle-price"),this.addEventListener("input",this.inputChange.bind(this)),this.querySelectorAll(".custom-buy-btn").forEach(button=>{button.addEventListener("click",event=>{this.showLoadingSpinner(!0),this.toggleAddToCartText(!1),this.addToCart(this.currentVariant.id,1)})}),this.bundlePriceElement&&this.initializeBundlePrice()}initializeBundlePrice(){const bundleProductsData=JSON.parse(this.bundlePriceElement.dataset.bundleProducts);let totalPrice=0;bundleProductsData.forEach(product=>{if(product.variants&&product.variants.length>0){const priceText=product.variants[0].price.toString().replace(/[^\d]/g,"");let price=parseInt(priceText,10);price=price/100,isNaN(price)||(totalPrice+=price)}});const formattedTotalPrice=totalPrice.toFixed(2);this.bundlePriceElement.innerHTML=`
2        <p class="bundle-total-price">${formattedTotalPrice}</p>
3      `}calculateSavings(products,bundlePrice){return products.reduce((sum,product)=>product.variants&&product.variants.length>0?sum+product.variants[0].price:sum,0)-bundlePrice}showLoadingSpinner(show){const spinner=this.querySelector(".loading__spinner");show?spinner.classList.remove("hidden"):spinner.classList.add("hidden")}toggleAddToCartText(show){const addToCartText=this.querySelector(".add-text");show?addToCartText.style.display="inline":addToCartText.style.display="none"}addToCart(productId,quantity){console.log("Adding to cart:",productId,quantity);const formData={items:[{id:productId,quantity}],sections:["cart-drawer","cart-icon-bubble"],sections_url:window.location.pathname};fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(formData)}).then(response=>{if(response.ok)return response.json();throw new Error("Failed to add to cart")}).then(cartData=>{this.updateCartIconBubble(cartData),this.updateCartDrawer(cartData),this.showLoadingSpinner(!1),this.toggleAddToCartText(!0),this.openCartDrawer()}).catch(error=>{console.error("Error adding to cart:",error),this.showLoadingSpinner(!1),this.toggleAddToCartText(!0)})}updateCartIconBubble(cartData){if(cartData.sections&&cartData.sections["cart-icon-bubble"]){const cartIconBubble=document.getElementById("cart-icon-bubble");cartIconBubble&&(cartIconBubble.innerHTML=cartData.sections["cart-icon-bubble"])}}updateCartDrawer(cartData){document.querySelectorAll(".drawer").forEach(drawer=>{drawer.classList.remove("is-empty")}),setTimeout(()=>{if(cartData.sections["cart-drawer"]){const cartDrawerElement=document.querySelector("cart-drawer");if(cartDrawerElement){const drawerInner=cartDrawerElement.querySelector(".drawer__inner");if(drawerInner){const temp=document.createElement("div");temp.innerHTML=cartData.sections["cart-drawer"];const newDrawerInner=temp.querySelector(".drawer__inner");newDrawerInner&&(drawerInner.innerHTML=newDrawerInner.innerHTML,console.log("Cart drawer inner content updated successfully"),drawerInner.offsetHeight,typeof cartDrawerElement.refreshDrawer=="function"&&cartDrawerElement.refreshDrawer())}}}},100)}openCartDrawer(){const cartDrawer=document.querySelector("cart-drawer");cartDrawer&&typeof cartDrawer.open=="function"?cartDrawer.open():console.warn("Cart drawer not found or open method not available")}inputChange(){let selectedValues=[],currentVariant={};this.querySelectorAll("input").forEach(input=>{input.checked&&selectedValues.push(input.value)}
3),this.variants.forEach(variant=>{JSON.stringify(variant.options)==JSON.stringify(selectedValues)&&(currentVariant=variant)});const url=`${this.productUrl}?variant=${currentVariant.id}&section_id=${this.sectionId}`;fetch(url).then(res=>res.text()).then(data=>{const html=new DOMParser().parseFromString(data,"text/html");this.innerHTML=html.querySelector(`[data-product-url="${this.productUrl}"]`).innerHTML})}}customElements.define("product-cart-element",ProductCartElement)}
4//# sourceMappingURL=/cdn/shop/t/19/assets/product-card.js.map?v=160777944390790430501731678514

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.