Update static/login.html
Browse files- static/login.html +294 -71
static/login.html
CHANGED
|
@@ -5,73 +5,290 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Login / Signup</title>
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
</style>
|
| 32 |
</head>
|
| 33 |
<body>
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
<
|
| 37 |
-
<
|
| 38 |
-
<
|
| 39 |
-
<
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
</div>
|
| 50 |
|
| 51 |
<script>
|
| 52 |
-
// --- FIX: Wait for the page to load before trying to find elements ---
|
| 53 |
document.addEventListener('DOMContentLoaded', () => {
|
| 54 |
-
console.log("DOM fully loaded and parsed. Initializing script.");
|
| 55 |
-
|
| 56 |
const API_BASE_URL = '';
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
const loginForm = document.getElementById('loginForm');
|
|
|
|
|
|
|
|
|
|
| 59 |
const signupBtn = document.getElementById('signupBtn');
|
| 60 |
-
const
|
|
|
|
|
|
|
| 61 |
const messageEl = document.getElementById('message');
|
| 62 |
|
| 63 |
-
//
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
// --- LOGIN LOGIC ---
|
| 70 |
loginForm.addEventListener('submit', async (e) => {
|
| 71 |
e.preventDefault();
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
loginBtn.
|
| 75 |
|
| 76 |
const formData = new FormData();
|
| 77 |
formData.append('username', e.target.username.value);
|
|
@@ -82,44 +299,41 @@
|
|
| 82 |
method: 'POST',
|
| 83 |
body: formData
|
| 84 |
});
|
| 85 |
-
|
| 86 |
const data = await response.json();
|
| 87 |
|
| 88 |
if (response.ok) {
|
| 89 |
const token = data.access_token;
|
| 90 |
localStorage.setItem('accessToken', token);
|
| 91 |
-
|
| 92 |
if (window.parent) {
|
| 93 |
window.parent.postMessage({ accessToken: token }, '*');
|
| 94 |
}
|
| 95 |
-
|
| 96 |
-
messageEl.style.color = 'green';
|
| 97 |
-
messageEl.textContent = 'Login Successful! You can return to the settings page.';
|
| 98 |
} else {
|
| 99 |
-
|
| 100 |
-
messageEl.textContent = data.detail || 'Login failed.';
|
| 101 |
}
|
| 102 |
} catch (error) {
|
| 103 |
console.error('Login fetch error:', error);
|
| 104 |
-
|
| 105 |
-
messageEl.textContent = 'An error occurred. Please try again.';
|
| 106 |
} finally {
|
| 107 |
loginBtn.disabled = false;
|
|
|
|
| 108 |
}
|
| 109 |
});
|
| 110 |
|
| 111 |
// --- SIGNUP LOGIC ---
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 114 |
signupBtn.disabled = true;
|
|
|
|
| 115 |
|
| 116 |
-
const username =
|
| 117 |
-
const password =
|
| 118 |
|
| 119 |
if (!username || !password) {
|
| 120 |
-
|
| 121 |
-
messageEl.textContent = 'Please enter a username and password to sign up.';
|
| 122 |
signupBtn.disabled = false;
|
|
|
|
| 123 |
return;
|
| 124 |
}
|
| 125 |
|
|
@@ -131,21 +345,30 @@
|
|
| 131 |
});
|
| 132 |
|
| 133 |
if (response.status === 201) {
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
} else {
|
| 137 |
const errorData = await response.json();
|
| 138 |
-
|
| 139 |
-
messageEl.textContent = errorData.detail || 'Signup failed.';
|
| 140 |
}
|
| 141 |
} catch (error) {
|
| 142 |
console.error('Signup error:', error);
|
| 143 |
-
|
| 144 |
-
messageEl.textContent = 'An error occurred. Please try again.';
|
| 145 |
} finally {
|
| 146 |
signupBtn.disabled = false;
|
|
|
|
| 147 |
}
|
| 148 |
});
|
|
|
|
|
|
|
|
|
|
| 149 |
});
|
| 150 |
</script>
|
| 151 |
</body>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>Login / Signup</title>
|
| 7 |
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--accent-color: #FF9500;
|
| 10 |
+
--background-dark: #121212;
|
| 11 |
+
--form-bg-color: rgba(30, 30, 30, 0.65);
|
| 12 |
+
--input-bg-color: rgba(50, 50, 50, 0.7);
|
| 13 |
+
--text-primary: #FFFFFF;
|
| 14 |
+
--text-secondary: #AAAAAA;
|
| 15 |
+
--border-color: rgba(255, 255, 255, 0.1);
|
| 16 |
+
--error-color: #FF4747;
|
| 17 |
+
--success-color: #34C759;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
* {
|
| 21 |
+
margin: 0;
|
| 22 |
+
padding: 0;
|
| 23 |
+
box-sizing: border-box;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
body {
|
| 27 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
| 28 |
+
display: flex;
|
| 29 |
+
justify-content: center;
|
| 30 |
+
align-items: center;
|
| 31 |
+
min-height: 100vh;
|
| 32 |
+
background: var(--background-dark);
|
| 33 |
+
/* Adding a subtle gradient for a more dynamic background */
|
| 34 |
+
background-image: radial-gradient(circle at 10% 20%, rgba(255, 149, 0, 0.15), transparent 50%),
|
| 35 |
+
radial-gradient(circle at 80% 90%, rgba(255, 149, 0, 0.1), transparent 40%);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.form-container {
|
| 39 |
+
width: 100%;
|
| 40 |
+
max-width: 400px;
|
| 41 |
+
margin: 20px;
|
| 42 |
+
background: var(--form-bg-color);
|
| 43 |
+
border-radius: 20px;
|
| 44 |
+
border: 1px solid var(--border-color);
|
| 45 |
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
|
| 46 |
+
backdrop-filter: blur(15px);
|
| 47 |
+
-webkit-backdrop-filter: blur(15px);
|
| 48 |
+
overflow: hidden;
|
| 49 |
+
transition: height 0.4s ease-in-out;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.form-flipper {
|
| 53 |
+
position: relative;
|
| 54 |
+
width: 100%;
|
| 55 |
+
transition: transform 0.6s ease-in-out;
|
| 56 |
+
transform-style: preserve-3d;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.form-wrapper {
|
| 60 |
+
width: 100%;
|
| 61 |
+
padding: 2.5rem;
|
| 62 |
+
backface-visibility: hidden;
|
| 63 |
+
-webkit-backface-visibility: hidden; /* for Safari */
|
| 64 |
+
transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
#loginFormWrapper {
|
| 68 |
+
/* Starts visible */
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
#signupFormWrapper {
|
| 72 |
+
position: absolute;
|
| 73 |
+
top: 0;
|
| 74 |
+
left: 0;
|
| 75 |
+
opacity: 0;
|
| 76 |
+
transform: translateY(20px);
|
| 77 |
+
pointer-events: none; /* Inactive form should not be interactive */
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
/* State classes for switching */
|
| 81 |
+
.form-container.show-signup #loginFormWrapper {
|
| 82 |
+
opacity: 0;
|
| 83 |
+
transform: translateY(-20px);
|
| 84 |
+
pointer-events: none;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.form-container.show-signup #signupFormWrapper {
|
| 88 |
+
opacity: 1;
|
| 89 |
+
transform: translateY(0);
|
| 90 |
+
pointer-events: all;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
h2 {
|
| 95 |
+
text-align: center;
|
| 96 |
+
color: var(--text-primary);
|
| 97 |
+
font-size: 2rem;
|
| 98 |
+
margin-bottom: 0.5rem;
|
| 99 |
+
font-weight: 600;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.form-subtitle {
|
| 103 |
+
text-align: center;
|
| 104 |
+
color: var(--accent-color);
|
| 105 |
+
margin-bottom: 2rem;
|
| 106 |
+
font-weight: 500;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.form-group {
|
| 110 |
+
margin-bottom: 1.5rem;
|
| 111 |
+
position: relative;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
label {
|
| 115 |
+
display: block;
|
| 116 |
+
margin-bottom: .5rem;
|
| 117 |
+
color: var(--text-secondary);
|
| 118 |
+
font-size: 0.9rem;
|
| 119 |
+
font-weight: 500;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
input {
|
| 123 |
+
width: 100%;
|
| 124 |
+
padding: 0.85rem 1rem;
|
| 125 |
+
box-sizing: border-box;
|
| 126 |
+
border: 1px solid transparent;
|
| 127 |
+
border-radius: 10px;
|
| 128 |
+
background-color: var(--input-bg-color);
|
| 129 |
+
color: var(--text-primary);
|
| 130 |
+
font-size: 1rem;
|
| 131 |
+
transition: border-color 0.3s, box-shadow 0.3s;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
input:focus {
|
| 135 |
+
outline: none;
|
| 136 |
+
border-color: var(--accent-color);
|
| 137 |
+
box-shadow: 0 0 0 3px rgba(255, 149, 0, 0.3);
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
button {
|
| 141 |
+
width: 100%;
|
| 142 |
+
padding: 0.9rem;
|
| 143 |
+
border: none;
|
| 144 |
+
border-radius: 10px;
|
| 145 |
+
color: var(--text-primary);
|
| 146 |
+
background-color: var(--accent-color);
|
| 147 |
+
cursor: pointer;
|
| 148 |
+
font-size: 1.1rem;
|
| 149 |
+
font-weight: 600;
|
| 150 |
+
transition: transform 0.2s, background-color 0.2s;
|
| 151 |
+
margin-top: 1rem;
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
button:hover {
|
| 155 |
+
transform: translateY(-2px);
|
| 156 |
+
background-color: #ffae42; /* A slightly lighter shade for hover */
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
button:disabled {
|
| 160 |
+
opacity: 0.5;
|
| 161 |
+
cursor: not-allowed;
|
| 162 |
+
transform: translateY(0);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.switch-form-btn {
|
| 166 |
+
background: none;
|
| 167 |
+
border: none;
|
| 168 |
+
color: var(--accent-color);
|
| 169 |
+
cursor: pointer;
|
| 170 |
+
font-size: 0.9rem;
|
| 171 |
+
font-weight: 500;
|
| 172 |
+
padding: 0;
|
| 173 |
+
margin-top: 1.5rem;
|
| 174 |
+
text-align: center;
|
| 175 |
+
width: 100%;
|
| 176 |
+
display: block;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
.switch-form-btn:hover {
|
| 180 |
+
text-decoration: underline;
|
| 181 |
+
transform: none; /* Override button hover */
|
| 182 |
+
background: none;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
#message {
|
| 186 |
+
margin-top: 1rem;
|
| 187 |
+
text-align: center;
|
| 188 |
+
font-weight: 500;
|
| 189 |
+
font-size: 0.9rem;
|
| 190 |
+
height: 20px; /* Reserve space to prevent layout shift */
|
| 191 |
+
transition: color 0.3s;
|
| 192 |
+
}
|
| 193 |
</style>
|
| 194 |
</head>
|
| 195 |
<body>
|
| 196 |
+
|
| 197 |
+
<div class="form-container" id="formContainer">
|
| 198 |
+
<div id="loginFormWrapper" class="form-wrapper">
|
| 199 |
+
<form id="loginForm">
|
| 200 |
+
<h2>Animex</h2>
|
| 201 |
+
<p class="form-subtitle">Welcome Back!</p>
|
| 202 |
+
<div class="form-group">
|
| 203 |
+
<label for="login-username">Username</label>
|
| 204 |
+
<input type="text" id="login-username" name="username" required autocomplete="username">
|
| 205 |
+
</div>
|
| 206 |
+
<div class="form-group">
|
| 207 |
+
<label for="login-password">Password</label>
|
| 208 |
+
<input type="password" id="login-password" name="password" required autocomplete="current-password">
|
| 209 |
+
</div>
|
| 210 |
+
<button type="submit" id="loginBtn">Login</button>
|
| 211 |
+
</form>
|
| 212 |
+
<button class="switch-form-btn" id="showSignup">Don't have an account? Sign Up</button>
|
| 213 |
+
</div>
|
| 214 |
+
|
| 215 |
+
<div id="signupFormWrapper" class="form-wrapper">
|
| 216 |
+
<form id="signupForm">
|
| 217 |
+
<h2>Animex</h2>
|
| 218 |
+
<p class="form-subtitle">Get started with a new account</p>
|
| 219 |
+
<div class="form-group">
|
| 220 |
+
<label for="signup-username">Username</label>
|
| 221 |
+
<input type="text" id="signup-username" name="username" required autocomplete="username">
|
| 222 |
+
</div>
|
| 223 |
+
<div class="form-group">
|
| 224 |
+
<label for="signup-password">Password</label>
|
| 225 |
+
<input type="password" id="signup-password" name="password" required autocomplete="new-password">
|
| 226 |
+
</div>
|
| 227 |
+
<button type="submit" id="signupBtn">Sign Up</button>
|
| 228 |
+
</form>
|
| 229 |
+
<button class="switch-form-btn" id="showLogin">Already have an account? Login</button>
|
| 230 |
+
</div>
|
| 231 |
+
<p id="message"></p>
|
| 232 |
</div>
|
| 233 |
|
| 234 |
<script>
|
|
|
|
| 235 |
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
|
|
| 236 |
const API_BASE_URL = '';
|
| 237 |
|
| 238 |
+
const formContainer = document.getElementById('formContainer');
|
| 239 |
+
const loginFormWrapper = document.getElementById('loginFormWrapper');
|
| 240 |
+
const signupFormWrapper = document.getElementById('signupFormWrapper');
|
| 241 |
const loginForm = document.getElementById('loginForm');
|
| 242 |
+
const signupForm = document.getElementById('signupForm');
|
| 243 |
+
|
| 244 |
+
const loginBtn = document.getElementById('loginBtn');
|
| 245 |
const signupBtn = document.getElementById('signupBtn');
|
| 246 |
+
const showSignupBtn = document.getElementById('showSignup');
|
| 247 |
+
const showLoginBtn = document.getElementById('showLogin');
|
| 248 |
+
|
| 249 |
const messageEl = document.getElementById('message');
|
| 250 |
|
| 251 |
+
// Function to adjust container height based on content
|
| 252 |
+
const adjustContainerHeight = () => {
|
| 253 |
+
// Use a timeout to allow CSS transitions to start
|
| 254 |
+
setTimeout(() => {
|
| 255 |
+
const activeFormWrapper = formContainer.classList.contains('show-signup')
|
| 256 |
+
? signupFormWrapper
|
| 257 |
+
: loginFormWrapper;
|
| 258 |
+
formContainer.style.height = `${activeFormWrapper.scrollHeight + 70}px`;
|
| 259 |
+
}, 100);
|
| 260 |
+
};
|
| 261 |
+
|
| 262 |
+
// Initial height adjustment
|
| 263 |
+
adjustContainerHeight();
|
| 264 |
+
|
| 265 |
+
// --- UI SWITCHING LOGIC ---
|
| 266 |
+
showSignupBtn.addEventListener('click', (e) => {
|
| 267 |
+
e.preventDefault();
|
| 268 |
+
formContainer.classList.add('show-signup');
|
| 269 |
+
messageEl.textContent = ''; // Clear message on switch
|
| 270 |
+
adjustContainerHeight();
|
| 271 |
+
});
|
| 272 |
+
|
| 273 |
+
showLoginBtn.addEventListener('click', (e) => {
|
| 274 |
+
e.preventDefault();
|
| 275 |
+
formContainer.classList.remove('show-signup');
|
| 276 |
+
messageEl.textContent = ''; // Clear message on switch
|
| 277 |
+
adjustContainerHeight();
|
| 278 |
+
});
|
| 279 |
+
|
| 280 |
+
// --- API LOGIC ---
|
| 281 |
+
const showMessage = (message, isError = true) => {
|
| 282 |
+
messageEl.textContent = message;
|
| 283 |
+
messageEl.style.color = isError ? 'var(--error-color)' : 'var(--success-color)';
|
| 284 |
+
}
|
| 285 |
|
| 286 |
// --- LOGIN LOGIC ---
|
| 287 |
loginForm.addEventListener('submit', async (e) => {
|
| 288 |
e.preventDefault();
|
| 289 |
+
showMessage('');
|
| 290 |
+
loginBtn.disabled = true;
|
| 291 |
+
loginBtn.textContent = 'Logging in...';
|
| 292 |
|
| 293 |
const formData = new FormData();
|
| 294 |
formData.append('username', e.target.username.value);
|
|
|
|
| 299 |
method: 'POST',
|
| 300 |
body: formData
|
| 301 |
});
|
|
|
|
| 302 |
const data = await response.json();
|
| 303 |
|
| 304 |
if (response.ok) {
|
| 305 |
const token = data.access_token;
|
| 306 |
localStorage.setItem('accessToken', token);
|
|
|
|
| 307 |
if (window.parent) {
|
| 308 |
window.parent.postMessage({ accessToken: token }, '*');
|
| 309 |
}
|
| 310 |
+
showMessage('Login Successful!', false);
|
|
|
|
|
|
|
| 311 |
} else {
|
| 312 |
+
showMessage(data.detail || 'Login failed.');
|
|
|
|
| 313 |
}
|
| 314 |
} catch (error) {
|
| 315 |
console.error('Login fetch error:', error);
|
| 316 |
+
showMessage('An error occurred. Please try again.');
|
|
|
|
| 317 |
} finally {
|
| 318 |
loginBtn.disabled = false;
|
| 319 |
+
loginBtn.textContent = 'Login';
|
| 320 |
}
|
| 321 |
});
|
| 322 |
|
| 323 |
// --- SIGNUP LOGIC ---
|
| 324 |
+
signupForm.addEventListener('submit', async (e) => {
|
| 325 |
+
e.preventDefault();
|
| 326 |
+
showMessage('');
|
| 327 |
signupBtn.disabled = true;
|
| 328 |
+
signupBtn.textContent = 'Signing up...';
|
| 329 |
|
| 330 |
+
const username = e.target.username.value;
|
| 331 |
+
const password = e.target.password.value;
|
| 332 |
|
| 333 |
if (!username || !password) {
|
| 334 |
+
showMessage('Please enter a username and password.');
|
|
|
|
| 335 |
signupBtn.disabled = false;
|
| 336 |
+
signupBtn.textContent = 'Sign Up';
|
| 337 |
return;
|
| 338 |
}
|
| 339 |
|
|
|
|
| 345 |
});
|
| 346 |
|
| 347 |
if (response.status === 201) {
|
| 348 |
+
showMessage('Signup successful! Please log in.', false);
|
| 349 |
+
// Automatically switch to login form
|
| 350 |
+
setTimeout(() => {
|
| 351 |
+
formContainer.classList.remove('show-signup');
|
| 352 |
+
adjustContainerHeight();
|
| 353 |
+
// Pre-fill username for convenience
|
| 354 |
+
loginForm.username.value = username;
|
| 355 |
+
loginForm.password.focus();
|
| 356 |
+
}, 1500);
|
| 357 |
} else {
|
| 358 |
const errorData = await response.json();
|
| 359 |
+
showMessage(errorData.detail || 'Signup failed.');
|
|
|
|
| 360 |
}
|
| 361 |
} catch (error) {
|
| 362 |
console.error('Signup error:', error);
|
| 363 |
+
showMessage('An error occurred. Please try again.');
|
|
|
|
| 364 |
} finally {
|
| 365 |
signupBtn.disabled = false;
|
| 366 |
+
signupBtn.textContent = 'Sign Up';
|
| 367 |
}
|
| 368 |
});
|
| 369 |
+
|
| 370 |
+
// Adjust height on window resize
|
| 371 |
+
window.addEventListener('resize', adjustContainerHeight);
|
| 372 |
});
|
| 373 |
</script>
|
| 374 |
</body>
|