Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.1 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);
    }


    let searchCTA = `<div class="eg-search">
     <button>Search</button>
    </div>`;

    let hero = `<div class="eg-hero-container">
    <h3>Find your flexible and inspiring <br> workspace</h3>
    <p>Join a thriving community of professionals and get to work in offices, <br>
    coworking spaces and meeting rooms in over <strong>493 locations around the globe.</strong></p>
</div>`;

    /* Variation Init */
    function init() {
      /* start your code here */
      if (!document.querySelector(".eg-heading")) {
        setTimeout(() => {
          document.querySelector(".slider-large .c-location-finder-section__title").insertAdjacentHTML("beforebegin", `<div class="eg-heading">Find your ideal workspace</div>`);
        }, 200);
      }
    
        setTimeout(() => {
            if (!document.querySelector(".eg-heading")) {
          document.querySelector(".slider-large .c-location-finder-section__title").insertAdjacentHTML("beforebegin", `<div class="eg-heading">Find your ideal workspace</div>`);
            }
            }, 1000);
      
      if (!document.querySelector(".eg-location")) {
        waitForElement(".c-location-finder-section__content", function () {
          document.querySelector(".c-location-finder-section__content").insertAdjacentHTML("afterend", `<div class="eg-location">Search for your location</div>`);
        }, 500, 25000);
      }

      if (!document.querySelector(".eg-search")) {
        waitForElement(".c-location-finder-section__input input", function () {
          document.querySelector(".c-location-finder-section__input input").insertAdjacentHTML("afterend", searchCTA)
        }, 500, 25000);
      }

     
        waitForElement(".page.page--front-page > div:first-child .container-fluid", function () {
           if (!document.querySelector("eg-hero-container")) {
          document.querySelector(".page.page--front-page > div:first-child .container-fluid").insertAdjacentHTML("afterbegin", hero);
           }
           setTimeout(() => {
             if (!document.querySelector("eg-hero-container")) {
          document.querySelector(".page.page--front-page > div:first-child .container-fluid").insertAdjacentHTML("afterbegin", hero);
           }
           },1000);
        }, 500, 10000);
  
    }

    /* Initialize variation */
    waitForElement('.slider-large .c-location-finder-section__title', init, 500, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();