Spaces:
Sleeping
Sleeping
File size: 7,511 Bytes
9e7b45f | 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | // Theme Toggle Functionality
document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.querySelector('.theme-switch__checkbox');
const body = document.body;
const fadeOverlay = document.getElementById('fadeOverlay');
// Load saved theme or default to light
const savedTheme = localStorage.getItem('theme') || 'light';
body.className = savedTheme;
// Set initial toggle state
if (savedTheme === 'dark') {
themeToggle.checked = true;
}
// Theme toggle event listener
if (themeToggle) {
themeToggle.addEventListener('change', function() {
// Add fade overlay during transition
if (fadeOverlay) {
fadeOverlay.classList.add('active');
}
// Change theme immediately to prevent text disappearing
if (this.checked) {
body.className = 'dark';
localStorage.setItem('theme', 'dark');
} else {
body.className = 'light';
localStorage.setItem('theme', 'light');
}
// Remove fade overlay after a shorter delay
setTimeout(() => {
if (fadeOverlay) {
fadeOverlay.classList.remove('active');
}
}, 150);
});
}
});
// Password visibility toggle for faculty
function togglePassword() {
const passwordInput = document.getElementById('password');
const eyeIcon = document.querySelector('.eye-icon');
if (passwordInput && eyeIcon) {
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.textContent = 'π';
} else {
passwordInput.type = 'password';
eyeIcon.textContent = 'π';
}
}
}
// Password visibility toggle for student
function toggleStudentPassword() {
const passwordInput = document.getElementById('student_password');
const eyeIcon = document.querySelector('#studentForm .eye-icon');
if (passwordInput && eyeIcon) {
if (passwordInput.type === 'password') {
passwordInput.type = 'text';
eyeIcon.textContent = 'π';
} else {
passwordInput.type = 'password';
eyeIcon.textContent = 'π';
}
}
}
// Remember me functionality for faculty
function storeRememberMe() {
const rememberMe = document.getElementById('rememberMe');
const email = document.getElementById('faculty_email');
if (rememberMe && email) {
if (rememberMe.checked) {
localStorage.setItem('rememberedEmail', email.value);
} else {
localStorage.removeItem('rememberedEmail');
}
}
}
// Remember me functionality for student
function storeStudentRememberMe() {
const rememberMe = document.getElementById('rememberStudent');
const rollNo = document.getElementById('roll_no');
if (rememberMe && rollNo) {
if (rememberMe.checked) {
localStorage.setItem('rememberedRollNo', rollNo.value);
} else {
localStorage.removeItem('rememberedRollNo');
}
}
}
// Load remembered data
document.addEventListener('DOMContentLoaded', function() {
// Load remembered faculty email
const rememberedEmail = localStorage.getItem('rememberedEmail');
const emailInput = document.getElementById('faculty_email');
const rememberMe = document.getElementById('rememberMe');
if (rememberedEmail && emailInput) {
emailInput.value = rememberedEmail;
if (rememberMe) {
rememberMe.checked = true;
}
}
// Load remembered student roll number
const rememberedRollNo = localStorage.getItem('rememberedRollNo');
const rollNoInput = document.getElementById('roll_no');
const rememberStudent = document.getElementById('rememberStudent');
if (rememberedRollNo && rollNoInput) {
rollNoInput.value = rememberedRollNo;
if (rememberStudent) {
rememberStudent.checked = true;
}
}
});
// Mobile responsiveness helpers
function handleMobileLayout() {
const isMobile = window.innerWidth <= 768;
const body = document.body;
if (isMobile) {
body.classList.add('mobile-layout');
} else {
body.classList.remove('mobile-layout');
}
}
// Handle window resize
window.addEventListener('resize', handleMobileLayout);
// Initial mobile layout check
document.addEventListener('DOMContentLoaded', handleMobileLayout);
// Smooth scrolling for mobile
function smoothScrollTo(element) {
if (element) {
element.scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
}
// Handle form focus on mobile
document.addEventListener('DOMContentLoaded', function() {
const inputs = document.querySelectorAll('input[type="text"], input[type="password"]');
inputs.forEach(input => {
input.addEventListener('focus', function() {
if (window.innerWidth <= 768) {
setTimeout(() => {
smoothScrollTo(this);
}, 300);
}
});
});
});
// Prevent zoom on input focus (iOS)
document.addEventListener('DOMContentLoaded', function() {
const inputs = document.querySelectorAll('input[type="text"], input[type="password"]');
inputs.forEach(input => {
input.addEventListener('focus', function() {
if (window.innerWidth <= 768) {
const viewport = document.querySelector('meta[name="viewport"]');
if (viewport) {
viewport.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
}
}
});
input.addEventListener('blur', function() {
if (window.innerWidth <= 768) {
const viewport = document.querySelector('meta[name="viewport"]');
if (viewport) {
viewport.content = 'width=device-width, initial-scale=1.0';
}
}
});
});
});
// Enhanced touch interactions for mobile
document.addEventListener('DOMContentLoaded', function() {
const buttons = document.querySelectorAll('button, input[type="submit"], .role-option');
buttons.forEach(button => {
button.addEventListener('touchstart', function() {
this.classList.add('touch-active');
});
button.addEventListener('touchend', function() {
setTimeout(() => {
this.classList.remove('touch-active');
}, 150);
});
});
});
// Handle orientation change
window.addEventListener('orientationchange', function() {
setTimeout(() => {
handleMobileLayout();
}, 100);
});
// Keyboard navigation improvements
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && e.target.tagName === 'INPUT') {
const form = e.target.closest('form');
if (form) {
const inputs = Array.from(form.querySelectorAll('input[type="text"], input[type="password"]'));
const currentIndex = inputs.indexOf(e.target);
if (currentIndex < inputs.length - 1) {
e.preventDefault();
inputs[currentIndex + 1].focus();
}
}
}
});
|