PageSourceSearch

https://petpoint.co.il/cdn/shop/t/4/assets/wishlist-drawer.js?v=60310897365362532041772800160

js petpoint.co.il collected 2026-10-07 08:43:20 UTC 17,271 bytes, 39 lines download raw bytes

1const wishlist_api="https://shopify-wishlist.matat.io";class WishlistDrawer extends HTMLElement{constructor(){if(super(),typeof customer_id<"u"&&(this.syncWithServer(),this.syncWishlistToServer(),this.renderContentFromSessionStorage()),this.createUniqueUserID(),localStorage.getItem("visitCount")){let visitCount=parseInt(localStorage.getItem("visitCount"));visitCount++,visitCount%5===0&&(this.syncWishlistToServer(),visitCount=0),localStorage.setItem("visitCount",visitCount.toString())}else localStorage.setItem("visitCount","1");this.renderContentFromSessionStorage(),this.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.querySelector("#WishlistDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.setHeaderCartIconAccessibility()}syncWithServer(){var userId=localStorage.getItem("userId");if(userId!=customer_id){const endpoint=`${wishlist_api}/api/wishlist/sync`,dynamicPayload={user_id:userId,customer_id},dynamicPayloadJSON=JSON.stringify(dynamicPayload);fetch(endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:dynamicPayloadJSON}).then(response=>{if(!response.ok)throw new Error("Network response was not ok");return response.json()}).then(data=>{localStorage.setItem("userId",customer_id)}).catch(error=>{})}}createUniqueUserID(){if(!localStorage.getItem("userId")){const userId=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);return localStorage.setItem("userId",userId),userId}}syncWishlistToServer(){var userId=localStorage.getItem("userId");const endpoint=`${wishlist_api}/api/wishlist/${userId}`;fetch(endpoint,{method:"GET",headers:{"Content-Type":"application/json"}}).then(response=>{if(!response.ok)throw new Error("Network response was not ok");return response.json()}).then(data=>{let get_items=JSON.parse(localStorage.getItem("wishlist_items"));get_items.length>0?localStorage.setItem("wishlist_items",JSON.stringify(get_items)):localStorage.setItem("wishlist_items",JSON.stringify(data)),this.renderContentFromSessionStorage()}).catch(error=>{})}setHeaderCartIconAccessibility(){const cartLink=document.querySelector("#wishlist-icon-bubble");cartLink.setAttribute("role","button"),cartLink.setAttribute("aria-haspopup","dialog"),cartLink.addEventListener("click",event=>{event.preventDefault(),this.open(cartLink)}),cartLink.addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink))})}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy),setTimeout(()=>{this.classList.add("animate","active")}),this.addEventListener("transitionend",()=>{const containerToTrapFocusOn=document.getElementById("WishlistDrawer"),focusElement=this.querySelector(".drawer__inner")||this.querySelector(".drawer__close");trapFocus(containerToTrapFocusOn,focusElement)},{once:!0}),document.querySelector("#Details-menu-drawer-container").hasAttribute("open")&&(document.querySelector("#Details-menu-drawer-container").removeAttribute("open"),document.querySelector("#Details-menu-drawer-container").classList.remove("menu-opening"),document.querySelector(".header__icon--menu").setAttribute("aria-expanded",!1),document.body.classList.remove("overflow-hidden-tablet"),document.querySelector(".section-header").classList.remove("menu-open")),document.querySelector(".header__search details").hasAttribute("open")&&(document.querySelector(".header__search details").removeAttribute("open"),document.querySelector(".section-header").classList.remove("menu-open")),document.body.classList.add("overflow-hidden")}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),document.body.classList.remove("overflow-hidden")}setSummaryAccessibility(cartDrawerNote){cartDrawerNote.setAttribute("role","button"),cartDrawerNote.setAttribute("aria-expanded","false"),cartDrawerNote.nextElementSibling.getAttribute("id")&&cartDrawerNote.setAttribute("aria-controls",cartDrawerNote.nextElementSibling.id),cartDrawerNote.addEventListener("click",event=>{event.currentTarget.setAttribute("aria-expanded",!event.currentTarget.closest("details").hasAttribute("open"))}),cartDrawerNote.parentElement.addEventListener("keyup",onKeyUpEscape)}appendWishlistImage(product){const wishlistContainer=document.querySelector(".wishlist-container");if(!wishlistContainer)return;const div=document.createElement("div");div.classList.add("wishlist-image-item");
1const anchor=document.createElement("a");anchor.href=product.url,anchor.classList.add("wishlist-product-wrap");const img=document.createElement("img");img.width=150,img.height=200,img.classList.add("attachment-woocommerce_thumbnail","size-woocommerce_thumbnail","lazyload"),img.alt="Product Image",img.decoding="async",img.setAttribute("src",product.src),img.setAttribute("sizes","(max-width: 150px) 100vw, 150px"),anchor.appendChild(img),div.appendChild(anchor),wishlistContainer.appendChild(div)}renderWishlistItem(product){let product_media=product.src.split(",");var render_pro_image,pro_badges,pro_compare_price="";render_pro_image=document.createElement("div"),render_pro_image.classList.add("wishlist-image-item");const anchor=document.createElement("a");anchor.href=product.url,anchor.classList.add("wishlist-product-wrap");const img=document.createElement("img");if(img.width=150,img.height=200,img.classList.add("attachment-woocommerce_thumbnail","size-woocommerce_thumbnail","lazyload"),img.alt="Product Image",img.decoding="async",img.setAttribute("src",product.src),img.setAttribute("sizes","(max-width: 320px) 100vw, 320px"),anchor.appendChild(img),render_pro_image.appendChild(anchor),product.saleBadge!=""||product.soldBadge!=""||product.tagBadge!=""){var sale_badge="",sold_badge="",tag_badge="";console.log(product.saleBadge),product.saleBadge!=null&&product.compare_price>product.price&&(sale_badge=`<span class="wishlist-sale-badge">${product.saleBadge}</span>`),product.soldBadge!=""&&product.soldBadge!=null&&(sold_badge=`<span class="wishlist-sold-badge">${product.soldBadge}</span>`),product.tagBadge!=""&&product.tagBadge!=null&&(tag_badge=`<span class="wishlist-tag-badge">${product.tagBadge}</span>`),pro_badges=`<div class="wishlist-pro-badges">${sale_badge} ${sold_badge} ${tag_badge}</div>`}return product.compare_price!=""&&product.compare_price!=null&&(pro_compare_price=`<span class="sale-wishlist-price amount">${product.compare_price}</span>`),`
2        <wishlist-item class="product-col">
3          <div class="product-item">
4            <div class="img-wrap">
5              <wishlist-item-delete-button class="btn-remove-wishlist" data-id="${product.id}" role="button" tabindex="0">
6              <svg xmlns="http://www.w3.org/2000/svg" width="13.629" height="15.088" viewBox="0 0 13.629 15.088">
7                <g id="Icon_feather-trash" data-name="Icon feather-trash" transform="translate(-4.25 -2.75)">
8                  <path id="Path_7719" data-name="Path 7719" d="M4.5,9H17.629" transform="translate(0 -3.082)" fill="none" stroke="CurrentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.5"/>
9                  <path id="Path_7720" data-name="Path 7720" d="M17.711,5.918V16.129a1.459,1.459,0,0,1-1.459,1.459H8.959A1.459,1.459,0,0,1,7.5,16.129V5.918m2.188,0V4.459A1.459,1.459,0,0,1,11.147,3h2.918a1.459,1.459,0,0,1,1.459,1.459V5.918" transform="translate(-1.541 0)" fill="none" stroke="CurrentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.5"/>
10                </g>
11              </svg>
12              </wishlist-item-delete-button>
13              ${render_pro_image.outerHTML}
14              ${product.has_only_default_variant=="false"||product.has_only_default_variant==0||product.has_only_default_variant==!1?`<a href="${product.url}" class="btn-add-cart demo">${wishlist.choose_option}</a>`:`<add-to-cart href="${product.url}" class="btn-add-cart demo" data-variant-id="${product.variantId}" data-id="${product.id}"  role="button" tabindex="0">${wishlist.add_to_cart}</add-to-cart><form method="post" action="/cart/add" id="product-form-template--20440754225444__product-grid8653905461540" accept-charset="UTF-8" class="form" enctype="multipart/form-data" novalidate="novalidate" data-type="add-to-cart-form"><input type="hidden" name="form_type" value="product"><input type="hidden" name="utf8" value="\u2713"><input type="hidden" name="id" value="${product.variantId}" class="product-variant-id"></form>`}
15              ${pro_badges}
16            </div>
17            <div class="product_info_wrapper">
18              <h3 class="product-name">
19                <a href="${product.url}">${product.title}</a>
20              </h3>
21              <div class="product_inner_info">
22                <div class="product-price">
23                  ${pro_compare_price}
24                  <span class="woocommerce-Price-amount amount"><bdi>${product.price}</bdi></span>
25                </div>
26                <div class="go_to_product">
27                  <a href="${product.url}" class="go-top-product_btn button button--primary">${wishlist.choose_option}</a>
28                </div>
29              </div>
30            </div>
31          </div>
32        </wishlist-item>`}renderContentFromSessionStorage(){const storedData=JSON.parse(localStorage.getItem("wishlist_items")||"[]"),wishlistItemsElement=document.querySelector("wishlist-items"),wishlistButtons=document.querySelectorAll("wishlist-button");if(storedData.length>=1){const renderedItems=storedData.map(product=>this.renderWishlistItem(product));wishlistItemsElement.innerHTML=renderedItems.join(`
33`),this.updateWishlistBubble(),document.querySelector(".wishlist-pro-slider")&&setTimeout(function(){document.querySelectorAll(".wishlist-pro-slider").forEach(ele=>{var flkty=new Flickity(ele,{pageDots:!0,prevNextButtons:!1,wrapAround:!0})})},300)}wishlistButtons.forEach(button=>{button.classList.toggle("has_in_wishlist",this.checkIfProductExistInWishlist(button.dataset.id))})}checkIfProductExistInWishlist(productId){const storedData=localStorage.getItem("wishlist_items");return storedData?JSON.parse(storedData).some(product=>product.id===productId):!1}updateWishlistBubble(){let layout="";const storedData=localStorage.getItem("wishlist_items");if(storedData&&JSON.parse(storedData).length>=1){var productData=JSON.parse(storedData);layout=`<div class="cart-count-bubble">
34            <span aria-hidden="true">${productData.length}</span>
35            <span class="visually-hidden">${productData.length} Items</span>
36        </div>`,this.setDrawerStatus(!0)}else this.setDrawerStatus(!1);document.querySelector("#WishlistDrawer .drawer__heading span").innerHTML=`(${JSON.parse(storedData).length})`,document.querySelector("#wishlist-bubble-container").innerHTML=layout}setActiveElement(element){this.activeElement=element}setDrawerStatus(status){let $this=this;status?$this.classList.remove("wishlist-empty"):setTimeout(()=>{$this.classList.add("wishlist-empty")},500)}removeProductFromSessionStorage(productIdToRemove){let storedData=localStorage.getItem("wishlist_items");if(storedData){let updatedData=JSON.parse(storedData).filter(product=>product.id!==productIdToRemove);localStorage.setItem("wishlist_items",JSON.stringify(updatedData)),this.updateWishlistBubble()}}}customElements.define("wishlist-drawer",WishlistDrawer);class WishlistItems extends HTMLElement{constructor(){super()}}customElements.define("wishlist-items",WishlistItems);class WishlistItem extends WishlistItems{}customElements.define("wishlist-item",WishlistItem);class WishlistDeleteButton extends WishlistItem{constructor(){super(),this.addEventListener("click",this.removeItem)}removeItem(){let product_id=this.dataset.id;this.sendDeleteRequest(product_id),document.querySelector("wishlist-drawer").removeProductFromSessionStorage(product_id),this.fadeAndRemove(this.closest("wishlist-item")),document.querySelectorAll("wishlist-button").forEach(button=>{button.classList.toggle("has_in_wishlist",this.checkIfProductExistInWishlist(button.dataset.id))})}checkIfProductExistInWishlist(productId){const storedData=localStorage.getItem("wishlist_items");return storedData?JSON.parse(storedData).some(product=>product.id===productId):!1}fadeAndRemove(el){var opacity=1,interval=setInterval(function(){opacity>0?(opacity-=.1,el.style.opacity=opacity):(clearInterval(interval),el.style.display="none",el.remove())},25)}sendDeleteRequest(itemId){const endpoint=`${wishlist_api}/api/wishlist`,payload={user_id:localStorage.getItem("userId"),product_id:itemId},payloadJSON=JSON.stringify(payload);fetch(endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:payloadJSON}).then(response=>{if(!response.ok)throw new Error("Network response was not ok")}).catch(error=>{console.error("Error:",error)})}}customElements.define("wishlist-item-delete-button",WishlistDeleteButton);class WishlistButton extends HTMLElement{constructor(){super(),this.addEventListener("click",this.handleButtonClicked),this.checkIfProductExistInWishlist(this.dataset.id)&&this.classList.add("has_in_wishlist")}handleButtonClicked(){let prod=this.getProductObject(this.dataset);this.classList.contains("has_in_wishlist")?(this.classList.remove("has_
36in_wishlist"),this.removeFromWishlist(prod)):(this.classList.add("has_in_wishlist"),this.addToWishlist(prod),setTimeout(()=>{this.openDrawer()},200)),document.querySelector("wishlist-drawer").renderContentFromSessionStorage()}addToWishlist(prod){this.appendJsonToSessionStorage(prod),this.sendWishlistItem(prod)}removeFromWishlist(prod){document.querySelector("wishlist-drawer").removeProductFromSessionStorage(prod.id),document.querySelector("wishlist-item-delete-button").sendDeleteRequest(prod.id)}openDrawer(){document.querySelector("wishlist-drawer").open()}getProductObject(prod){return{has_only_default_variant:prod.has_only_default_variant,id:prod.id,title:prod.title,price_varies:prod.price_varies,price:prod.price,price_max:prod.price_max,price_min:prod.price_min,src:prod.src,url:prod.url,variantId:prod.variantId,compare_price:prod.compareprice,saleBadge:prod.salebadge,soldBadge:prod.soldbadge,tagBadge:prod.tagbadge}}appendJsonToSessionStorage(jsonData){let existingData=localStorage.getItem("wishlist_items");if(existingData){let parsedData=JSON.parse(existingData);parsedData.push(jsonData),localStorage.setItem("wishlist_items",JSON.stringify(parsedData))}else localStorage.setItem("wishlist_items",JSON.stringify([jsonData]))}checkIfProductExistInWishlist(productId){const storedData=localStorage.getItem("wishlist_items");return storedData?JSON.parse(storedData).some(product=>product.id===productId):!1}sendWishlistItem(prod){const userId=localStorage.getItem("userId"),endpoint=`${wishlist_api}/api/wishlist`,dynamicPayload={user_id:userId,...prod},dynamicPayloadJSON=JSON.stringify(dynamicPayload);fetch(endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:dynamicPayloadJSON}).then(response=>{if(!response.ok)throw new Error("Network response was not ok");return response.json()}).then(data=>{}).catch(error=>{console.error("Error:",error)})}}customElements.define("wishlist-button",WishlistButton);class WishlistATCButton extends HTMLElement{constructor(){super(),this.addEventListener("click",this.quickAddToCart)}quickAddToCart(){var $this=this;if(this.getAttribute("disabled"))alert("Clicked");else{this.setAttribute("disabled",!0),this.innerHTML=`<svg aria-hidden="true" focusable="false" class="spinner" viewBox="0 0 66 66" xmlns="http://www.w3.org/2000/svg">
37            <circle class="path" fill="none" stroke-width="6" cx="33" cy="33" r="30"></circle>
38        </svg>  \u05D4\u05D5\u05E1\u05E4\u05D4 \u05DC\u05E2\u05D2\u05DC\u05D4`;let product_id=this.dataset.id;var xhr=new XMLHttpRequest;xhr.open("POST","/cart/add.js",!0),xhr.setRequestHeader("Content-Type","application/json"),xhr.onreadystatechange=function(){if(xhr.readyState===4)if(xhr.status===200){var data2=JSON.parse(xhr.responseText);fetch(`${routes.cart_url}?sections=cart-drawer,cart-icon-bubble`).then(response=>response.json()).then(response=>{let responseFormated={sections:response,...data2.items[0]},cart_drawer=document.querySelector("cart-notification")||document.querySelector("cart-drawer");cart_drawer.renderContents(responseFormated),$this.innerHTML="\u05D4\u05D5\u05E1\u05E4\u05D4 \u05DC\u05E1\u05DC \u05D4\u05E7\u05E0\u05D9\u05D5\u05EA",cart_drawer&&cart_drawer.classList.contains("is-empty")&&cart_drawer.classList.remove("is-empty"),$this.removeAttribute("disabled"),document.querySelector("wishlist-item-delete-button").sendDeleteRequest(product_id),document.querySelector("wishlist-drawer").removeProductFromSessionStorage(product_id),document.querySelector("wishlist-drawer").renderContentFromSessionStorage()})}else $this.innerHTML="\u05D4\u05D5\u05E1\u05E4\u05D4 \u05DC\u05E1\u05DC \u05D4\u05E7\u05E0\u05D9\u05D5\u05EA",$this.removeAttribute("disabled")};var data=JSON.stringify({items:[{id:this.dataset.variantId,quantity:1}]});xhr.send(data)}}fadeAndRemove(el){var opacity=1,interval=setInterval(function(){opacity>0?(opacity-=.1,el.style.opacity=opacity):(clearInterval(interval),el.style.display="none",el.remove())},25)}}customElements.define("add-to-cart",WishlistATCButton);
39//# sourceMappingURL=/cdn/shop/t/4/assets/wishlist-drawer.js.map?v=60310897365362532041772800160

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.