PageSourceSearch

https://bernstein-badshop.de/cdn/shop/t/2/assets/cart.js?v=151214173868554950541789478632

js bernstein-badshop.de collected 2026-09-26 02:26:21 UTC 5,507 bytes, 1 lines download raw bytes

1class Cart extends HTMLElement{constructor(){super(),this.loading=!1,this.submitButton=this.querySelector('.cart-details button[type="submit"]'),this.submitButton&&this.submitButton.addEventListener("click",()=>{localStorage.removeItem("bernstein-cart-updated"),localStorage.removeItem("bernstein-bubble-closed")}),window.addEventListener("cartViewUpdate",this.cartViewUpdateHandler=t=>{window.location.href=window.location.href});const e=parseInt(this.getAttribute("data-items-count"));fetch("/cart.js",{method:"GET"}).then(t=>t.json()).then(t=>{e!==t.item_count?window.location.href=window.location.href:this.setLoading(!1)});var t="true"===this.getAttribute("data-2-mann-handling");fetch(window.Shopify.routes.root+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{_2_mann_handling_eligible:t?"true":"false"}})})}update(t){var e=(new DOMParser).parseFromString(t.section,"text/html").querySelector("cart-main"),t=(new URL(location),this.closest("section#shopify-section-"+this.id).replaceChild(e,this),this.setLoading(!1),document.dispatchEvent(new CustomEvent("cart:updated",{detail:t.items,bubbles:!1})),window.dispatchEvent(new CustomEvent("cartCounterUpdate")),"true"===e.getAttribute("data-2-mann-handling"));fetch(window.Shopify.routes.root+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{_2_mann_handling_eligible:t?"true":"false"}})})}setLoading(t=!0){1==t?this.setAttribute("loading",!0):this.removeAttribute("loading")}disconnectedCallback(){this.cartViewUpdateHandler&&window.removeEventListener("cartViewUpdate",this.cartViewUpdateHandler)}}customElements.define("cart-main",Cart);class CartItem extends HTMLElement{constructor(){super(),this.cart=this.closest("cart-main"),this.lineKey=this.dataset.lineKey,this.quantityInput=this.querySelector("quantity-field input"),this.removeButton=this.querySelector(".cart-item__actions__remove a"),this.warranty=this.querySelector(".cart-item__warranty"),this.warrantyCheckbox=this.querySelector(".cart-item__warranty__checkmark input"),this.onRemove=t=>this.changeQuantity(t,!0),this.onQuantityChange=this.debounce(this.changeQuantity,400),this.onWarrantyChange=t=>this.toggleWarranty(t,t.target.checked),this.removeButton.addEventListener("click",this.onRemove),this.quantityInput.addEventListener("change",this.onQuantityChange),this.warrantyCheckbox&&this.warrantyCheckbox.addEventListener("change",this.onWarrantyChange)}debounce(e,a){let n;return(...t)=>{clearTimeout(n),n=setTimeout(()=>e.apply(this,t),a)}}toggleWarranty(t,e=!1){t.preventDefault(),this.cart.setLoading();var t=Object.fromEntries(JSON.parse(this.dataset.properties?.replaceAll("=>",":")||"{}")),a=JSON.parse(this.dataset.warranty?.replaceAll("=>",":")||"{}");let n=t;var i=this.warranty.dataset.warrantyKey,r=this.warranty.dataset.warrantyName;const o=parseInt(this.quantityInput.value),s=this.dataset.variantId;a&&(t=t._warranty,e&&null==t?(n._warranty=[{id:a.id}],n[i]=r):e||null==t||(delete n._warranty,n[i]&&delete n[i]),fetch(window.Shopify.routes.root+"cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:this.lineKey,quantity:0})}).then(t=>t.json()).then(t=>{var e={items:[{id:s,quantity:o,properties:n}],sections:this.cart.id};fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(t=>t.json()).then(t=>{if(!t.sections[this.cart.id])return new Error(t.message);var e=t.sections[this.cart.id],e=(this.cart.update({section:e,count:t.item_count,items:t.items}),(t.items||[]).some(t=>t.properties&&t.properties._oos_product));fetch(window.Shopify.routes.root+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{_oos_product_in_cart:e?"true":""}})}),0<t.item_count?localStorage.setItem("bernstein-cart-updated",Date.now()):localStorage.removeItem("bernstein-cart-updated")}).catch(t=>{console.error("Error:",t),this.cart.setLoading(!1)})}))}changeQuantity(t,e=!1){t.preventDefault(),this.cart.setLoading(),fetch(window.Shopify.routes.root+"cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:this.lineKey,quantity:e?0:t?.target?.value,sections:this.cart.id})}).then(t=>t.json()).then(t=>{if(!t.sections[this.cart.id])return new Error(t.message);var e=t.sections[this.cart.id],e=(this.cart.update({section:e,count:t.item_count,items:t.items}),t.items.some(t=>t.properties&&t.properties._oos_product)),a=document.querySelector(".klarna_icon");fetch(window.Shopify.routes.root+"cart/update.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{_oos_product_in_cart:e?"true":""}})}),e?a&&(a.style.display="none"):a&&"none"===a.style.display&&(a.style.display="block"),0<t.item_count?localStorage.setItem("bernstein-cart-updated",Date.now()):localStorage.removeItem("bernstein-cart-updated")}
1).catch(t=>{console.error("Error:",t),document.querySelector("cart-item").quantityInput.value=document.querySelector("cart-item").quantityInput.getAttribute("value"),this.cart.setLoading(!1)})}disconnectedCallback(){this.removeButton?.removeEventListener("click",this.onRemove),this.quantityInput?.removeEventListener("change",this.onQuantityChange),this.warrantyCheckbox&&this.warrantyCheckbox.removeEventListener("change",this.onWarrantyChange)}}customElements.define("cart-item",CartItem);

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.