Advertisement
PlotnikovPhilipp

Untitled

Jan 2nd, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function a(t) {
  2.     t.preventDefault();
  3.     var o = $(this);
  4.     if (o.attr("data-link-event-setted", "yes"), void 0 === o.attr("data-dbclk-prevent") || "yes" != o.attr("data-dbclk-prevent")) {
  5.       o.attr("data-dbclk-prevent", "yes"), setTimeout(function() {
  6.         o.removeAttr("data-dbclk-prevent")
  7.       }, 1e3), $("body").hasClass("t-body_popupshowed") && ($("body").removeClass("t-body_popupshowed"), $(".t-popup").removeClass("t-popup_show"), setTimeout(function() {
  8.         $(".t-popup").not(".t-popup_show").css("display", "none")
  9.       }, 300), tcart__clearProdUrl());
  10.       var r = o.attr("href"),
  11.         a = "0",
  12.         i = "",
  13.         c = "",
  14.         d = "",
  15.         n = "",
  16.         e = "",
  17.         s = "",
  18.         _ = "";
  19.       if ("#order:" == r.substring(0, 7)) {
  20.         var w = r.substring(7);
  21.         if (void 0 !== w && "" != w) {
  22.           if (0 < w.indexOf(":::")) {
  23.             var u = w.indexOf(":::");
  24.             if (0 < w.indexOf("=") && w.indexOf("=") < w.indexOf(":::")) {
  25.               var p = w.substring(u + 3);
  26.               w = w.substring(0, u)
  27.             }
  28.           }
  29.           var l;
  30.           if (0 < w.indexOf("=")) void 0 !== (l = w.split("="))[0] && (i = l[0]), void 0 !== l[1] && (a = l[1]), a = tcart__cleanPrice(a);
  31.           else i = w; if (void 0 !== p && "" != p)
  32.             if (0 < p.indexOf("=")) void 0 !== (l = p.split("="))[0] && void 0 !== l[1] && "" != l[0] && "" != l[1] && "image" == l[0] && 0 < l[1].indexOf("tildacdn.com") && (c = l[1]);
  33.             "" == s && void 0 === (s = o.closest(".r").attr("id").replace("rec", "")) && (s = "")
  34.         }
  35.       }
  36.       var m = $(this).closest(".js-product");
  37.       if (void 0 !== m) {
  38.         if ("" == i && void 0 === (i = m.find(".js-product-name").text()) && (i = ""), "" != a && 0 != a || (a = tcart__cleanPrice(a = m.find(".js-product-price").text())), "" == c)
  39.           if (void 0 !== m.attr("data-product-img") && "" != m.attr("data-product-img")) c = m.attr("data-product-img");
  40.           else {
  41.             var v = m.find(".js-product-img");
  42.             if (void 0 !== v && (v.is("img") && (c = v.attr("src")), v.is("div"))) {
  43.               c = "";
  44.               var y = v.css("background-image");
  45.               void 0 !== y && "" != y && (c = y.replace("url(", "").replace(")", "").replace(/\"/gi, ""))
  46.             }
  47.           }
  48.           "" == n && void 0 === (n = m.attr("data-product-lid")) && (n = ""), "" == e && void 0 === (e = m.attr("data-product-uid")) && (e = ""), "" == s && void 0 === (s = m.closest(".r").attr("id").replace("rec", "")) && (s = ""), "" == _ && void 0 === (_ = m.attr("data-product-inv")) && (_ = "");
  49.         var f = [];
  50.         m.find(".js-product-edition-option").each(function() {
  51.           var t = $(this),
  52.             o = t.find(".js-product-edition-option-name").text(),
  53.             r = t.find("option:selected").val(),
  54.             a = t.find("option:selected").attr("data-product-edition-variant-price");
  55.           if (a = tcart__cleanPrice(a), void 0 !== o && void 0 !== r) {
  56.             var i = {};
  57.             "" != o && (o = tcart__escapeHtml(o)), "" != r && (r = (r = tcart__escapeHtml(r)).replace(/(?:\r\n|\r|\n)/g, "")), 1 < o.length && ":" == o.charAt(o.length - 1) && (o = o.substring(0, o.length - 1)), i.option = o, i.variant = r, i.price = a, f.push(i)
  58.           }
  59.         }), m.find(".js-product-option").each(function() {
  60.           var t = $(this),
  61.             o = t.find(".js-product-option-name").text(),
  62.             r = t.find("option:selected").val(),
  63.             a = t.find("option:selected").attr("data-product-variant-price");
  64.           if (a = tcart__cleanPrice(a), void 0 !== o && void 0 !== r) {
  65.             var i = {};
  66.             "" != o && (o = tcart__escapeHtml(o)), "" != r && (r = (r = tcart__escapeHtml(r)).replace(/(?:\r\n|\r|\n)/g, "")), 1 < o.length && ":" == o.charAt(o.length - 1) && (o = o.substring(0, o.length - 1)), i.option = o, i.variant = r, i.price = a, f.push(i)
  67.           }
  68.         }), "" == d && void 0 === (d = m.find(".js-product-sku").text()) && (d = "")
  69.       }
  70.       if ("" != i || "" != a && 0 != a) {
  71.         "" == i && (i = "NoName"), "" == a && (a = 0), "" != i && (i = tcart__escapeHtml(i)), "" != c && (c = tcart__escapeHtmlImg(c));
  72.         var h = {};
  73.         if (h.name = i, h.price = a, h.img = c, h.recid = s, void 0 !== f && 0 < f.length && (h.options = f), void 0 !== d && "" != d && (d = tcart__escapeHtml(d), h.sku = d), void 0 !== e && "" != e && (h.uid = e), void 0 !== _ && 0 < _ && (h.inv = parseInt(_)), tcart__addProduct(h), void 0 !== window.tcart_sendevent_onadd && "y" == window.tcart_sendevent_onadd && window.Tilda && "function" == typeof Tilda.sendEventToStatistics) {
  74.           var b = "/tilda/cart/add/";
  75.           0 < s && (b += s), 0 < n && (b += "-" + n);
  76.           var g = i,
  77.             P = a,
  78.             x = "";
  79.           void 0 !== f && 0 < f.length && $.each(f, function(t, o) {
  80.             x += o.option + ": " + o.variant + "; "
  81.           });
  82.           var C = {
  83.             ecommerce: {
  84.               add: {
  85.                 products: [{
  86.                   recid: s,
  87.                   lid: n,
  88.                   sku: d,
  89.                   name: i,
  90.                   price: a,
  91.                   variant: x,
  92.                   quantity: 1
  93.                 }]
  94.               }
  95.             }
  96.           };
  97.           Tilda.sendEventToStatistics(b, g, C, P)
  98.         }
  99.       }
  100.     }
  101.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement