PageSourceSearch

https://dojo.uy/cdn/shop/t/22/assets/cart-discounts.js?v=74566700716606473571789920467

js dojo.uy collected 2026-10-02 01:10:15 UTC 3,535 bytes, 2 lines download raw bytes

1if(!customElements.get("cart-discounts")){class CartDiscounts extends HTMLElement{constructor(){super()}connectedCallback(){this.discounts()}getSectionsToRender(){return[{id:"Cart",section:"main-cart",selector:".thb-cart-form"},{id:"Cart-Drawer",section:"cart-drawer",selector:".cart-drawer"},{id:"cart-drawer-toggle",section:"cart-bubble",selector:".thb-item-count"}]}getSectionInnerHTML(html,selector){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}discounts(){const button=this.querySelector(".cart-discounts--button"),remove_discount_buttons=this.querySelectorAll(".cart-discounts--remove");button&&(button.addEventListener("click",event=>{event.preventDefault(),button.classList.add("loading"),this.updateDiscount()}),remove_discount_buttons.forEach(remove_discount_button=>{remove_discount_button.addEventListener("click",this.removeDiscount.bind(this))}))}updateDiscount(){const discountCodeValue=this.querySelector(".cart-discounts--input").value,existingDiscounts=this.existingDiscounts();existingDiscounts.includes(discountCodeValue)||(existingDiscounts.push(discountCodeValue),this.renderDiscounts(existingDiscounts,discountCodeValue))}removeDiscount(event){const discountCode=event.target.previousElementSibling.innerHTML,existingDiscounts=this.existingDiscounts(),index=existingDiscounts.indexOf(discountCode);index!==-1&&(existingDiscounts.splice(index,1),this.renderDiscounts(existingDiscounts))}existingDiscounts(){const discountCodes=[],discountPills=this.querySelectorAll(".cart-discounts--name");for(const pill of discountPills)discountCodes.push(pill.innerHTML);return discountCodes}renderDiscounts(existingDiscounts,discountCodeValue){const body=JSON.stringify({discount:existingDiscounts.join(","),sections:this.getSectionsToRender().map(section=>section.section),sections_url:window.location.pathname});var errorEl=this.querySelector(".cart-discounts--error");errorEl&&errorEl.setAttribute("hidden",""),fetch(`${theme.routes.cart_update_url}.js`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body}).then(response=>response.text()).then(state=>{const parsedState=JSON.parse(state),SE=window.Shopify&&window.Shopify.StandardEvents;SE&&parsedState.token&&publishStandardEvent("CartDiscountUpdateEvent",{discountCodes:(parsedState.discount_codes||[]).map(discount=>({code:discount.code,applicable:discount.applicable})),promise:Promise.resolve({cart:SE.CartDiscountUpdateEvent.createCartFromAjaxResponse(parsedState)})},this);const wasDiscountOpen=!!this.closest("details[open]");this.getSectionsToRender().forEach((section=>{const elementToReplace=document.getElementById(section.id)?.querySelector(section.selector)||document.getElementById(section.id);parsedState.sections&&elementToReplace&&(elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector))})),wasDiscountOpen&&document.querySelectorAll(".cart-discounts--title").forEach(el=>{el.closest("details").setAttribute("open","")}),document.querySelectorAll(".cart-discounts--button").forEach(el=>{el.classList.remove("loading")}),discountCodeValue&&parsedState.discount_codes.find(discount=>discount.code===discountCodeValue&&discount.applicable===!1)&&setTimeout(()=>{document.querySelectorAll(".cart-discounts--error").forEach(el=>{el.removeAttribute("hidden")})},300)})}}customElements.define("cart-discounts",CartDiscounts)}
2//# sourceMappingURL=/cdn/shop/t/22/assets/cart-discounts.js.map?v=74566700716606473571789920467

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.