vineelagampa commited on
Commit
ffd8a73
·
verified ·
1 Parent(s): 2d79148

Update web/login.html

Browse files
Files changed (1) hide show
  1. web/login.html +167 -239
web/login.html CHANGED
@@ -5,255 +5,164 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>Login / Signup - CTRL + ALT + HEAL</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
 
 
 
 
8
  <style>
9
  :root {
10
- --blue: rgb(120, 187, 242);
11
- --l-blue: rgb(197, 217, 251);
12
  --latte-cream: #ffffff;
13
- --red: #ff746c;
14
- --l-red: #faa0a0;
15
  }
16
-
17
  body {
18
  font-family: "Rubik", sans-serif;
19
- background-color: var(--cream);
20
  color: #333;
21
  }
22
-
23
- /* Navbar styles */
24
- nav {
25
- backdrop-filter: blur(10px);
26
- background: rgba(255, 255, 255, 0.85);
27
- transition: transform 0.3s ease, background-color 0.3s ease,
28
- box-shadow 0.3s ease;
29
- }
30
-
31
- nav.scrolled {
32
- background: rgba(255, 255, 255, 1);
33
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
34
- transform: translateY(-5px);
35
- }
36
-
37
- nav a {
38
- transition: color 0.3s ease, transform 0.2s ease;
39
- }
40
-
41
- nav a:hover {
42
- color: var(--blue);
43
- transform: translateY(-2px);
44
- }
45
-
46
- /* Form card animation */
47
- @keyframes fadeSlideUp {
48
- 0% {
49
- opacity: 0;
50
- transform: translateY(20px);
51
- }
52
- 100% {
53
- opacity: 1;
54
- transform: translateY(0);
55
- }
56
- }
57
-
58
- .fade-slide-up {
59
- animation: fadeSlideUp 0.6s ease forwards;
60
- }
61
-
62
- .form-card {
63
- background: rgba(255, 255, 255, 0.85);
64
- backdrop-filter: blur(10px);
65
  border-radius: 1rem;
 
66
  padding: 2rem;
67
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
68
  transition: transform 0.3s ease, box-shadow 0.3s ease;
69
  }
70
-
71
- .form-card:hover {
72
  transform: translateY(-5px);
73
- box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
74
  }
75
-
76
- .form-input {
77
- width: 100%;
78
- padding: 0.5rem 1rem;
79
- border-radius: 0.5rem;
80
- border: 1px solid #ccc;
81
- transition: border-color 0.3s ease, box-shadow 0.3s ease;
82
  }
83
-
84
- .form-input:focus {
85
- outline: none;
86
- border-color: var(--blue);
87
- box-shadow: 0 0 0 3px rgba(120, 187, 242, 0.3);
 
 
 
 
88
  }
89
-
90
- .btn-primary {
91
  width: 100%;
92
- padding: 0.75rem;
93
- border-radius: 0.75rem;
94
- background-color: var(--blue);
95
- color: white;
96
- font-weight: 600;
97
- transition: background-color 0.3s ease, transform 0.2s ease,
98
- box-shadow 0.2s ease;
99
  }
100
-
101
- .btn-primary:hover {
102
- background-color: var(--l-blue);
103
- color: #333;
104
- transform: translateY(-2px);
105
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
106
- }
107
-
108
- .btn-red {
109
  width: 100%;
110
- padding: 0.75rem;
111
- border-radius: 0.75rem;
112
- background-color: var(--red);
113
- color: white;
114
- font-weight: 600;
115
- transition: background-color 0.3s ease, transform 0.2s ease,
116
- box-shadow 0.2s ease;
117
- }
118
-
119
- .btn-red:hover {
120
- background-color: var(--l-red);
121
- transform: translateY(-2px);
122
- box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
123
  }
124
  </style>
125
  </head>
126
- <body
127
- class="min-h-screen flex flex-col items-center justify-start px-4 pt-24"
128
- >
129
- <!-- Navbar -->
130
  <nav
131
  class="fixed top-0 left-0 w-full z-50 backdrop-blur-md bg-white/20 border-b border-white/30 shadow-md"
132
  >
133
- <div
134
- class="max-w-6xl mx-auto px-6 py-4 flex justify-between items-center"
135
- >
136
- <!-- Logo -->
137
  <a
138
  href="index.html"
139
- class="text-2xl font-bold hover:text-[var(--tropical-indigo)] transition"
140
  >
141
  CTRL + ALT + HEAL
142
  </a>
143
-
144
  <!-- Desktop Menu -->
145
  <ul class="hidden md:flex space-x-6 font-medium text-gray-800">
146
  <li><a href="index.html" class="nav-link">Home</a></li>
147
- <li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
148
  <li><a href="profile.html" class="nav-link">Profile</a></li>
149
- <li><a href="login.html" class="nav-link">Login</a></li>
150
- <li><a href="about.html" class="nav-link">About</a></li>
151
- </ul>
152
-
153
- <!-- Hamburger Menu -->
154
- <button id="hamburger" class="md:hidden text-[#000000] text-2xl">
 
155
 
156
  </button>
157
  </div>
158
-
159
- <!-- Mobile Menu -->
160
  <ul
161
  id="mobile-menu"
162
  class="hidden flex-col space-y-4 bg-white/30 backdrop-blur-lg border border-white/20 rounded-xl shadow-lg mt-2 p-4 mx-6 md:hidden"
163
  >
 
164
  <li>
165
- <a
166
- href="index.html"
167
- class="block text-bold text-gray-800 hover:text-[var(--neon-green)]"
168
- >Home</a
169
- >
170
- </li>
171
- <li>
172
- <a
173
- href="analyzer.html"
174
- class="block text-gray-800 hover:text-[var(--neon-green)]"
175
- >Analyzer</a
176
- >
177
- </li>
178
- <li>
179
- <a
180
- href="profile.html"
181
- class="block text-gray-800 hover:text-[var(--neon-green)]"
182
- >Profile</a
183
- >
184
  </li>
 
185
  <li>
186
- <a
187
- href="login.html"
188
- class="block text-gray-800 hover:text-[var(--neon-green)]"
189
- >Login</a
190
- >
191
- </li>
192
- <li>
193
- <a
194
- href="about.html"
195
- class="block text-gray-800 hover:text-[var(--neon-green)]"
196
- >About</a
197
- >
198
  </li>
199
  </ul>
200
  </nav>
201
 
202
- <!-- Login Form -->
203
- <div class="form-card w-full max-w-md fade-slide-up mt-8">
204
- <h2 id="formTitle" class="text-2xl font-semibold text-[var(--blue)] mb-6">
205
- Log In
206
- </h2>
207
- <input type="hidden" id="mode" value="login" />
208
-
209
- <label class="block mb-2 text-sm font-medium">Mode</label>
210
- <select
211
- id="modeSelector"
212
- onchange="toggleMode(this.value)"
213
- class="form-input mb-4"
214
- >
215
- <option value="login">Log In</option>
216
- <option value="signup">Sign Up</option>
217
- </select>
218
-
219
- <label class="block mb-2 text-sm font-medium">Email</label>
220
- <input
221
- type="email"
222
- id="email"
223
- placeholder="you@example.com"
224
- class="form-input mb-4"
225
- />
226
-
227
- <label class="block mb-2 text-sm font-medium">Password</label>
228
- <input
229
- type="password"
230
- id="password"
231
- placeholder="••••••••"
232
- class="form-input mb-4"
233
- />
234
 
235
- <div id="nameGroup" style="display: none">
236
- <label class="block mb-2 text-sm font-medium">Name</label>
237
  <input
238
- type="text"
239
- id="name"
240
- placeholder="Your Name"
241
- class="form-input mb-4"
 
 
 
 
 
 
242
  />
243
- </div>
244
 
245
- <div id="dobGroup" style="display: none">
246
- <label class="block mb-2 text-sm font-medium">Date of Birth</label>
247
- <input type="date" id="dob" class="form-input mb-6" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  </div>
 
249
 
250
- <button onclick="submitForm()" id="submitBtn" class="btn-primary mb-2">
251
- Log In
252
- </button>
253
- <button onclick="resetPassword()" class="btn-red">Reset Password</button>
254
- </div>
255
 
256
- <!-- Firebase & JS -->
257
  <script type="module">
258
  import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
259
  import {
@@ -269,37 +178,63 @@
269
  } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
270
 
271
  const firebaseConfig = {
272
- apiKey: "",
273
- authDomain: "",
274
- projectId: "",
275
- storageBucket: "",
276
- messagingSenderId: "",
277
- appId: "",
278
- measurementId: "",
279
  };
280
 
281
  const app = initializeApp(firebaseConfig);
282
  const auth = getAuth(app);
283
  const db = getFirestore(app);
284
 
285
- window.toggleMode = (mode) => {
286
- document.getElementById("formTitle").textContent =
287
- mode === "signup" ? "Sign Up" : "Log In";
288
- document.getElementById("nameGroup").style.display =
289
- mode === "signup" ? "block" : "none";
290
- document.getElementById("dobGroup").style.display =
291
- mode === "signup" ? "block" : "none";
292
- document.getElementById("submitBtn").textContent =
293
- mode === "signup" ? "Sign Up" : "Log In";
294
- document.getElementById("mode").value = mode;
 
 
 
 
 
 
 
295
  };
296
 
297
- window.submitForm = async () => {
298
- const mode = document.getElementById("mode").value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  const email = document.getElementById("email").value;
300
  const password = document.getElementById("password").value;
301
- try {
302
- if (mode === "signup") {
 
 
303
  const name = document.getElementById("name").value;
304
  const dob = document.getElementById("dob").value;
305
  const userCredential = await createUserWithEmailAndPassword(
@@ -309,40 +244,33 @@
309
  );
310
  const user = userCredential.user;
311
  await setDoc(doc(db, "users", user.uid), { name, email, dob });
312
- } else {
 
 
 
 
 
313
  await signInWithEmailAndPassword(auth, email, password);
 
 
 
314
  }
315
- window.location.href = "profile.html";
316
- } catch (err) {
317
- alert(
318
- (mode === "signup" ? "Sign Up" : "Log In") +
319
- " error: " +
320
- err.message
321
- );
322
  }
323
- };
324
 
325
  window.resetPassword = async () => {
326
  const email = document.getElementById("email").value;
327
- if (!email) return alert("Please enter your email to reset password.");
 
 
 
328
  try {
329
  await sendPasswordResetEmail(auth, email);
330
- alert("Password reset email sent to " + email);
331
  } catch (err) {
332
- alert("Error sending password reset: " + err.message);
333
  }
334
  };
335
-
336
- document.addEventListener("DOMContentLoaded", () => {
337
- toggleMode("login");
338
-
339
- // Navbar scroll animation
340
- const navbar = document.getElementById("navbar");
341
- window.addEventListener("scroll", () => {
342
- if (window.scrollY > 20) navbar.classList.add("scrolled");
343
- else navbar.classList.remove("scrolled");
344
- });
345
- });
346
  </script>
347
  </body>
348
- </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>Login / Signup - CTRL + ALT + HEAL</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
+ <link
9
+ href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;700&display=swap"
10
+ rel="stylesheet"
11
+ />
12
  <style>
13
  :root {
14
+ --tropical-indigo: rgb(120, 187, 242);
15
+ --wisteria: rgb(197, 217, 251);
16
  --latte-cream: #ffffff;
 
 
17
  }
 
18
  body {
19
  font-family: "Rubik", sans-serif;
20
+ background-color: var(--latte-cream);
21
  color: #333;
22
  }
23
+ .glass-card {
24
+ background: rgba(162, 160, 160, 0.075);
25
+ backdrop-filter: blur(12px);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  border-radius: 1rem;
27
+ border: 1px solid rgba(255, 255, 255, 0.3);
28
  padding: 2rem;
 
29
  transition: transform 0.3s ease, box-shadow 0.3s ease;
30
  }
31
+ .glass-card:hover {
 
32
  transform: translateY(-5px);
33
+ box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
34
  }
35
+ .nav-link {
36
+ position: relative;
37
+ padding-bottom: 4px;
38
+ transition: color 0.3s;
 
 
 
39
  }
40
+ .nav-link::after {
41
+ content: "";
42
+ position: absolute;
43
+ width: 0%;
44
+ height: 2px;
45
+ bottom: 0;
46
+ left: 0;
47
+ background-color: var(--tropical-indigo);
48
+ transition: width 0.3s ease;
49
  }
50
+ .nav-link:hover::after {
 
51
  width: 100%;
 
 
 
 
 
 
 
52
  }
53
+ .nav-link.active-page::after {
 
 
 
 
 
 
 
 
54
  width: 100%;
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
  </style>
57
  </head>
58
+ <body class="min-h-screen flex flex-col">
59
+ <!-- NAVBAR -->
 
 
60
  <nav
61
  class="fixed top-0 left-0 w-full z-50 backdrop-blur-md bg-white/20 border-b border-white/30 shadow-md"
62
  >
63
+ <div class="flex justify-between items-center w-full px-6 py-4">
 
 
 
64
  <a
65
  href="index.html"
66
+ class="text-2xl font-bold text-black hover:text-[var(--tropical-indigo)] transition"
67
  >
68
  CTRL + ALT + HEAL
69
  </a>
 
70
  <!-- Desktop Menu -->
71
  <ul class="hidden md:flex space-x-6 font-medium text-gray-800">
72
  <li><a href="index.html" class="nav-link">Home</a></li>
 
73
  <li><a href="profile.html" class="nav-link">Profile</a></li>
74
+ <li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
75
+ <li><a href="past_data.html" class="nav-link">Past Report</a></li>
76
+
77
+ <button
78
+ id="hamburger"
79
+ class="md:hidden text-[var(--latte-cream)] text-2xl"
80
+ >
81
 
82
  </button>
83
  </div>
 
 
84
  <ul
85
  id="mobile-menu"
86
  class="hidden flex-col space-y-4 bg-white/30 backdrop-blur-lg border border-white/20 rounded-xl shadow-lg mt-2 p-4 mx-6 md:hidden"
87
  >
88
+ <li><a href="index.html" class="block text-gray-800">Home</a></li>
89
  <li>
90
+ <a href="analyzer.html" class="block text-gray-800">Analyzer</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  </li>
92
+ <li><a href="profile.html" class="block text-gray-800">Profile</a></li>
93
  <li>
94
+ <a href="login.html" class="block text-gray-800 active-page">Login</a>
 
 
 
 
 
 
 
 
 
 
 
95
  </li>
96
  </ul>
97
  </nav>
98
 
99
+ <!-- LOGIN FORM -->
100
+ <main class="flex flex-1 items-center justify-center pt-28 px-6">
101
+ <div class="glass-card w-full max-w-md text-center">
102
+ <h2 class="text-3xl font-bold text-[var(--tropical-indigo)] mb-6">
103
+ Sign In / Sign Up
104
+ </h2>
105
+ <select
106
+ id="modeSelector"
107
+ onchange="toggleMode(this.value)"
108
+ class="w-full mb-4 px-4 py-2 border rounded-lg"
109
+ >
110
+ <option value="login">Log In</option>
111
+ <option value="signup">Sign Up</option>
112
+ </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
 
 
114
  <input
115
+ type="email"
116
+ id="email"
117
+ placeholder="Email"
118
+ class="w-full mb-4 px-4 py-2 border rounded-lg"
119
+ />
120
+ <input
121
+ type="password"
122
+ id="password"
123
+ placeholder="Password"
124
+ class="w-full mb-4 px-4 py-2 border rounded-lg"
125
  />
 
126
 
127
+ <div id="nameGroup" style="display: none">
128
+ <input
129
+ type="text"
130
+ id="name"
131
+ placeholder="Full Name"
132
+ class="w-full mb-4 px-4 py-2 border rounded-lg"
133
+ />
134
+ </div>
135
+
136
+ <div id="dobGroup" style="display: none">
137
+ <input
138
+ type="date"
139
+ id="dob"
140
+ class="w-full mb-4 px-4 py-2 border rounded-lg"
141
+ />
142
+ </div>
143
+
144
+ <p id="error-message" class="text-red-500 text-sm mb-4"></p>
145
+
146
+ <button
147
+ id="submitBtn"
148
+ class="w-full bg-[var(--tropical-indigo)] text-white py-2 rounded-lg hover:bg-[var(--wisteria)] mb-2"
149
+ >
150
+ Log In
151
+ </button>
152
+ <button
153
+ onclick="resetPassword()"
154
+ class="w-full bg-gray-200 text-gray-800 py-2 rounded-lg hover:bg-gray-300"
155
+ >
156
+ Reset Password
157
+ </button>
158
  </div>
159
+ </main>
160
 
161
+ <!-- FOOTER -->
162
+ <footer class="py-6 bg-[var(--wisteria)] text-white text-center">
163
+ &copy; 2025 CTRL + ALT + HEAL. All rights reserved.
164
+ </footer>
 
165
 
 
166
  <script type="module">
167
  import { initializeApp } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js";
168
  import {
 
178
  } from "https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js";
179
 
180
  const firebaseConfig = {
181
+ apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
182
+ authDomain: "login-tutorial-7a9e1.firebaseapp.com",
183
+ projectId: "login-tutorial-7a9e1",
184
+ storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
185
+ messagingSenderId: "491093197824",
186
+ appId: "1:491093197824:web:9f866...",
 
187
  };
188
 
189
  const app = initializeApp(firebaseConfig);
190
  const auth = getAuth(app);
191
  const db = getFirestore(app);
192
 
193
+ let mode = "login";
194
+ const nameGroup = document.getElementById("nameGroup");
195
+ const dobGroup = document.getElementById("dobGroup");
196
+ const actionBtn = document.getElementById("submitBtn");
197
+ const errorElement = document.getElementById("error-message");
198
+
199
+ window.toggleMode = (newMode) => {
200
+ mode = newMode;
201
+ if (mode === "signup") {
202
+ nameGroup.style.display = "block";
203
+ dobGroup.style.display = "block";
204
+ actionBtn.textContent = "Sign Up";
205
+ } else {
206
+ nameGroup.style.display = "none";
207
+ dobGroup.style.display = "none";
208
+ actionBtn.textContent = "Log In";
209
+ }
210
  };
211
 
212
+
213
+ const getFriendlyErrorMessage = (error) => {
214
+ switch (error.code) {
215
+ case 'auth/invalid-email':
216
+ return 'Invalid email format. Please try again.';
217
+ case 'auth/user-not-found':
218
+ return 'No user found with this email.';
219
+ case 'auth/wrong-password':
220
+ return 'Incorrect password. Please try again.';
221
+ case 'auth/weak-password':
222
+ return 'Password is too weak. Please use at least 6 characters.';
223
+ case 'auth/invalid-login-credentials':
224
+ return 'Invalid email or password. Please try again.';
225
+ default:
226
+ return 'An unknown error occurred. Please try again.';
227
+ }
228
+ };
229
+
230
+ actionBtn.addEventListener("click", async (e) => {
231
+ e.preventDefault();
232
  const email = document.getElementById("email").value;
233
  const password = document.getElementById("password").value;
234
+ errorElement.textContent = "";
235
+
236
+ if (mode === "signup") {
237
+ try {
238
  const name = document.getElementById("name").value;
239
  const dob = document.getElementById("dob").value;
240
  const userCredential = await createUserWithEmailAndPassword(
 
244
  );
245
  const user = userCredential.user;
246
  await setDoc(doc(db, "users", user.uid), { name, email, dob });
247
+ window.location.href = "profile.html";
248
+ } catch (err) {
249
+ errorElement.textContent = getFriendlyErrorMessage(err);
250
+ }
251
+ } else {
252
+ try {
253
  await signInWithEmailAndPassword(auth, email, password);
254
+ window.location.href = "profile.html";
255
+ } catch (err) {
256
+ errorElement.textContent = getFriendlyErrorMessage(err);
257
  }
 
 
 
 
 
 
 
258
  }
259
+ });
260
 
261
  window.resetPassword = async () => {
262
  const email = document.getElementById("email").value;
263
+ if (!email) {
264
+ errorElement.textContent = "Enter your email first!";
265
+ return;
266
+ }
267
  try {
268
  await sendPasswordResetEmail(auth, email);
269
+ alert("Password reset email sent!");
270
  } catch (err) {
271
+ errorElement.textContent = err.message;
272
  }
273
  };
 
 
 
 
 
 
 
 
 
 
 
274
  </script>
275
  </body>
276
+ </html>