app.getCookie("azer_token", function (e, r) { if (e) { app.redirectUrl(`../dashio/home?azer_token=${r}`); } }); /* //====================LOGIN VERIFICATION============= */ const loginForm = document.querySelector(".login-form"); const loginBtn = document.getElementById("login-btn"); const loginEmail = document.getElementById("email"); const loginPass = document.getElementById("password"); const myContStyle = document.querySelector(".myCont-style"); const containerFluid = document.querySelector(".card"); /* =====Password show====== */ const loginPassCheck = document.getElementById("pass-check"); const signupBtn = document.getElementById(".check2 button"); loginPassCheck.addEventListener("click", () => { if (loginPassCheck.checked) { loginPass.type = "text"; } else { loginPass.type = "password"; } }); /* =====Button click====== */ loginBtn.addEventListener("click", (e) => { e.preventDefault(); if (loginEmail.value && loginPass.value) { myContStyle.classList.add("active"); // loginForm.reset(); // loginPass.value = ""; // loginEmail.value = ""; } else if (!loginTermsCheck.checked) { document.querySelector(".field-check label").classList.add("active"); } myContStyle.addEventListener("click", (e) => { var isClickInsideElement = containerFluid.contains(e.target); if (!isClickInsideElement) { myContStyle.classList.remove("active"); } }); }); var captcha = sliderCaptcha({ id: "captcha", setSrc: function () { return "../public/images/Pic" + Math.round(Math.random() * 14) + ".jpg"; }, // captcha.reset(); onSuccess: function () { swal({ title: "Loading", html: "Please wait...", // type: 'success', padding: "2em", onOpen: function () { swal.showLoading(); }, }); var handler = setTimeout(function () { window.clearTimeout(handler); app.client.fetch("../auth/login", "POST", forms()).then(function (d) { console.log(d); if (!d.isSuccess) { sweetAlertE(d.icon, d.message, d.title); captcha.reset(); } else { sweetAlertS(d.icon, d.message, d.title, d.redirectUrl); captcha.reset(); } }); }, 500); }, }); // swal({ // title: 'Loading', // html: 'Loading..', // type: 'success', // padding: '2em', // onOpen: function () { // swal.showLoading() // } // }) function forms() { let formdata = { email: app.query("#email").value, password: app.query("#password").value, }; return formdata; } function sweetAlertE(icon, msg, title) { swal({ title: title, html: msg, type: icon, timer: 3500, padding: "2em", onOpen: function () { swal.showLoading(); }, }).then(function (result) { if (result.dismiss === swal.DismissReason.timer) { myContStyle.classList.remove("active"); captcha.reset(); } }); } function sweetAlertS(icon, msg, title, url) { swal({ title: title, html: msg, type: icon, timer: 1000, padding: "2em", onOpen: function () { swal.showLoading(); }, }).then(function (result) { if (result.dismiss === swal.DismissReason.timer) { myContStyle.classList.remove("active"); captcha.reset(); window.location = url; } }); }