PageSourceSearch

https://store.22fresh.com/cdn/shop/t/61/assets/cart.js?v=85308899251383303541741622079

js 22fresh.com collected 2026-10-07 20:29:51 UTC 3,689 bytes, 2 lines download raw bytes

1class Cart{constructor(){this.container=document.getElementById("Cart"),this.setupEventListeners()}onChange(event){event.target.type=="number"?this.updateQuantity(event.target.dataset.index,event.target.value):event.target.getAttribute("id")=="CartSpecialInstructions"&&this.saveNotes()}saveNotes(){fetch(`${theme.routes.cart_update_url}.js`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({note:document.getElementById("CartSpecialInstructions").value})})}setupEventListeners(){this.removeProductEvent(),this.debouncedOnChange=debounce(event=>{this.onChange(event)},300),document.addEventListener("cart:refresh",event=>{this.refresh()}),this.container.addEventListener("change",this.debouncedOnChange.bind(this))}getSectionsToRender(){return[{id:"Cart",section:"main-cart",selector:".thb-cart-form"},{id:"cart-drawer-toggle",section:"cart-bubble",selector:".thb-item-count"}]}displayErrors(line2,message){const lineItemError=document.getElementById(`Line-item-error-${line2}`)||document.getElementById(`CartDrawer-LineItemError-${line2}`);lineItemError&&(lineItemError.removeAttribute("hidden"),lineItemError.querySelector(".cart-item__error-text").innerHTML=message,this.container.querySelector(`#CartItem-${line2}`).classList.remove("loading"))}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}updateQuantity(line2,quantity){this.container.classList.add("cart-disabled"),line2&&this.container.querySelector(`#CartItem-${line2}`).classList.add("loading");const body=JSON.stringify({line:line2,quantity,sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});dispatchCustomEvent("line-item:change:start",{quantity}),fetch(`${theme.routes.cart_change_url}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){this.displayErrors(line2,parsedState.errors),this.container.classList.remove("cart-disabled");return}this.renderContents(parsedState,line2),this.container.classList.remove("cart-disabled"),dispatchCustomEvent("line-item:change:end",{quantity,cart:parsedState})})}refresh(){this.container.classList.add("cart-disabled"),fetch(`${window.location.pathname}?sections=main-cart`).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state);if(parsedState.errors){this.displayErrors(line,parsedState.errors),this.container.classList.remove("cart-disabled");return}this.renderContents(parsedState,!1,!0),this.container.classList.remove("cart-disabled")})}removeProductEvent(){this.container.querySelectorAll(".remove").forEach(remove=>{remove.addEventListener("click",event=>{this.updateQuantity(event.target.dataset.index,"0"),event.preventDefault()})})}renderContents(parsedState,line2,refresh){this.getSectionsToRender().forEach((section=>{const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);refresh?parsedState[section.section]&&(elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState[section.section],section.selector)):elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector),this.removeProductEvent(),line2&&this.container.querySelector(`#CartItem-${line2}`)&&this.container.querySelector(`#CartItem-${line2}`).classList.remove("loading")}))}}window.addEventListener("load",()=>{typeof Cart<"u"&&new Cart});
2//# sourceMappingURL=/cdn/shop/t/61/assets/cart.js.map?v=85308899251383303541741622079

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.