Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
5.7 kB
1
Indexable
Never
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    function checkPopupCookie() {
      return getCookie("popupShown");
    }

    function waitForElement(selector, trigger, delayInterval, delayTimeout) {
      var interval = setInterval(function () {
        if (
          document &&
          document.querySelector(selector) &&
          document.querySelectorAll(selector).length > 0
        ) {
          clearInterval(interval);
          trigger();
        }
      }, delayInterval);
      setTimeout(function () {
        clearInterval(interval);
      }, delayTimeout);
    }

    function getCookie(name) {
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
      }
      return null;
    }

    function setCookie(name, value, days) {
      var expires = "";
      if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toUTCString();
      }
      document.cookie = name + "=" + (value || "") + expires + "; path=/";
    }

    function live(selector, event, callback, context) {
      function addEvent(el, type, handler) {
        if (el.attachEvent) el.attachEvent('on' + type, handler);
        else el.addEventListener(type, handler);
      }
      this.Element &&
        (function (ElementPrototype) {
          ElementPrototype.matches =
            ElementPrototype.matches ||
            ElementPrototype.matchesSelector ||
            ElementPrototype.webkitMatchesSelector ||
            ElementPrototype.msMatchesSelector ||
            function (selector) {
              var node = this,
                nodes = (node.parentNode || node.document).querySelectorAll(selector),
                i = -1;
              while (nodes[++i] && nodes[i] != node);
              return !!nodes[i];
            };
        })(Element.prototype);
      function live(selector, event, callback, context) {
        addEvent(context || document, event, function (e) {
          var found,
            el = e.target || e.srcElement;
          while (el && el.matches && el !== context && !(found = el.matches(selector))) el = el.parentElement;
          if (found) callback.call(el, e);
        });
      }
      live(selector, event, callback, context);
    };

    let egstring = `<section class="popup-wrapper eg-exitintent-popup"><div class="w-layout-blockcontainer container w-container"><div class="popup is-b"><div class="player-wrapper is-flat"><div class="player-content is-link"><img src="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba2b06106fa4f36f9a1b2e_thumbnail-video-callout.jpg" loading="lazy" sizes="(max-width: 767px) 88vw, (max-width: 991px) 60vw, 49vw" srcset="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba2b06106fa4f36f9a1b2e_thumbnail-video-callout-p-500.jpg 500w, https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba2b06106fa4f36f9a1b2e_thumbnail-video-callout-p-800.jpg 800w, https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba2b06106fa4f36f9a1b2e_thumbnail-video-callout.jpg 1200w" alt="" class="player-thumbnail is-link"></div><a href="/demo-hub-form" class="player-link w-inline-block"><div class="player-button"><div class="player-button-circle"><div class="player-button-circle-icon">︎</div></div><div><div>Watch demo</div><div class="body-xsmall">7:30 min</div></div></div></a></div><div class="popup-content"><h3>Before you go...</h3><p margin="medium" class="body-medium">Take Lattice for a spin. See our People Management Platform in action in a 7-minute product overview video.</p><div class="ratings"><div class="rating"><img src="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64b7d54429a9c0d18bf0a8a7_icon-g2.svg" loading="eager" alt="Icon for G2" class="rating-icon"><div><div class="rating-number">4.7<span class="rating-star">★</span></div><div>on G2</div></div></div><div class="rating-divider"></div><div class="rating"><img src="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64b7d544bb8d37bedad3b1e7_icon-capterra.svg" loading="eager" alt="Icon for Capterra" class="rating-icon"><div><div class="rating-number">4.5<span class="rating-star">★</span></div><div>on Capterra</div></div></div></div></div><a href="#" class="popup-close is-dark">✕</a></div></div></section>`

    /* Variation Init */
    function init() {
      if (!document.querySelector('.eg-exitintent-popup') && !getCookie('popupShown')) {
        document.body.insertAdjacentHTML("beforeend", egstring);
        document.body.classList.add("eg-popup-show")

        document.addEventListener("mouseleave", function (e) {
          if (!getCookie('popupShown')) {
            document.querySelector(".eg-exitintent-popup").classList.add("eg-show");
            setCookie("popupShown", "true", 100);
          }
        });

        live(".eg-popup-show>.eg-exitintent-popup .popup .popup-close", "click", function () {
          document.querySelector(".eg-exitintent-popup").classList.remove("eg-show")
        })
      }
    }

    if (window.location.href.includes("/performance-management") || window.location.href.includes("lp/products")) {
      waitForElement('html body', init, 50, 15000);
    }

  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();


Leave a Comment