async function loadLoginModal(e){ if(e.preventDefault)e.preventDefault(); createModal(`

Login







Submit Cancel
`); } async function loadSignUpModal(e){ if(e.preventDefault)e.preventDefault(); createModal(`
Video Placeholder

Sign-Up













Submit Cancel
`); } async function postSignUpModal(e){ if(e.preventDefault)e.preventDefault(); let formData = new FormData(); formData.append("email",document.querySelector("#email").value); formData.append("password",document.querySelector("#password").value); formData.append("firstName",document.querySelector("#firstName").value); formData.append("lastName",document.querySelector("#lastName").value); let a = await fetch(`/sign-up/`, { method: 'POST', body: formData, }).then(response => response.json()); if(a.token){ document.cookie = `token=${a.token}`; window.location.href = '/dashboard/vehicle-profiles/#welcome'; } else { alert(a.msg); } } async function postLoginModal(e){ if(e.preventDefault)e.preventDefault(); document.cookie = `token=''`; let formData = new FormData(); formData.append("email",document.querySelector("#email").value); formData.append("password",document.querySelector("#password").value); let a = await fetch(`/login/`, { method: 'POST', body: formData, }).then(response => response.json()); if(a.token){ document.cookie = `token=${a.token}`; document.cookie = `email=${document.querySelector("#email").value}`; window.location.href = '/dashboard/vehicle-profiles/'; } else { alert(a.msg); } } async function logout(e){ if(e.preventDefault)e.preventDefault(); document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; document.cookie = "email=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; window.location = '/'; } async function createModal(html){ if(document.querySelector("#top-modal"))return false; let modal = document.createElement('div'); modal.id = "top-modal"; modal.innerHTML = html; modal.style.visibility = 'visible'; modal.style.position = 'fixed'; modal.style.width = '95%'; modal.style.minWidth = '200pt'; modal.style.maxWidth = '400pt'; modal.style.maxHeight = '90vh'; modal.style.top = '50%'; modal.style.left = '50%'; modal.style.transform = 'translate(-50%,-50%)'; modal.style.boxShadow = '3pt 3pt 3pt gray'; modal.style.border = '1pt solid gray'; modal.style.borderRadius = '3pt'; modal.style.padding = '3pt'; document.querySelector('body').appendChild(modal); document.querySelector('body').style.visibility = 'hidden'; } async function closeModal(e){ let n; if(!(n = document.querySelector("#top-modal")))return false; n.remove(); document.querySelector('body').style.visibility = 'visible'; }