Untitled
unknown
plain_text
2 years ago
13 kB
9
Indexable
(function () {
try {
/* main variables */
var debug = 0;
var variation_name = "";
var $;
/* all Pure helper functions */
function checkPopupCookie() {
return getCookie("popupShown");
}
function waitforMarketo(trigger) {
var interval = setInterval(function () {
if (
window.MktoForms2
) {
clearInterval(interval);
trigger();
}
}, 700);
setTimeout(function () {
clearInterval(interval);
}, 15000);
}
function waitForjQuery(trigger) {
var interval = setInterval(function () {
if (window.jQuery != undefined) {
clearInterval(interval);
trigger();
} else {
addJQuery();
}
}, 50);
setTimeout(function () {
clearInterval(interval);
}, 15000)
}
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")
})
live('[data-watch-quick-demo-cta]', 'click', function () {
document.body.classList.add('eg-show-popup');
waitForElement('.eg-step-submit-form #Email', function () {
$('.eg-step-submit-form #Email').focus();
}, 50, 15000);
});
let egstring = `<section class="popup-wrapper eg-exitintent-popup"><div class="w-layout-blockcontainer container w-container"><div class="eg-container_new"><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("https://assets-global.website-files.com/64ad6f1aef87635bd23449f1/64ba4375418a540ade839f98_video-lightbox-demo-poster-00001.jpg")" 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 class="eg-form-section"></div></div></div></section>`
/* Variation Init */
function init() {
waitForjQuery(function () {
$ = window.jQuery;
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);
}
});
waitforMarketo(function () {
loadFrm("372-AAD-485", 3115, `html body [data-form-popup] .eg-form-section .form-card`);
window.MktoForms2.whenReady(function (form) {
$('#FirstName').focus();
var freemailDomains = ["yahoo.com", "hotmail.com", "live.com", "aol.com", "msn.com", "outlook.com", "gmail.com", "cloudmdrive.my.id", "driveplus.my.id", "meniti.my.id"],
errorFreemail = "Must be business email.";
/\ *no need to touch below this line* /
var formEl = form.getFormElem()[0],
emailEl = formEl.querySelector("input[name='Email']"),
emailJq = MktoForms2.$(emailEl);
form.onValidate(function (native) {
if (!native) return;
var currentValues = form.getValues(),
currentEmail = currentValues.Email;
if (inDomainList(currentEmail, freemailDomains)) {
form.submittable(false);
form.showErrorMessage(errorFreemail, emailJq);
} else {
form.submittable(true);
}
});
form.onSuccess(function (values, followUpUrl) {
const frmId = values.formid;
let redt;
if (frmId === "3115") {
redt = "http://lattice.com/demo-hub";
}
if (redt) {
window.location.href = redt;
}
});
window.scrollTo(0, 0);
});
});
});
}
function loadFrm(egMID, egFrmId, targetSel) {
let egTarget;
egTarget = document.querySelector('.eg-exitintent-popup>.container .eg-container_new > .eg-form-section');
let mkform = `<form class="eg-step-submit-form" id="mktoForm_${egFrmId}"></form>`;
console.log(mkform)
if (!egTarget.querySelector(".eg-step-submit-form")) {
egTarget.insertAdjacentHTML("afterbegin", mkform);
reloadForm(egMID, egFrmId);
} else {
const frmEl = egTarget.querySelector('.eg-step-submit-form:empty');
if (frmEl) {
reloadForm(egMID, egFrmId);
}
}
}
const reloadForm = (egMID, egFrmId) => {
MktoForms2.loadForm("//people.lattice.com", egMID, egFrmId, function (form) {
console.log('form loaded', egFrmId);
waitForElement('[id^="LblContent_Demo_Request_LD"]', function () {
document.querySelector('[id^="LblContent_Demo_Request_LD"]').closest('.mktoFormRow').classList.add('eg-separator-mkto_row');
document.querySelector('[id^="LblContent_Demo_Request_LD"]').parentElement.classList.add('eg-separator-mkto');
document.querySelector('.eg-step-submit-form button[type="submit"]').style.cssText = "font-family: Matter,sans-serif !important;";
document.querySelector('.eg-step-submit-form button[type="submit"]').innerText = "Watch now";
document.querySelector('.eg-step-submit-form button[type="submit"]').classList.remove('mktoButton');
document.querySelector('.eg-step-submit-form button[type="submit"]').classList.add('button');
const firstFormEls = [
document.querySelector('html body .eg-step-submit-form [id="LblEmail"]'),
document.querySelector('html body .eg-step-submit-form [id^="LblCompany_Size"]'),
document.querySelector('html body .eg-step-submit-form [id="LblCountry"]')
];
firstFormEls.forEach(firstFormEl => {
if (firstFormEl) {
firstFormEl.closest('.mktoFormRow').classList.add('eg-stage-1formrowsfilled');
}
});
if (!document.querySelector('.eg-stage-1submit-cta_mkto')) {
document.querySelector('.eg-step-submit-form button[type="submit"]').insertAdjacentHTML('afterend', `<button type="button" class="eg-stage-1submit-cta_mkto mktoButton" style="font-family: Matter, sans-serif !important;">Watch Quick Demo</button>`);
document.querySelector('.eg-stage-1submit-cta_mkto').addEventListener('click', function () {
const isValid = form.validate();
console.log("Form is valid: ", isValid);
if (isValid) {
// document.querySelector('html body .eg-popup_modal-container').setAttribute('data-show-entered', true);
const nxtFrmlbl = document.querySelector('html body .eg-separator-mkto>label#LblContent_Demo_Request_LD_Special_Route__c.mktoLabel');
if (nxtFrmlbl) {
const nxtFrmCheck = document.querySelector('html body .eg-separator-mkto>label#LblContent_Demo_Request_LD_Special_Route__c.mktoLabel ~ div input');
if (nxtFrmCheck && !nxtFrmCheck.checked) {
// nxtFrmlbl.click();
document.querySelector('.eg-step-submit-form button[type="submit"]').click();
}
}
}
});
}
if (!document.querySelector('.eg-marketo-captcha')) {
const html = `<div class="smallprints eg-marketo-captcha">This site is protected by reCAPTCHA and the <a href="https://policies.google.com/privacy" target="_blank" class="hyperlink" rel="noreferrer noopener">Google Privacy Policy</a> and <a href="https://policies.google.com/terms" target="_blank" class="hyperlink" rel="noreferrer noopener">Terms of Service</a> apply. By submitting your information, you agree to Lattice's <a href="https://lattice.com/privacy/terms-of-service" class="hyperlink">Terms of Service</a> and <a href="https://lattice.com/privacy/policy" class="hyperlink">Privacy Policy</a>. You can opt out anytime.</div>`;
document.querySelector('.eg-step-submit-form button[type="submit"]').insertAdjacentHTML('afterend', html);
}
}, 50, 15000);
// prevent redirection from happening of outer form
form.onSuccess(function (values, followUpUrl) {
// return false;
});
});
}
function inDomainList(email, domains) {
return domains
.map(function (domain) {
return new RegExp('@' + domain.replace('.', '\.') + '$', 'i');
})
.some(function (reDomain) {
return reDomain.test(email);
});
}
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