(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 egArrow = `<svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="#000"><path d="M256 120.768L306.432 64 768 512l-461.568 448L256 903.232 659.072 512z" fill="#000"></path></svg>`;
let egCut = `<svg fill="#000000" height="200px" width="200px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 511.949 511.949" xml:space="preserve"><path d="M271.215,255.894l237.76-237.867c4.053-4.267,3.947-10.987-0.213-15.04c-4.16-3.947-10.667-3.947-14.827,0 l-237.867,237.76L18.308,2.988c-4.267-4.053-10.987-3.947-15.04,0.32c-3.947,4.16-3.947,10.667,0,14.827l237.76,237.76 L3.268,493.655c-4.267,4.053-4.373,10.88-0.213,15.04c4.16,4.16,10.88,4.373,15.04,0.213c0.107-0.107,0.213-0.213,0.213-0.213 l237.76-237.76l237.76,237.76c4.267,4.053,10.987,3.947,15.04-0.213c3.947-4.16,3.947-10.667,0-14.827L271.215,255.894z"></path></svg>`;
let egBanner = `
<div class="eg-banner">
<div class="eg-wrapper">
<!-- logo -->
<p class="eg-logo">Unrivalled workspace</p>
<!-- center text -->
<p class="eg-center">We’ve cut the cost of selected workspaces* for a limited time only.</p>
<div class="eg-box">
<!-- link -->
<a class="eg-link updated" href="https://www.regus.com/en-us/promotion/">Great Discounts. 25% off. Save Now! <span class="eg-arrow eg-icon">${egArrow}</span></a>
<!-- cut btn -->
<span class="eg-cut eg-icon">${egCut}</span>
</div>
<img src="https://assets.iwgplc.com/image/upload/c_fill,f_auto,q_auto,w_526,h_400,g_auto:subject/Sitecore/CD/-/media/regus/redesign/cards-stacked/homepage-feb-offer-2023.ashx?h=786&w=1021&hash=D963EE6AFC7B60580A7802954E2EBF44" class="eg-img">
</div>
</div>`;
let egInterval;
function live(selector, event, callback, context) {
/****Helper Functions****/
// helper for enabling IE 8 event bindings
function addEvent(el, type, handler) {
if (el.attachEvent) el.attachEvent("on" + type, handler);
else el.addEventListener(type, handler);
}
// matches polyfill
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);
// live binding helper using matchesSelector
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-cut', 'click', function() {
document.querySelector(".eg-banner") && document.querySelector(".eg-banner").remove();
setCookie("egRegusPromo",true,364);
});
live('.eg-img', 'click', function() {
document.querySelector(".eg-link") && document.querySelector(".eg-link").click();
});
/* Variation Init */
function init() {
egInterval = setInterval(() => {
if ((!document.querySelector(".eg-banner")) && (getCookie("egRegusPromo") === null)) {
document.querySelector("html body #root >div:nth-child(1) >div.main-navigation").insertAdjacentHTML("beforeend", egBanner);
} else {
clearInterval(egInterval);
}
}, 1500);
}
var getCookie = function(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;
};
var setCookie = function(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=/';
};
/* Initialize variation */
waitForElement('html body #root >div:nth-child(1) >div.main-navigation', init, 50, 15000);
} catch (e) {
if (debug) console.log(e, "error in Test" + variation_name);
}
})();