forked from mansiruhil13/Bobble-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.html
135 lines (121 loc) · 4.63 KB
/
login.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Register & Login</title>
<!-- Google Fonts -->
<link
href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&display=swap"
rel="stylesheet"
/>
<!-- Boxicons -->
<link
href="https://unpkg.com/[email protected]/css/boxicons.min.css"
rel="stylesheet"
/>
<!-- Font Awesome -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<!-- Custom CSS -->
<link rel="stylesheet" href="src/css/login.css" />
<!-- EmailJS -->
<script
src="https://cdn.jsdelivr.net/npm/@emailjs/browser@4/dist/email.min.js"
type="text/javascript"
></script>
</head>
<body>
<!-- Login Form -->
<div class="wrapper">
<div class="form-box login" style="padding-top: 50px">
<h2 class="title animation" style="margin-bottom: 30px">Login</h2>
<form id="loginForm">
<div class="input-box animation" style="--i: 1; --j: 22">
<input type="text" id="loginUsername" required />
<label>Username</label>
<i class="bx bxs-user"></i>
</div>
<div class="input-box animation" style="--i: 2; --j: 23">
<input type="password" id="loginPassword" required />
<label>Password</label>
<i class="bx bxs-lock-alt"></i>
<i
class="fas fa-eye toggle-password"
id="togglePassword"
onclick="togglePassword()"
></i>
</div>
<button type="submit" class="btn animation" style="--i: 3; --j: 24">
Login
</button>
<div class="linkTxt animation" style="--i: 5; --j: 25">
<p>
Don't have an account?
<a href="#" class="register-link">Sign Up</a>
</p>
</div>
</form>
</div>
<span class="rotate-bg"></span>
<span class="rotate-bg2"></span>
</div>
<script>
// Toggle password visibility
function togglePassword() {
const password = document.getElementById("loginPassword");
const togglePassword = document.getElementById("togglePassword");
if (password.type === "password") {
password.type = "text";
togglePassword.classList.add("fa-eye-slash");
togglePassword.classList.remove("fa-eye");
} else {
password.type = "password";
togglePassword.classList.add("fa-eye");
togglePassword.classList.remove("fa-eye-slash");
}
}
// Handle form submission
document
.getElementById("loginForm")
.addEventListener("submit", function (event) {
event.preventDefault(); // Prevent form submission
const loginUsername = document.getElementById("loginUsername").value;
const loginPassword = document.getElementById("loginPassword").value;
// Retrieve stored user data (mocked with localStorage for demonstration)
const storedUser = JSON.parse(localStorage.getItem("user"));
// Validate credentials
if (
storedUser &&
loginUsername === storedUser.username &&
loginPassword === storedUser.password
) {
alert("Login successful! Redirecting to home page...");
localStorage.setItem("currentUser", loginUsername);
window.location.href = "index.html"; // Redirect to home page
} else {
alert("Invalid username or password.");
}
});
// Handle registration link click
document
.querySelector(".register-link")
.addEventListener("click", function () {
document.querySelector(".form-box.login").style.display = "none";
document.querySelector(".form-box.register").style.display = "block";
});
// Handle login link click
document
.querySelector(".login-link")
.addEventListener("click", function () {
document.querySelector(".form-box.register").style.display = "none";
document.querySelector(".form-box.login").style.display = "block";
});
</script>
</body>
</html>