1/* Javascript Document */ 2function showWishlistPopup(message){ 3 if( document.querySelector('#commercekit-wishlist-popup') ){ 4 var popup = document.querySelector('#commercekit-wishlist-popup'); 5 popup.innerHTML = message; 6 popup.style.display = 'block'; 7 setTimeout( function(){ document.querySelector('#commercekit-wishlist-popup').style.display = 'none';}, 2000); 8 } 9} 10document.addEventListener("DOMContentLoaded", function(){ 11 document.querySelectorAll('.commercekit-save-wishlist').forEach(function(object){ 12 object.setAttribute('href', '#wishlists'); 13 }); 14 if( document.querySelector('.commercekit-wishlist') ){ 15 document.querySelector('body').insertAdjacentHTML('afterbegin', '<div id="commercekit-wishlist-popup" style="display: none;"></div>'); 16 } 17 document.querySelector('body').addEventListener('click', function(event){ 18 $this = event.target.closest('a'); 19 if( $this && $this.classList.contains('commercekit-save-wishlist') ){ 20 event.preventDefault(); 21 processWishlistAction($this, 'commercekit_save_wishlist'); 22 } 23 if( $this && $this.classList.contains('commercekit-remove-wishlist') ){ 24 event.preventDefault(); 25 processWishlistAction($this, 'commercekit_remove_wishlist'); 26 } 27 }); 28 document.querySelector('body').addEventListener('click', function(event){ 29 $this = event.target; 30 if( $this.classList.contains('commercekit-remove-wishlist2') ){ 31 event.preventDefault(); 32 if( $this.classList.contains('processing') ) return true; 33 $this.classList.add('processing'); 34 var product_id = $this.getAttribute('data-product-id'); 35 var wpage = $this.getAttribute('data-wpage'); 36 var formData = new FormData(); 37 formData.append('product_id', product_id); 38 formData.append('wpage', wpage); 39 formData.append('type', 'list'); 40 formData.append('reload', '1'); 41 fetch( commercekit_ajs.ajax_url + '?action=commercekit_remove_wishlist', { 42 method: 'POST', 43 body: formData, 44 }).then(response => response.json()).then( json => { 45 if( json.status == 1 ){ 46 document.querySelector('#commercekit-wishlist-shortcode').innerHTML = json.html; 47 } 48 showWishlistPopup(json.message); 49 }); 50 } 51 if( $this.classList.contains('commercekit-wishlist-cart') ){ 52 event.preventDefault(); 53 $this.setAttribute('disabled', 'disabled'); 54 var product_id = $this.getAttribute('data-product-id'); 55 var formData = new FormData(); 56 formData.append('product_id', product_id); 57 fetch( commercekit_ajs.ajax_url + '?action=commercekit_wishlist_addtocart', { 58 method: 'POST', 59 body: formData, 60 }).then(response => response.json()).then( json => { 61 $this.removeAttribute('disabled'); 62 showWishlistPopup(json.message); 63 var wc_fragment = new Event('wc_fragment_refresh'); 64 document.body.dispatchEvent(wc_fragment); 65 }); 66 } 67 }); 68}); 69function processWishlistAction($this, action){ 70 if( $this.classList.contains('processing') ) return true; 71 $this.classList.add('processing'); 72 var parent = $this.parentNode; 73 var product_id = $this.getAttribute('data-product-id'); 74 var type = $this.getAttribute('data-type'); 75 var formData = new FormData(); 76 formData.append('product_id', product_id); 77 formData.append('type', type); 78 fetch( commercekit_ajs.ajax_url + '?action='+action, { 79 method: 'POST', 80 body: formData, 81 }).then(response => response.json()).then( json => { 82 if( json.status == 1 ){ 83 parent.innerHTML = json.html; 84 } 85 $this.classList.remove('processing'); 86 showWishlistPopup(json.message); 87 }); 88}
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.