forked from TejashMalviya/NoteMates5.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
81 lines (69 loc) · 2.56 KB
/
script.js
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
/*
Inspired by: "Login Page & Homepage"
By: Neo Link: https://dribbble.com/shots/4485321-Login-Page-Homepage
*/
let usernameInput = document.querySelector(".username");
let passwordInput = document.querySelector(".password");
let showPasswordButton = document.querySelector(".password-button");
let face = document.querySelector(".face");
passwordInput.addEventListener("focus", (event) => {
document.querySelectorAll(".hand").forEach((hand) => {
hand.classList.add("hide");
});
document.querySelector(".tongue").classList.remove("breath");
});
passwordInput.addEventListener("blur", (event) => {
document.querySelectorAll(".hand").forEach((hand) => {
hand.classList.remove("hide");
hand.classList.remove("peek");
});
document.querySelector(".tongue").classList.add("breath");
});
usernameInput.addEventListener("focus", (event) => {
let length = Math.min(usernameInput.value.length - 16, 19);
document.querySelectorAll(".hand").forEach((hand) => {
hand.classList.remove("hide");
hand.classList.remove("peek");
});
face.style.setProperty("--rotate-head", `${-length}deg`);
});
usernameInput.addEventListener("blur", (event) => {
face.style.setProperty("--rotate-head", "0deg");
});
usernameInput.addEventListener(
"input",
_.throttle((event) => {
let length = Math.min(event.target.value.length - 16, 19);
face.style.setProperty("--rotate-head", `${-length}deg`);
}, 100)
);
showPasswordButton.addEventListener("click", (event) => {
if (passwordInput.type === "text") {
passwordInput.type = "password";
document.querySelectorAll(".hand").forEach((hand) => {
hand.classList.remove("peek");
hand.classList.add("hide");
});
} else {
passwordInput.type = "text";
document.querySelectorAll(".hand").forEach((hand) => {
hand.classList.remove("hide");
hand.classList.add("peek");
});
}
});
// Handle form submission
document.getElementById('loginForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent default form submission
// Perform validation or authentication (this is a placeholder, replace with actual validation logic)
const username = usernameInput.value;
const password = passwordInput.value;
// Simulate successful login
if (username && password) {
// Redirect to main.html after successful login
window.location.href = 'main.html';
} else {
// Display an error message (this is a placeholder)
alert('Invalid username or password');
}
});