1/** 2 * 2017 Keshva Thakur 3 * @author Keshva Thakur 4 * @copyright Keshva Thakur 5 * @license https://www.prestashop.com/en/osl-license 6 * @version 1.1.8 7 */ 8 9var ga4 = {}; 10 11window.addEventListener('load',function() { 12 ga4 = { 13 response: null, 14 15 pcommon: { 16 'ajax': 1, 17 // 'module_name': 'ga4', 18 // 'configure': 'ga4', 19 'token': ga4_token, 20 'rand': new Date().getTime() 21 }, 22 23 ajaxCall: function (params, callback) { 24 if (typeof params.data != 'undefined') { 25 var contentType = false; 26 var processData = false; 27 var data = params.data; 28 delete params.data; 29 Object.assign(params, this.pcommon); 30 $.each(params, function(index, value) { 31 data.append(index, value); 32 }); 33 } else { 34 var contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; 35 var processData = true; 36 var data = {}; 37 Object.assign(data, this.pcommon, params); 38 } 39 return $.ajax({ 40 'url': ga4_link, 41 'method': 'post', 42 'dataType': 'json', 43 'contentType': contentType, 44 'processData': processData, 45 'cache': false, 46 'data': data, 47 'success': function (data) { 48 if (typeof callback != 'undefined') { 49 eval(callback + '(params, data)'); 50 } 51 }, 52 'error': function (data) { 53 console.log(data) 54 //alert("leer error"); 55 } 56 }); 57 }, 58 addToCart(params, data) { 59 if (typeof data.value != 'undefined') { 60 gtag('event', 'add_to_cart', data); 61 } 62 }, 63 }; 64}); 65 66$( document ).ajaxComplete(function( event, xhr, settings ) { 67 if (typeof settings.data !== 'undefined' && ( 68 (settings.data.search('add-to-cart') > -1 || settings.data.search('add') > -1) || 69 ( 70 settings.data.search('controller=cart') > -1 && 71 settings.data.search('id_product=') > -1 72 )) 73 && settings.data.search('getProductPopupAdded') == -1 74 ) { 75 var id_product = 0; 76 var id_product_attribute = 0; 77 var regex_p = /[&|?]?id_product=([0-9]+)/gm 78 var match_p = regex_p.exec(settings.data); 79 if (typeof match_p[1] != 'undefined') { 80 id_product = match_p[1]; 81 } 82 var regex_pa = /[&|?]?id_product_attribute|ipa=([0-9]+)/gm 83 var match_pa = regex_pa.exec(settings.data); 84 if (match_pa != null && typeof match_pa[1] != 'undefined') { 85 id_product_attribute = match_pa[1]; 86 } 87 if ($('input[name="qty"]').length) { 88 var quantity = $('input[name="qty"]').val(); 89 } else { 90 var quantity = 1; 91 } 92 if (id_product > 0) { 93 var params = { 94 'action': 'getProduct', 95 'id_product': id_product, 96 'id_product_attribute': id_product_attribute, 97 'quantity': quantity 98 }; 99 //console.log('ga4.addToCart'); 100 ga4.ajaxCall(params, 'ga4.addToCart'); 101 } 102 } 103});
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.