var startInterval = setInterval(() => { if (typeof $ != "undefined") { if (mobileCheck() || (window.innerWidth < 800)) $("body").addClass("format-mobile"); else $("body").removeClass("format-mobile"); window.byapi = new BirdyApi(); clearInterval(startInterval); } else { console.log("Module not started - No jQuery found"); } }, 100); var socket; var auth_submitForm = function() { var email = $("#auth-input-email").val(); setCookie("email",email); var pass = $("#auth-input-pass").val(); byapi.login(email,pass).then(() => { var urlParams = new URLSearchParams(window.location.search); var redirect = urlParams.get('redirect'); if (redirect) window.location.href = redirect; else window.location.href = "/"; }).catch((err) => { $("#auth-error-div").html(err); $(".auth-error").show(); }); return false; } document.addEventListener("DOMContentLoaded", () => { $("#auth-input-email").val(getCookie("email")); $("#auth-manu").click(function(){ $("#auth-input-pass").val(""); $("#auth-box-qr").hide(); $("#auth-box-manu").show(); }); $("#auth-qr").click(function(){ $("#auth-input-pass").val(""); $("#auth-box-qr").show(); $("#auth-box-manu").hide(); }); $("#auth-app").click(function(){ window.open('https://play.google.com/store/apps/details?id=com.bw.litem2&hl=fr', '_blank'); }); $("#auth-new").click(function(){ window.open('https://www.birdywood.fr/connect/?page=new', '_blank'); }); socket = io({path: "/ws/" }); socket.on('connect', () => { socket.emit('tokenRequest'); }); socket.on('tokenRequest', (msg) => { $("#auth-img-qrcode").attr("src","https://api.birdywood.fr/api/qrcode/svg?q="+msg) }); socket.on('token', (msg) => { byapi.getUserMe(msg.token).then((user) => { setCookie("email",user.email); var urlParams = new URLSearchParams(window.location.search); window.location.href = urlParams.get('redirect'); }).catch((err) => { $("#auth-error-div").html(err); $(".auth-error").show(); }); }); });