Untitled

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

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


    /* Variation Init */
    function init() {
      var url = window.location.pathname;
      var lastSegment = url.split('/').filter(function (segment) {
        return segment.trim() !== '';
      }).pop();
      var variationText = lastSegment.replace(/-/g, ' ');
      var words = variationText.split(" ");
      for (var i = 0; i < words.length; i++) {
        words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
      }

      var finalText, finalctatext;
      if (window.location.href.match(/(employee-engagement|employee-survey|okrs|employee-goals)/)) {
        finalText = "Request an " + words.join(" ") + " Demo";
        finalctatext = "Book Your Free " + words.join(" ") + " Demo";
      } else if (window.location.href.match(/(performance-management|performance-reviews|compensation)/)) {
        finalText = "Request a " + words.join(" ") + " Demo";
        finalctatext = "Book Your Free " + words.join(" ") + " Demo";
      }
      document.querySelector('html body .card .card-title').innerText = finalText;
      document.querySelector('html body #marketo-form .mktoButtonRow [type="submit"]').innerText = finalctatext;
    }

    /* Initialize variation */
    if (window.location.href.indexOf('/employee-engagement') !== -1 || window.location.href.indexOf('/employee-survey') !== -1 || window.location.href.indexOf('/performance-management') !== -1 || window.location.href.indexOf('/performance-reviews') !== -1 || window.location.href.indexOf('/okrs') !== -1 || window.location.href.indexOf('/compensation') !== -1 || window.location.href.indexOf('/employee-goals') !== -1) {
      waitForElement('html body #marketo-form .mktoButtonRow [type="submit"]', init, 50, 15000);
    }
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();


Leave a Comment