Advertisement
Guest User

well

a guest
Oct 18th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ! function() {
  2.     var e = function(e) {
  3.             var t = {
  4.                 exports: {}
  5.             };
  6.             return e.call(t.exports, t, t.exports), t.exports
  7.         },
  8.         i = function() {
  9.             function r(e, t) {
  10.                 for (var n = 0; n < t.length; n++) {
  11.                     var r = t[n];
  12.                     r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r)
  13.                 }
  14.             }
  15.             return function(e, t, n) {
  16.                 return t && r(e.prototype, t), n && r(e, n), e
  17.             }
  18.         }(),
  19.         h = function(e, t) {
  20.             if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
  21.         };
  22.     e(function(e, t) {
  23.         "use strict";
  24.  
  25.         function s(e) {
  26.             for (var t = e.split("&"), n = 0; n < t.length; n++) {
  27.                 var r = t[n].split("=");
  28.                 if ("quantity" === r[0]) return r[1]
  29.             }
  30.             return 1
  31.         }
  32.  
  33.         function c(e, t) {
  34.             var n = u({
  35.                 variantId: e.id.to_s,
  36.                 productId: e.product_id,
  37.                 currency: window.ShopifyAnalytics.meta.currency,
  38.                 quantity: (t || 1).to_s,
  39.                 price: e.price / 100,
  40.                 name: e.title,
  41.                 sku: e.sku,
  42.                 brand: e.vendor,
  43.                 variant: e.variant_title,
  44.                 category: e.product_type
  45.             }, d());
  46.             window.ShopifyAnalytics.lib.track("Added Product", n), window.ShopifyAnalytics.lib.track("monorail://trekkie_storefront_track_added_product/1.0", n)
  47.         }
  48.  
  49.         function d() {
  50.             var e = {};
  51.             return window.ShopifyAnalytics.meta.page && (e = {
  52.                 pageType: window.ShopifyAnalytics.meta.page.pageType,
  53.                 resourceType: window.ShopifyAnalytics.meta.page.resourceType,
  54.                 resourceId: window.ShopifyAnalytics.meta.page.resourceId
  55.             }), e
  56.         }
  57.  
  58.         function u(e, t) {
  59.             for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
  60.             return e
  61.         }
  62.         Object.defineProperty(t, "__esModule", {
  63.             value: !0
  64.         });
  65.         var n, r, o, l = function() {
  66.             function o(e, t, n, r) {
  67.                 h(this, o), this.xhr = e, this.url = t, this.method = n, this.body = r
  68.             }
  69.             return i(o, null, [{
  70.                 key: "handleXhrOpen",
  71.                 value: function e() {}
  72.             }]), i(o, [{
  73.                 key: "onReadyStateChange",
  74.                 value: function t() {
  75.                     this.xhr.readyState === XMLHttpRequest.DONE && this.handleXhrDone({
  76.                         method: this.method,
  77.                         url: this.url,
  78.                         body: this.body,
  79.                         xhr: this.xhr
  80.                     }), this.oldOnReadyStateChange && this.oldOnReadyStateChange()
  81.                 }
  82.             }, {
  83.                 key: "handleXhrDone",
  84.                 value: function n(e) {
  85.                     try {
  86.                         switch (e.url) {
  87.                             case "/cart/add.js":
  88.                                 e.xhr.responseText && c(JSON.parse(e.xhr.responseText), s(e.body));
  89.                                 break;
  90.                             case "/cart/change.js":
  91.                             case "/cart/clear.js":
  92.                             case "/cart.js":
  93.                                 e.xhr.responseText && this.facebookMessengerPayment(JSON.parse(e.xhr.responseText))
  94.                         }
  95.                     } catch (t) {
  96.                         console && console.warn && console.warn("[shop_events_listener] Error in handleXhrDone:  " + t.message)
  97.                     }
  98.                 }
  99.             }, {
  100.                 key: "facebookMessengerPayment",
  101.                 value: function r(e) {
  102.                     window.MessengerExtensions && window.MessengerExtensions.isInExtension() && window.MessengerExtensions.updateCart(function() {}, function() {}, e.item_count, "https://" + this._hostName() + "/cart", 300)
  103.                 }
  104.             }, {
  105.                 key: "_hostName",
  106.                 value: function a() {
  107.                     return window.location.hostname
  108.                 }
  109.             }]), o
  110.         }();
  111.         t["default"] = l,
  112.             function() {
  113.                 function r(e, t, n) {
  114.                     window.jQuery && window.jQuery(e).bind ? window.jQuery(e).bind(t, n) : e.addEventListener ? e.addEventListener(t, n) : e.attachEvent && e.attachEvent("on" + t, n)
  115.                 }
  116.  
  117.                 function o(e) {
  118.                     if (!((e = e || window.event).defaultPrevented || e.isDefaultPrevented && e.isDefaultPrevented())) {
  119.                         var t = e.target || e.srcElement;
  120.                         if (t && (t.getAttribute("action") || t.getAttribute("href"))) try {
  121.                             var n = c((t.id.options ? t.id.options[t.id.selectedIndex] : t.id).value);
  122.                             n.quantity = (t.quantity ? t.quantity.value : 1).to_s, window.ShopifyAnalytics.lib.track("Added Product", n), window.ShopifyAnalytics.lib.track("monorail://trekkie_storefront_track_added_product/1.0", n)
  123.                         } catch (r) {
  124.                             console && console.warn && console.warn("[shop_events_listener] Error in handleSubmitCartAdd: " + r.message)
  125.                         }
  126.                     }
  127.                 }
  128.  
  129.                 function a(e) {
  130.                     var t = (e = e || window.event).target || e.srcElement;
  131.                     if (t && t.getAttribute("action")) try {
  132.                         window.ShopifyAnalytics.lib.track("Added Payment", {
  133.                             currency: window.ShopifyAnalytics.meta.currency,
  134.                             total: window.ShopifyAnalytics.meta.checkout.payment_due / 100
  135.                         })
  136.                     } catch (n) {
  137.                         console && console.warn && console.warn("[shop_events_listener] Error in handleSubmitToPaymentAdd: " + n.message)
  138.                     }
  139.                 }
  140.  
  141.                 function i(e) {
  142.                     s((e = e || window.event).currentTarget)
  143.                 }
  144.  
  145.                 function s(e) {
  146.                     try {
  147.                         var t = void 0;
  148.                         if (!(t = e.id.options && e.id.options[e.id.selectedIndex] ? e.id.options[e.id.selectedIndex] : e.id)) return;
  149.                         var n = t.value;
  150.                         if (window.ShopifyAnalytics.meta.selectedVariantId && window.ShopifyAnalytics.meta.selectedVariantId == n) return;
  151.                         var r = c(window.ShopifyAnalytics.meta.selectedVariantId = n);
  152.                         window.ShopifyAnalytics.lib.track("Viewed Product Variant", r), window.ShopifyAnalytics.lib.track("monorail://trekkie_storefront_track_viewed_product_variant/1.0", r)
  153.                     } catch (o) {
  154.                         console && console.warn && console.warn("[shop_events_listener] Error in trackViewedProductVariant: " + o.message)
  155.                     }
  156.                 }
  157.  
  158.                 function c(e) {
  159.                     var t = u(n(e), d());
  160.                     return t.currency = window.ShopifyAnalytics.meta.currency, t
  161.                 }
  162.  
  163.                 function n(e) {
  164.                     var t = void 0,
  165.                         n = window.ShopifyAnalytics.meta.product;
  166.                     if (n) {
  167.                         t = {
  168.                             productId: n.id,
  169.                             brand: n.vendor,
  170.                             category: n.type
  171.                         };
  172.                         for (var r = 0; r < n.variants.length; r++)
  173.                             if (n.variants[r].id == e) {
  174.                                 var o = n.variants[r];
  175.                                 t = u(t, {
  176.                                     variantId: e,
  177.                                     price: o.price / 100,
  178.                                     name: o.name,
  179.                                     sku: o.sku,
  180.                                     variant: o.public_title
  181.                                 })
  182.                             }
  183.                     } else t = {
  184.                         variantId: e
  185.                     };
  186.                     return t
  187.                 }
  188.                 r(window, "load", function() {
  189.                     for (var e = 0; e < document.forms.length; e++) {
  190.                         var t = document.forms[e].getAttribute("action");
  191.                         t && 0 <= t.indexOf("/cart/add") && (r(document.forms[e], "submit", o), r(document.forms[e], "change", i), s(document.forms[e]));
  192.                         var n = document.forms[e].elements.previous_step;
  193.                         n && "payment_method" === n.value && r(document.forms[e], "submit", a)
  194.                     }
  195.                 })
  196.             }(), n = XMLHttpRequest, r = n.prototype.open, o = n.prototype.send, n.prototype.open = function(e, t) {
  197.                 this._url = t, this._method = e, l.handleXhrOpen(), r.apply(this, arguments)
  198.             }, n.prototype.send = function(e) {
  199.                 var t = new l(this, this._url, this._method, e);
  200.                 this.addEventListener ? this.addEventListener("readystatechange", t.onReadyStateChange.bind(t), !1) : (t.oldOnReadyStateChange = this.onreadystatechange, this.onreadystatechange = t.onReadyStateChange), o.call(this, e)
  201.             },
  202.             function(e, t) {
  203.                 function r(e) {
  204.                     e.clone().json().then(function(e) {
  205.                         return l.prototype.facebookMessengerPayment(e)
  206.                     })["catch"](a)
  207.                 }
  208.  
  209.                 function o(e, t) {
  210.                     e.clone().json().then(function(e) {
  211.                         return c(e, t)
  212.                     })["catch"](a)
  213.                 }
  214.  
  215.                 function a(e) {
  216.                     console && console.warn && console.warn("[shop_events_listener] Error in handleFetchRequest:  " + e.message)
  217.                 }
  218.  
  219.                 function i(e) {
  220.                     var t = void 0;
  221.                     try {
  222.                         t = JSON.parse(e).quantity || 1
  223.                     } catch (n) {
  224.                         t = s(e)
  225.                     }
  226.                     return t
  227.                 }
  228.                 "function" == typeof t && (e.fetch = function() {
  229.                     var n = arguments;
  230.                     return t.apply(this, Array.prototype.slice.call(arguments)).then(function(e) {
  231.                         if (!e.ok) return e;
  232.                         try {
  233.                             switch (!0) {
  234.                                 case e.url.includes("/cart/add.js"):
  235.                                     o(e, i(n[1].body));
  236.                                     break;
  237.                                 case e.url.includes("/cart/change.js"):
  238.                                 case e.url.includes("/cart/clear.js"):
  239.                                 case e.url.includes("/cart.js"):
  240.                                     r(e)
  241.                             }
  242.                         } catch (t) {
  243.                             a(t)
  244.                         }
  245.                         return e
  246.                     })
  247.                 })
  248.             }(window, window.fetch)
  249.     })
  250. }("undefined" != typeof global ? global : "undefined" != typeof window && window);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement