// AI Chat Demo — Optin Page // Watches for form submission, shows progress, loads checker iframe, // and redirects to demo page when contact data is ready. let optinForm, optinBtn, wait4Thanks, thanksDiv, refreshTimer; const ifrSrc = `${window.location.origin}/demo-optin-checker`; const demoUrl = `${window.location.origin}/${nextDemoStep}`; const frameLoadWait = 1000; let progressPct = 5; function createCheckFrame() { clearInterval(wait4Thanks); wait4Thanks = setInterval(() => { thanksDiv = optinForm.querySelector("#_builder-form .thank-you-message"); if (thanksDiv) { clearInterval(wait4Thanks); $(".demo-optin").hide(); $(".post-submit").fadeIn(); const checkerDiv = document.getElementById("user-checker-container"); const iframe = document.createElement("iframe"); iframe.setAttribute("class", "user-checker-frame"); iframe.id = "user-checker-frame"; iframe.src = `${ifrSrc}?t=${new Date().getTime()}`; animateProgress(); setTimeout(() => { checkerDiv.appendChild(iframe); }, frameLoadWait); } }); } function animateProgress() { const el = document.querySelector(".progress-inner"); if (!el) return; el.className = el.className.replace(/progress\d+/g, "").trim(); el.removeAttribute("style"); let t = 0; el.style.width = "0%"; const timer = setInterval(() => { t += progressPct; el.style.width = `${t}%`; if (t > 100) { clearInterval(timer); el.style.width = "0%"; animateProgress(); } }, 1000); } localStorage.clear(); document.addEventListener("hydrationDone", () => { setTimeout(() => { const jq = document.createElement("script"); jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"; jq.type = "text/javascript"; document.head.appendChild(jq); window.addEventListener("message", (e) => { const msg = e.data; if (msg && msg.type === "userData") { clearTimeout(refreshTimer); document.getElementById("user-checker-container").remove(); const params = new URLSearchParams({ first_name: msg.fName, email: msg.email, url: msg.url, company: msg.company }); window.location.href = `${demoUrl}?${params.toString()}`; } }); const wait4Button = setInterval(() => { optinBtn = document.querySelector('.demo-optin button[type="submit"]'); if (optinBtn) { clearInterval(wait4Button); optinForm = document.querySelector(".demo-optin"); optinBtn.addEventListener("click", createCheckFrame); const siteInput = document.querySelector('.demo-optin input[name="website"]'); siteInput.addEventListener("input", function () { if (this.value.includes(" ")) { this.value = this.value.replace(/\s/g, ""); this.dispatchEvent(new Event("input")); } }); } }); }, 250); });

Woot! Buckle Up...

We're Building Your Demo Right Now.

It Only Takes a Few Seconds...

Building Demo...

Turn your business into a 24/7 profit-generating machine with AI employees that qualify leads, schedule appointments, manage customer service and more!