(function () { /* Clipboard JS */ const clipboard = new ClipboardJS("#js-email-copy"); const instance = tippy(document.querySelector("#js-email-copy"), { content: "Copied!", trigger: "manual", }); clipboard.on("success", function (e) { instance.show(); }); /* Typed JS */ const options = { strings: ["domain setup", "email content", "DNS config", "SMTP server"], typeSpeed: 60, loop: true, smartBackspace: true, backSpeed: 30, startDelay: 30, fadeOut: true, fadeOutDelay: 200, backDelay: 1000, }; const typed = new Typed("#js-typed", options); /* Modal and process */ // Toggle waiting modal visibility function toggleWaitingModal() { const modal = document.querySelector("#js-waiting-modal"); modal.classList.toggle("hidden"); } // Toggle processing loader visibility function toggleProcessingLoader() { const modalp = document.querySelector("#processing-email"); modalp.classList.toggle("hidden"); } // Toggle "cancel waiting" button visibility function toggleWaitingButton() { const modalb = document.querySelector("#js-waiting-close"); modalb.classList.toggle("hidden"); } // Toggle waiting gif visibility function toggleWaitingLoader() { const modalw = document.querySelector("#waiting-email"); modalw.classList.toggle("hidden"); } // Run the analysis btn document.querySelector("#js-start-btn").addEventListener("click", startAnalysis); // Cancel btn Waiting modal document.querySelector("#js-waiting-close").addEventListener("click", cancelAnalysis); // When user cancel analysis function cancelAnalysis(e) { e.preventDefault(); // Close waiting modal toggleWaitingModal(); // Stop ajax call here clearInterval(window.refreshIntervalId); window.location.href = "#check-section"; } // Waiting for email reception function waitingEmail() { $.get("waiting_email.php", function (data) { if (data == "received") { clearInterval(window.refreshIntervalId); toggleWaitingLoader(); toggleWaitingButton(); toggleProcessingLoader(); window.processingts = 42; window.updateLoader("#js-loader", 0); waitingProcessing(); window.refreshProcessingIntervalId = setInterval(function () { waitingProcessing(); }, 1000); $.get("processing.php", function (data) { if (data == "recaptcha_issue") { window.location.href = "/#check-section"; window.location.reload(true); } else { window.location.href = "results-" + data; } }); } else if (data == "stopretry") { clearInterval(window.refreshIntervalId); window.location.href = "/#check-section"; window.location.reload(true); } }); } // Waiting for email processing function waitingProcessing() { if (window.processingts == 42) { window.processingts = Math.round(new Date().getTime() / 1000); } time_elapsed = Math.round(new Date().getTime() / 1000) - window.processingts; processingRate = Math.round((time_elapsed / 80) * 1000) / 10; window.updateLoader("#js-loader", processingRate); } // When user start analysis function startAnalysis(e) { e.preventDefault(); // Open waiting modal toggleWaitingModal(); waitingEmail(); window.refreshIntervalId = setInterval(function () { waitingEmail(); }, 1000); } })();