1var $j = jQuery.noConflict(); 2 3$j(document).ready(function() { 4 var cartElement = document.querySelector('.nectar-slide-in-cart'); 5 var ajaxTimeout = null; 6 var debounceDelay = 300; 7 8 if (cartElement) { 9 var observer = new MutationObserver(function(mutations) { 10 mutations.forEach(function(mutation) { 11 if (mutation.type === 'attributes' && mutation.attributeName === 'class') { 12 var hasOpen = cartElement.classList.contains('open'); 13 14 if (hasOpen) { 15 // Cancel the previous request if it exists 16 clearTimeout(ajaxTimeout); 17 18 // Send the request after the delay 19 ajaxTimeout = setTimeout(function() { 20 // Get the discount message 21 $j.ajax({ 22 type: 'POST', 23 url: '/wp-admin/admin-ajax.php', 24 cache: false, 25 data: { 26 action: "nectar_minicart_custom_discounts" 27 }, 28 success: function (response) { 29 if (response && response.amount_to_spend_message) { 30 if ($j('.widget_shopping_cart .discount-message').length > 0) { 31 $j('.widget_shopping_cart .discount-message').text(response.amount_to_spend_message); 32 } 33 } 34 }, 35 error: function(xhr, status, error) { 36 //* DEBUG 37 // console.error('Erreur AJAX:', error); 38 } 39 }); 40 }, debounceDelay); 41 } 42 } 43 }); 44 }); 45 46 observer.observe(cartElement, { 47 attributes: true, 48 attributeFilter: ['class'] 49 }); 50 } 51});
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.