window.addEventListener('load', adjustBodyHeight); window.addEventListener('resize', adjustBodyHeight); function adjustBodyHeight() { const viewportHeight = window.innerHeight; const body = document.body; body.style.height = viewportHeight + 'px'; } window.addEventListener('DOMContentLoaded', function () { const form = document.getElementById('signup-form'); // const loginDisplay = document.getElementById('signin-display') // const mainForm = document.getElementById('main-form') // loginDisplay.style.height = mainForm.innerHeight + 'px' form.addEventListener('submit', function (event) { event.preventDefault(); const email = document.getElementById('floatingEmail').value; const username = document.getElementById('floatingUsername').value; const password1 = document.getElementById('floatingPassword1').value; const password2 = document.getElementById('floatingPassword2').value; if (password1 !== password2) { alert("Passwords didn't match!"); event.preventDefault(); } else { const formData = { email: email, password: password1, is_active: true, is_superuser: false, is_verified: false, username: username, id: 0 }; fetch('/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }) .then(function (response) { if (response.ok) { console.log('Form data submitted successfully'); window.location.href = 'http://' + window.location.host + '/user/login'; } else if (response.status === 400) { alert("A user with this email already exists"); event.preventDefault() } else if (response.status === 500) { alert("A user with this username already exists"); event.preventDefault() } else { console.error('Error submitting form data'); alert('Something was wrong...') event.preventDefault() } }) .catch(function (error) { console.error('Error submitting form data:', error); }); } }); })