PageSourceSearch

https://lektormilky.cz/build/assets/cartpopup-Dm1N1Zv5.js

js lektormilky.cz collected 2026-10-02 15:57:30 UTC 3,093 bytes, 1 lines download raw bytes

1import{i as C}from"./lucide-icons-BbFicJj0.js";import"./lucide-C63VmYQq.js";document.addEventListener("DOMContentLoaded",()=>{const l=document.getElementById("cartPopup"),a=document.getElementById("cartOverlay"),g=document.getElementById("toggle-cart"),L=document.getElementById("closeCartBtn"),m=document.getElementById("cartItems"),s=document.getElementById("cartTotal"),u=document.getElementById("cartCount"),r=document.getElementById("confirmRemoveDialog"),p=document.querySelector('meta[name="csrf-token"]')?.content;if(!l)return;window.cartState=window.cartState||{count:0,total:0};async function f(){try{const e=await fetch("/cart/partial",{headers:{"X-Requested-With":"XMLHttpRequest"}});if(!e.ok)throw new Error("Cart fetch failed");const t=await e.json();m&&(m.innerHTML=t.html),s&&(s.textContent=t.total);const n=new DOMParser().parseFromString(t.html,"text/html").querySelectorAll(".cart-item:not(.empty)").length;window.cartState.total=t.total,window.cartState.count=n,sessionStorage.setItem("cart",JSON.stringify({count:n})),w(),C(),window.dispatchEvent(new CustomEvent("cart:updated",{detail:{count:n}})),console.log("✅ Cart refreshed and event dispatched")}catch(e){console.error("❌ Error refreshing cart:",e)}}function w(){s&&(s.textContent=window.cartState.total??"0.00"),u&&(u.textContent=window.cartState.count??0,u.style.display=window.cartState.count>0?"inline-block":"none")}function y(){l.classList.add("open"),a.classList.add("active"),a.hidden=!1,document.body.classList.add("cart-open"),f()}function E(){l.classList.remove("open"),a.classList.remove("active"),document.body.classList.remove("cart-open"),setTimeout(()=>a.hidden=!0,300)}g?.addEventListener("click",e=>{e.stopPropagation(),y()}),L?.addEventListener("click",E),a?.addEventListener("click",E),m.addEventListener("click",async e=>{const t=e.target.closest(".qty-btn");if(!t)return;const c=t.closest(".cart-item"),o=c?.dataset?.id;if(!o)return;const n=t.dataset.action,i=c.querySelector(".quantity");let d=parseInt(i.textContent||"1",10);n==="increase"&&d++,n==="decrease"&&d--;try{if(d<=0){if(!await S())return;await fetch(`/cart/remove/${o}`,{method:"DELETE",headers:{"X-CSRF-TOKEN":p}})}else await fetch(`/cart/update/${o}`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRF-TOKEN":p},body:JSON.stringify({quantity:d})});await f(),k("✅ Košík aktualizován"),window.dispatchEvent(new CustomEvent("cartUpdated"))}catch(h){console.error("❌ Cart update failed:",h)}});async function S(){return r?new Promise(e=>{r.showModal();const t=r.querySelector(".btn.line"),c=r.querySelector(".btn.prim"),o=v=>{r.close(),t.removeEventListener("click",n),c.removeEventListener("click",i),e(v)},n=()=>o(!1),i=()=>o(!0);t.addEventListener("click",n),c.addEventListener("click",i)}):confirm("Odstranit položku?")}function k(e){const t=document.createElement("div");t.className="cart-toast",t.textContent=e,document.body.appendChild(t),setTimeout(()=>t.classList.add("visible"),10),setTimeout(()=>{t.classList.remove("visible"),t.remove()},2200)}window.refreshCart=f,window.openCart=y,C(),w()});

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.