-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
121 lines (95 loc) · 3.62 KB
/
Copy pathscript.js
File metadata and controls
121 lines (95 loc) · 3.62 KB
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
/* ================= PASSWORD TOGGLE ================= */
function togglePassword() {
const input = document.getElementById("password");
const icon = document.getElementById("eyeIcon");
if (input.type === "password") {
input.type = "text";
if (icon) icon.innerText = "🙈";
} else {
input.type = "password";
if (icon) icon.innerText = "👁";
}
}
/* ================= PASSWORD STRENGTH ================= */
function checkStrength() {
const password = document.getElementById("password").value;
const bar = document.getElementById("strengthBar");
const text = document.getElementById("strengthText");
if (!bar || !text) return;
let strength = 0;
if (password.length > 5) strength++;
if (/[A-Z]/.test(password)) strength++;
if (/[0-9]/.test(password)) strength++;
if (/[^A-Za-z0-9]/.test(password)) strength++;
let width = strength * 25;
bar.innerHTML = `<div style="width:${width}%; background:${getColor(strength)}"></div>`;
text.innerText = getText(strength);
text.style.color = getColor(strength);
}
function getColor(strength) {
return ["#ef4444","#f97316","#eab308","#22c55e"][strength-1] || "#64748b";
}
function getText(strength) {
return ["Weak","Medium","Strong","Very Strong"][strength-1] || "";
}
/* ================= VALIDATION ================= */
function validateForm() {
const pass = document.getElementById("password")?.value;
const confirm = document.getElementById("confirm")?.value;
const error = document.getElementById("errorMsg");
if (pass !== confirm) {
if (error) error.innerText = "Passwords do not match!";
return false;
}
return true;
}
/* ================= LOGIN LOADING ================= */
function showLoader() {
const btn = document.getElementById("loginBtn");
if (!btn) return;
btn.classList.add("loading");
btn.innerText = "Logging in...";
}
/* ================= SUGGESTION TOGGLE ================= */
function toggleSuggestions() {
const box = document.getElementById("suggestionBox");
if (!box) return;
if (box.style.display === "none" || box.style.display === "") {
box.style.display = "block";
} else {
box.style.display = "none";
}
}
/* ================= FILE UPLOAD ================= */
const uploadBox = document.getElementById("uploadBox");
const fileInput = document.getElementById("fileInput");
const fileName = document.getElementById("fileName");
if (uploadBox && fileInput) {
uploadBox.addEventListener("click", () => fileInput.click());
fileInput.addEventListener("change", () => {
if (fileInput.files.length > 0) {
fileName.innerText = "📄 " + fileInput.files[0].name;
}
});
uploadBox.addEventListener("dragover", (e) => {
e.preventDefault();
uploadBox.style.border = "2px dashed #6366f1";
});
uploadBox.addEventListener("dragleave", () => {
uploadBox.style.border = "2px dashed #555";
});
uploadBox.addEventListener("drop", (e) => {
e.preventDefault();
fileInput.files = e.dataTransfer.files;
fileName.innerText = "📄 " + e.dataTransfer.files[0].name;
});
}
/* ================= CARD HOVER EFFECT ================= */
document.querySelectorAll(".card").forEach(card => {
card.addEventListener("mouseenter", () => {
card.style.transform = "translateY(-5px)";
});
card.addEventListener("mouseleave", () => {
card.style.transform = "translateY(0)";
});
});