Untitled

 avatar
unknown
plain_text
2 years ago
5.8 kB
6
Indexable
(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);
    };

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

    let egstring = `<section class="popup-wrapper eg-exitintent-popup"><div class="w-layout-blockcontainer container w-container"><div class="popup"><div><h3>Before you go...</h3><p class="body-medium">Take Lattice for a spin. See our People Management Platform in action in a 7-minute product overview video.</p></div><a href="/demo-hub-form" class="button is-lightbox w-inline-block"><div data-poster-url="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-poster-00001.jpg" data-video-urls="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-transcode.mp4,https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-transcode.webm" data-autoplay="true" data-loop="true" data-wf-ignore="true" class="lightbox-thumbnail w-background-video w-background-video-atom"><video id="faa98cfd-5ba0-01b2-1749-7cace200f8f1-video" autoplay="" loop="" style="background-image:url(&quot;https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-poster-00001.jpg&quot;)" muted="" playsinline="" data-wf-ignore="true" data-object-fit="cover"><source src="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-transcode.mp4" data-wf-ignore="true"><source src="https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-transcode.webm" data-wf-ignore="true"></video></div><p>Watch a demo</p></a><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><a href="#" class="popup-close">✕</a></div></div></section>`

    /* Variation Init */
    function init() {
        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);
          }
        });
    }

    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);
  }
})();


Editor is loading...
Leave a Comment