1var ecblib = ecblib || {}; 2ecblib.goods_ajax_cart_sb = ecblib.goods_ajax_cart_sb || {}; 3 4jQuery(function () { 5 var _goods_ajax_cart_sb = ecblib.goods_ajax_cart_sb; 6 7 var wait_class = 'js-animation-add-cart-in-progress'; 8 var wait_value = ecblib.msg.goods_ajax_cart_sb.PLEASE_WAIT; 9 var s_width = 60; 10 var l_width = 200; 11 if (document.URL.match("cart.aspx")) { 12 return false; 13 } 14 var $btn_cart = jQuery(".js-animation-add-cart"); 15 var noraml_class = $btn_cart.attr("class"); 16 jQuery(document).off("click", ".js-animation-add-cart"); 17 jQuery(document).on("click", ".js-animation-add-cart", function (e) { 18 var loadStart = function (elem) { 19 jQuery(elem).addClass(wait_class); 20 jQuery(elem).text(wait_value); 21 return elem; 22 }; 23 var loadEnd = function (elem, iserror) { 24 if (!iserror) { 25 ecblib.ui.showToolTip(jQuery("." + wait_class), { tooltip: ecblib.msg.goods_ajax_cart_sb.TO_SHOPPING_CART, diptimeSec: 2 }); 26 ecblib.ui.showCartCount(); 27 setTimeout(function () { 28 jQuery(elem).removeClass(wait_class); 29 jQuery(elem).text(ecblib.msg.goods_ajax_cart_sb.PUT_IN_SHOPPING_CART); 30 }, 2400); 31 32 } else { 33 jQuery(elem).removeClass(wait_class); 34 jQuery(elem).text(ecblib.msg.goods_ajax_cart_sb.PUT_IN_SHOPPING_CART); 35 } 36 }; 37 var addCart = function (b, g) { 38 var o = loadStart(b); 39 jQuery.ajax({ 40 async: true, 41 type: "POST", 42 url: ecblib.sys.wwwroot + "/shop/js/addcart.aspx", 43 data: { 44 "goods": goods, 45 "qty": qty, 46 "crsirefo_hidden": crsirefo_jscart 47 }, 48 cache: false, 49 ifModified: false, 50 dataType: "json", 51 success: function (result) { 52 result = result || {}; 53 if ('ecblib' in window && 'abtest' in ecblib && 'loadABtest' in ecblib.abtest) { 54 ecblib.abtest.saveBlockClickLog("jscart"); 55 } 56 if (result.IsUseGtmGa === 'true') { 57 window.dataLayer = window.dataLayer || []; 58 dataLayer.push({ 59 'metatag_ga_virtualurl_addcart': result.AjaxVirtualUrl_AddCart, 60 'event': 'metatag_ga_cart_added' 61 }); 62 } else if (result.IsUseLegacyGa === 'true') { 63 if (typeof gtag == "function") { 64 var gatrackingcode = jQuery("meta[property='ecb:GATrackingCode']").attr('content'); 65 gtag('config', gatrackingcode, { 'page_title': 'AddCart', 'page_location': ecblib.sys.wwwroot + '/shop/cart/addcart.aspx?goods=' + goods }); 66 } 67 } 68 if (result.ErrMessage && result.ErrMessage.length > 0) { 69 ecblib.ui.alert(ecblib.msg.modal_title.ERROR, result.ErrMessage.join("\r\n").replace(/<\/?[^>]+>/gi, "")); 70 loadEnd(o, true); 71 return false; 72 } 73 if (jQuery("#jscart_replace_").length > 0) { 74 jQuery.ajax({ 75 type: 'GET', 76 url: ecblib.sys.wwwroot + '/shop/js/cart.aspx', 77 dataType: 'text', 78 async: false, 79 timeout: 10000 80 }).done(function(data){ 81 jQuery('#jscart_replace_').html(data); 82 setTimeout(function () { 83 loadEnd(o, false); 84 }, 400); 85 }); 86 } else { 87 setTimeout(function () { 88 loadEnd(o, false); 89 }, 400); 90 } 91 }, 92 error: function (xhr, status, thrown) { 93 loadEnd(o, true); 94 ecblib.ui.alert(ecblib.msg.modal_title.ERROR, ecblib.msg.goods_ajax_cart_sb.SESSION_EXPIRED); 95 return false; 96 } 97 }); 98 return true; 99 }; 100 if (jQuery(this).hasClass(wait_class)) { 101 return false; 102 } 103 var href = jQuery(this).attr("href"); 104 var re = new RegExp("goods=([0-9A-Za-z_\-]+)"); 105 var matches = href.match(re); 106 var goods = ""; 107 if (matches && matches.length == 2) { 108 goods = matches[1]; 109 } else { 110 return true; 111 }
112 var qty_re = new RegExp("qty=([0-9A-Za-z_\-]+)"); 113 var matches = href.match(qty_re); 114 var qty = ""; 115 if (matches && matches.length == 2) { 116 qty = matches[1]; 117 } else { 118 qty = 1 119 } 120 if (jQuery("#agree_" + goods).length > 0) { 121 var btn = this; 122 ecblib.ui.dialog('agree_' + goods, { 123 buttons: { 124 'btnAgree': function (action) { 125 addCart(btn, goods); 126 action.close(); 127 } 128 , 'btnNotAgree': function (action) { 129 action.close(); 130 } 131 } 132 }); 133 } else { 134 addCart(this, goods); 135 return false; 136 } 137 return false; 138 }); 139});
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.