-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
116 lines (94 loc) · 3.67 KB
/
Copy pathscript.js
File metadata and controls
116 lines (94 loc) · 3.67 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
// Floating Background Particles
document.addEventListener('DOMContentLoaded', () => {
const particlesContainer = document.getElementById('particles');
const particleCount = 20;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.classList.add('particle');
// Random properties
const size = Math.random() * 8 + 2;
const left = Math.random() * 100;
const duration = Math.random() * 20 + 10;
const delay = Math.random() * 10;
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
particle.style.left = `${left}%`;
particle.style.animationDuration = `${duration}s`;
particle.style.animationDelay = `${delay}s`;
particlesContainer.appendChild(particle);
}
});
// Tab Switching
function switchTab(tabId) {
// Update buttons
document.querySelectorAll('.tab-btn').forEach(btn => {
btn.classList.remove('active');
});
event.target.classList.add('active');
// Update forms
document.querySelectorAll('.login-form').forEach(form => {
form.classList.remove('active');
});
document.getElementById(`${tabId}-form`).classList.add('active');
}
// Simulated OTP Logic
function sendOTP(method) {
const inputId = method === 'email' ? 'email-input' : 'mobile-input';
const inputVal = document.getElementById(inputId).value;
const sendBtn = document.getElementById(`${method}-send-btn`);
const otpSection = document.getElementById(`${method}-otp-section`);
const verifyBtn = document.getElementById(`${method}-verify-btn`);
if (!inputVal) {
showToast('Please enter a valid address/number', 'error');
return;
}
// Simulate sending OTP (Loading state)
const originalText = sendBtn.innerHTML;
sendBtn.innerHTML = `<i class="fa-solid fa-circle-notch fa-spin"></i> Sending...`;
sendBtn.disabled = true;
setTimeout(() => {
sendBtn.innerHTML = `<i class="fa-solid fa-check"></i> OTP Sent`;
// Show OTP input and verify button
otpSection.style.display = 'block';
verifyBtn.classList.remove('hidden');
sendBtn.classList.add('hidden'); // Hide send button
showToast(`OTP sent to ${inputVal}`, 'success');
// Focus the OTP input
setTimeout(() => document.getElementById(`${method}-otp-input`).focus(), 100);
}, 1500);
}
function verifyOTP(method) {
const otpInputId = `${method}-otp-input`;
const otpVal = document.getElementById(otpInputId).value;
const verifyBtn = document.getElementById(`${method}-verify-btn`);
if (otpVal.length !== 6) {
showToast('Please enter a valid 6-digit OTP', 'error');
return;
}
// Simulate verification (Loading state)
const originalText = verifyBtn.innerHTML;
verifyBtn.innerHTML = `<i class="fa-solid fa-circle-notch fa-spin"></i> Verifying...`;
verifyBtn.disabled = true;
setTimeout(() => {
verifyBtn.innerHTML = `<i class="fa-solid fa-check"></i> Verified`;
showToast('Login Successful! Redirecting...', 'success');
// Redirect to dashboard
setTimeout(() => {
window.location.href = '/dashboard';
}, 1000);
}, 1500);
}
// Toast Notification
function showToast(message, type = 'default') {
const toast = document.getElementById('toast');
toast.textContent = message;
if (type === 'success') {
toast.classList.add('success');
} else {
toast.classList.remove('success');
}
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}