PageSourceSearch

https://orapesce.it/cdn/shop/t/1/assets/minicart.js?v=133896663042936073891770309578

js orapesce.it collected 2026-10-05 19:56:12 UTC 8,401 bytes, 2 lines download raw bytes

1class MiniCart{constructor(cartEndpoint){this.cartEndpoint=cartEndpoint||"/cart.js",this.initCalculateShippingEndpoint="/cart/prepare_shipping_rates.json",this.getShippingEndpoint="/cart/async_shipping_rates.json",this.minicart=document.querySelector("[data-minicart]"),this.items=document.querySelector("[data-minicart-items]"),this.item="data-minicart-item",this.close="data-minicart-close",this.open="data-minicart-open",this.plus="data-minicart-plus",this.minus="data-minicart-minus",this.count="data-minicart-count",this.totalCount=document.querySelector("[data-minicart-totalcount]"),this.remove="data-minicart-remove",this.subtotal=document.querySelector("[data-minicart-subtotal]"),this.total=document.querySelector("[data-minicart-total]"),this.progress=document.querySelector("[data-minicart-progress]"),this.shipping=document.querySelector("[data-minicart-shipping]")}openCart(target){this.minicart&&target.hasAttribute(this.open)&&(this.minicart.classList.add("open"),this.minicart.classList.remove("close"))}closeCart(target){this.minicart&&target.hasAttribute(this.close)&&(this.minicart.classList.remove("open"),this.minicart.classList.add("close"))}updatTotalCount(total){total===0?this.totalCount.parentNode.classList.add("hidden"):this.totalCount.parentNode.classList.remove("hidden"),this.totalCount&&(this.totalCount.innerHTML=total)}updateSubtotal(total){if(!total)return!1;this.subtotal&&(this.subtotal.innerHTML=this.moneyFormat(total))}updateProgress(total){total>=12e3?this.progress.style.width="100%":total>=3e3?(this.progress.style.width=`${total/120}%`,this.progress.style.backgroundColor="#113b71"):(this.progress.style.width=`${total/120}%`,this.progress.style.backgroundColor="red")}updateCart(openCart=!0){fetch(this.cartEndpoint).then(resp=>resp.json()).then(cart=>{if(cart){this.updateSubtotal(cart.total_price),this.updateProgress(cart.total_price),this.updatTotalCount(cart.item_count),this.updateShippingRates(cart.total_price);let allItems="";for(let item of cart.items)allItems+=this.cartItemHTML(item);if(this.items&&(this.items.innerHTML=allItems),cart.items.length<1?this.isEmpty():(openCart=!1,this.isFilled(openCart)),document.querySelector("body.template--cart")){const shippableTotal=cart.items.filter(item=>item.requires_shipping).reduce((prev,cur)=>prev+cur.final_line_price,0);if(shippableTotal<3e3&&shippableTotal>0){const intervalId=setInterval(()=>{document.getElementById("deliveryGeoSearchField")&&(document.getElementById("deliveryGeoSearchField").disabled=!0,clearInterval(intervalId))},500)}}}}).catch(error=>{console.error(error)})}updateShippingRates(subtotal){fetch(`${this.initCalculateShippingEndpoint}?shipping_address[country]=Italy&shipping_address[zip]=20100&shipping_address[province]=Milano`,{method:"post",headers:{"Content-Type":"application/json"}}).then(resp=>{if(!resp.ok)throw resp;return resp.json()}).then(data=>{this.shipping.innerHTML='<div class="spinner">&nbsp;</div>',this.total.innerHTML='<div class="spinner">&nbsp;</div>',setTimeout(()=>{fetch(`${this.getShippingEndpoint}?shipping_address[country]=Italy&shipping_address[zip]=20100&shipping_address[province]=Milano`).then(resp=>resp.json()).then(data2=>{console.log("DATA",data2.shipping_rates);let subtotalText=this.subtotal.textContent;subtotalText=subtotalText.replace("\u20AC","").replace(",",".").trim();const subtotalNumber=parseFloat(subtotalText);if(subtotalNumber<120,data2.shipping_rates&&data2.shipping_rates.length>0){const shippingInCents=parseFloat(data2.shipping_rates[0].price)*100;this.shipping.innerHTML="<em>max</em> "+this.moneyFormat(shippingInCents,data2.shipping_rates[0].currency),this.total.innerHTML=this.moneyFormat(subtotal+shippingInCents)}else subtotalNumber<120?(console.log("Il totale \xE8 inferiore a 120\u20AC"),this.shipping.innerHTML="---",this.total.innerHTML="<small class='alert'>Minimo d'ordine 30\u20AC</small>"):(this.shipping.innerHTML="Consegna gratuita",this.total.innerHTML=this.moneyFormat(subtotal))}).catch(err=>{console.error("Error fetching shipping rates:",err),this.shipping.innerHTML="Max 15\u20AC",this.total.innerHTML=this.moneyFormat(subtotal)})},1e3)}).catch(err=>{console.error("Error initializing shipping calculation:",err),this.shipping.innerHTML="Max 15\u20AC",this.total.innerHTML=this.moneyFormat(subtotal)})}isFilled(openCart=!0){this.minicart&&(this.minicart.classList.remove("empty"),openCart&&(this.minicart.classList.remove("close"),this.minicart.classList.add("open")))}isEmpty(){this.minicart&&this.minicart.classList.add("empty")}removeCartItem(target){if(target.hasAttribute(this.remove)){const id=this.findAnce
1stor(target,`[${this.item}]`)&&this.findAncestor(target,`[${this.item}]`).dataset.minicartItem;id&&fetch("/cart/change.js",{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({id,quantity:0})}).then(resp=>resp.json()).then(cart=>{this.updateCart()}).catch(error=>{console.error(error)})}}minusCartItem(target){if(target.hasAttribute(this.minus)){const id=this.findAncestor(target,`[${this.item}]`)&&this.findAncestor(target,`[${this.item}]`).dataset.minicartItem,countElem=target.parentNode.querySelector(`[${this.count}]`),newQuantity=countElem.textContent&&parseInt(countElem.textContent)-1;id&&newQuantity&&fetch("/cart/change.js",{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`quantity=${newQuantity}&id=${id}`}).then(()=>{this.updateCart()}).catch(error=>{console.error("Error:",error)})}}plusCartItem(target){if(target.hasAttribute(this.plus)){const id=this.findAncestor(target,`[${this.item}]`)&&this.findAncestor(target,`[${this.item}]`).dataset.minicartItem;id&&fetch("/cart/add.js",{method:"post",headers:{"x-requested-with":"XMLHttpRequest","Content-Type":"application/x-www-form-urlencoded"},body:`id=${id}&quantity=1`}).then(resp=>resp.json()).then(data=>{data.status===422||this.updateCart()}).catch(error=>{console.error("Error:",error)})}}cartItemHTML(item){function buildProps(item2){if(!item2||!item2.properties||Object.keys(item2.properties).length===0)return"";let result="";for(const[key,value]of Object.entries(item2.properties))result+=`<li>${key}: ${value}</li>`;return result}function buildOptions(item2){if(!item2||!item2.options_with_values||item2.options_with_values.length===0)return"";let result="";for(let option of item2.options_with_values)option.value!=="Default Title"&&(result+=`<li>${option.name}: ${option.value}</li>`);return result}function getImage(image,size=300){if(!image)return"";const ext=image.match(/\.(?:jpg|gif|png)/g);return image.replace(ext[0],`_${size}x`+ext[0])}function buildImage(item2){return item2?`<img alt="" class="responsive-image__image lazyload" data-sizes="auto" src="${getImage(item2.image,150)}" data-src="${getImage(item2.image,250)}">`:""}let cartItem=miniCartItem;return cartItem&&(cartItem=cartItem.replace(/{{itemImage}}/g,buildImage(item)),cartItem=cartItem.replace(/{{itemVariantId}}/g,item.id),cartItem=cartItem.replace(/{{itemTitle}}/g,item.product_title),cartItem=cartItem.replace(/{{itemUrl}}/g,item.url),cartItem=cartItem.replace(/{{itemComparePrice}}/g,item.original_price>item.price?this.moneyFormat(item.original_price):""),cartItem=cartItem.replace(/{{itemPrice}}/g,this.moneyFormat(item.price)),cartItem=cartItem.replace(/{{itemOptions}}/g,buildOptions(item)),cartItem=cartItem.replace(/{{itemProps}}/g,buildProps(item)),cartItem=cartItem.replace(/{{itemQuantity}}/g,item.quantity)),cartItem}hideOnEscape(e){var keyCode=e.keyCode;keyCode===27&&this.minicart&&(this.minicart.classList.remove("open"),this.minicart.classList.add("close"))}moneyFormat(amout,customCurrency="EUR"){return amout?new Intl.NumberFormat("it-IT",{style:"currency",currency:customCurrency}).format(amout/100):new Intl.NumberFormat("it-IT",{style:"currency",currency:customCurrency}).format(0)}findAncestor(el,sel){for(;(el=el.parentElement)&&!(el.matches||el.matchesSelector).call(el,sel););return el}}const mini_cart=new MiniCart;window.mini_cart=mini_cart,mini_cart.updateCart(!1),document.addEventListener("keydown",function(e){mini_cart.hideOnEscape(e)}),document.addEventListener("click",function(e){mini_cart.openCart(e.target),mini_cart.removeCartItem(e.target),mini_cart.plusCartItem(e.target),mini_cart.minusCartItem(e.target),mini_cart.closeCart(e.target)});
2//# sourceMappingURL=/cdn/shop/t/1/assets/minicart.js.map?v=133896663042936073891770309578

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.