1(function ($) { 2 "use strict"; 3 4 $(document).on("click", ".pe-wishlist-btn", function (e) { 5 e.preventDefault(); 6 let productId = $(this).data("product-id"); 7 let btn = $(this); 8 let widgetSettings; 9 10 if ($('.pe--wishlist.archive-products-section').length) { 11 widgetSettings = $('.pe--wishlist.archive-products-section').parents('.elementor-element').data('settings') || {}; 12 } else { 13 widgetSettings = []; 14 } 15 16 btn.addClass("loading"); 17 18 // let wishlist = getWishlistCookie(); 19 20 // if (wishlist.includes(productId)) { 21 // wishlist = wishlist.filter((id) => id !== productId); 22 23 // } else { 24 // wishlist.push(productId); 25 26 // } 27 // setWishlistCookie(wishlist); 28 // console.log(wishlist) 29 30 // let isLoggedIn = woocommerce_params.is_user_logged_in === "1"; 31 32 $.ajax({ 33 url: woocommerce_params.ajax_url, 34 type: "POST", 35 data: { 36 action: "pe_toggle_wishlist", 37 product_id: productId, 38 settings: widgetSettings 39 }, 40 dataType: "json", 41 success: function (data) { 42 43 if (data.success) { 44 btn.removeClass("loading"); 45 document.dispatchEvent(new CustomEvent("wishlistUpdated")); 46 47 setTimeout(() => { 48 if (data.data.status === "added") { 49 btn.addClass("in--wishlist"); 50 51 if (document.querySelector('.pe--wishlist.archive-products-section')) { 52 var parser = new DOMParser(), 53 responseHTML = parser.parseFromString(data.data.product_html, 'text/html'), 54 productHtml = responseHTML.querySelector('.saren--single--product'); 55 56 if (productHtml) { 57 document.querySelector('.pe--wishlist.archive-products-section .saren--products-grid').insertAdjacentHTML('beforeend', productHtml.outerHTML); 58 } 59 } 60 61 } else if (data.data.status === "removed") { 62 63 btn.removeClass("in--wishlist"); 64 65 if (document.querySelector('.pe--wishlist.archive-products-section')) { 66 document.querySelectorAll('.pe--wishlist.archive-products-section').forEach(wishlist => { 67 wishlist.querySelector('.post-' + productId).remove(); 68 }); 69 } 70 71 } 72 }, 10); 73 } 74 }, 75 error: function (response) { 76 console.log(response); 77 } 78 }); 79 80 81 }); 82 83 // function getWishlistCookie() { 84 // let cookieValue = document.cookie 85 // .split("; ") 86 // .find((row) => row.startsWith("pe_wishlist=")); 87 88 // return cookieValue ? JSON.parse(decodeURIComponent(cookieValue.split("=")[1])) : []; 89 // } 90 91 // function setWishlistCookie(wishlist) { 92 // document.cookie = `pe_wishlist=${encodeURIComponent(JSON.stringify(wishlist))}; path=/; max-age=${30 * 24 * 60 * 60}`;
93 // } 94 95 96 97 98}(jQuery));
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.