PageSourceSearch

https://diamondrensu.com/cdn/shop/t/277/assets/custom-wishlist.js?v=80154982837122835911788237237

js diamondrensu.com collected 2026-10-02 10:07:08 UTC 6,513 bytes, 2 lines download raw bytes

1function getLocalWishlistCount(){try{return(JSON.parse(localStorage.getItem("wishlist"))||{items:[]}).items.length}catch{return 0}}function updateWishlistHeaderCount(count){const value=Math.max(0,Number(count)||0);window.wishlistItemCount=value,document.querySelectorAll("[data-wishlist-count]").forEach(el=>{el.textContent=String(value),el.classList.toggle("d-none",value===0)})}function initWishlistHeaderCount(){const customerId=window.customerDetails?.id;if(customerId){fetch(`https://certificate-manager.diamondrensu.com/api/wishlist?customer_id=${customerId}`,{method:"GET",headers:{"Content-Type":"application/json","X-Shop":"diamondrensu-new.myshopify.com"}}).then(response=>response.json()).then(data=>{const items=data?.data?.data||[];updateWishlistHeaderCount(data?.data?.total??items.length)}).catch(()=>{updateWishlistHeaderCount(getLocalWishlistCount())});return}updateWishlistHeaderCount(getLocalWishlistCount())}class customWishlist extends HTMLElement{constructor(){super(),this.productID=this.dataset.id,this.customer_id=this.dataset.customer_id,this.type=this.dataset.type,this.productType=this.dataset.product_type,this.featured_image=window.globalSpace.product.featured_image,this.varientID=this.dataset.varientid,this.checkvariINwishlist(),this.addEventListener("click",()=>this.manageWishlist(this)),this.variantOptions=this.closest(".product-form")?.querySelectorAll("[data-optionindex], [data-ring-size]"),this.variantRadioOptions=this.closest(".product-form")?.querySelectorAll("[data-stone-size], [data-metal-tone], [data-metal-type], fieldset")}checkvariINwishlist(){let variant_id=this.varientID;if(this.customer_id!==null&&this.customer_id!==""){const endpoint=`https://certificate-manager.diamondrensu.com/api/wishlist?customer_id=${this.customer_id}&variant_id=${this.varientID}`;fetch(endpoint,{method:"GET",headers:{"Content-Type":"application/json","X-Shop":"diamondrensu-australia.myshopify.com"}}).then(response=>response.json()).then(data=>{data.data.data.forEach(ele=>{variant_id==ele.variant_id&&this.classList.add("wishlist_added")})}).catch(error=>{console.error("Error fetching wishlist data from API:",error)})}else(JSON.parse(localStorage.getItem("wishlist"))||{items:[]}).items.some(item=>item.variant_id===variant_id&&item.product_id===this.productID)?this.classList.add("wishlist_added"):this.classList.remove("wishlist_added")}manageWishlist(){let line_item_properties={};var variantsHasOptions=!0,variantsHasRadioOptions=!0;this.varientID=document.querySelector(".product-form")?.querySelector('[name="id"]').value||this.dataset.varientid;const requiredData={customer_id:this.customer_id?parseInt(this.customer_id,10):null,shop:"diamondrensu-new.myshopify.com",product_id:this.productID,variant_id:this.varientID,product_title:window.globalSpace.product.title,handle:window.globalSpace.product.handle,item_qty:1,image:this.featured_image,type:this.type,product_price:this.dataset.price,product_compare_price:this.dataset.comapre_at_price,is_save_later:!1,line_item_properties};this.classList.contains("wishlist_added")?this.customer_id?this.removeToWishlist():this.removeFromLocalWishlist():(line_item_properties={},requiredData.line_item_properties=line_item_properties,this.customer_id?variantsHasOptions&&variantsHasRadioOptions&&this.addToWishlist([requiredData]):variantsHasOptions&&variantsHasRadioOptions&&this.updateWishlist(requiredData))}removeFromLocalWishlist(){let wishlist=JSON.parse(localStorage.getItem("wishlist"))||{items:[]};wishlist.items=wishlist.items.filter(item=>!(item.product_id===this.productID&&item.variant_id===this.varientID)),localStorage.setItem("wishlist",JSON.stringify(wishlist)),this.classList.remove("wishlist_added"),updateWishlistHeaderCount(wishlist.items.length),window.notificationEle.updateNotification("","Item has been successfully removed from your wishlist",{type:"error",timeout:3e3})}removeToWishlist(){if(console.log("tests"),this.customer_id){const endpoint="https://certificate-manager.diamondrensu.com/api/wishlist/remove",body={customer_id:this.customer_id,product_id:this.productID,variant_id:this.varientID};fetch(endpoint,{method:"DELETE",headers:{"Content-Type":"application/json","X-Shop":"diamondrensu-australia.myshopify.com"},body:JSON.stringify(body)}).then(response=>response.json()).then(data=>{this.classList.remove("wishlist_added"),updateWishlistHeaderCount((window.wishlistItemCount||1)-1),window.notificationEle.updateNotification("","Item has been successfully removed from your wishlist",{type:"error",timeout:3e3})}).catch(error=>{console.error("Error:",error)})}else{let wishlist=JSON.parse(localStorage.getItem("wishlist"))||{items:[]};wishlist.items=wishlist.items.filter(item=>!(item.product_id===this.productID&&item.variant_id===this.varientID)),localStorage.setItem("wishlist",JSON.stringify(wishlist)),this.classList.remove("wishlist_added"),updateWishlistHeaderCount(wishlist.items.length),window.notificationEle.updateNotification("","Item has been successfully removed from your wishlist",{type:"error",timeout:3e3})}}addToWishlist(items){fetch("https://certificate-manager.diamondrensu.com/api/wishlist/addbulkwishlist",{method:"POST",headers:{"Content-Type":"application/json","X-Shop":"diamondrensu-new.myshopify.com"},body:JSON.stringify({items})}).then(response=>response.json()).then(data=>{this.classList.add("wishlist_added"),updateWishlistHeaderCount((window.wishlistItemCount||0)+1),window.notificationEle.updateNotification("","Item has been successfully added to wishlist, view  My Wishlist",{type:"success",timeout:3e3})}).catch(error=>{console.error("Error:",error)})}updateWishlist(newItem){let wishlist=JSON.parse(localStorage.getItem("wishlist"))||{items:[]};const existingIndex=wishlist.items.findIndex(item=>item.product_id===newItem.product_id&&item.variant_id===newItem.variant_id);existingIndex>-1?wishlist.items[existingIndex]=newItem:wishlist.items.push(newItem),localStorage.setItem("wishlist",JSON.stringify(wishlist)),window.notificationEle.updateNotification("","Item has been temporarily added to wishlist, please login to save it permanently",{type:"error",timeout:3e3}),this.classList.add("wishlist_added")}scrollToField(element){let offsetPosition=element.getBoundingClientRect().top+window.pageYOffset-250;window.scrollTo({top:offsetPosition,behavior:"smooth"})}}customElements.define("custom-wishlist",customWishlist),initWishlistHeaderCount();
2//# sourceMappingURL=/cdn/shop/t/277/assets/custom-wishlist.js.map?v=80154982837122835911788237237

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.