Download script.js from Muso98/edusphere-smart-learning-hub: direct link, hf CLI and curl.
- Browser
- Download file 2.09 kB
-
https://huggingface.co/spaces/Muso98/edusphere-smart-learning-hub/resolve/main/script.js
- Command line
-
hf download hf://spaces/Muso98/edusphere-smart-learning-hub/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Muso98/edusphere-smart-learning-hub/resolve/main/script.js
2.09 kB
| // Global state management | |
| const appState = { | |
| currentUser: null, | |
| isAuthenticated: false, | |
| role: null | |
| }; | |
| // DOM ready function | |
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize components | |
| initAuthModal(); | |
| // Check for saved session | |
| checkSavedSession(); | |
| }); | |
| function checkSavedSession() { | |
| const token = localStorage.getItem('edu_token'); | |
| if (token) { | |
| // Validate token with backend in real implementation | |
| console.log('Found saved session token'); | |
| } | |
| } | |
| function initAuthModal() { | |
| const modal = document.querySelector('custom-auth-modal'); | |
| // Handle login form submission | |
| modal.shadowRoot.querySelector('#loginForm').addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const email = e.target.elements.email.value; | |
| const password = e.target.elements.password.value; | |
| const remember = e.target.elements.remember.checked; | |
| // Simulate login - replace with actual API call | |
| console.log(`Login attempt with ${email}`); | |
| setTimeout(() => { | |
| modal.hideModal(); | |
| showToast('Login successful! Redirecting...', 'success'); | |
| }, 1500); | |
| }); | |
| // Handle password reset | |
| modal.shadowRoot.querySelector('#forgotForm').addEventListener('submit', (e) => { | |
| e.preventDefault(); | |
| const email = e.target.elements.resetEmail.value; | |
| // Simulate reset request | |
| console.log(`Password reset requested for ${email}`); | |
| setTimeout(() => { | |
| modal.hideModal(); | |
| showToast('Password reset link sent to your email', 'success'); | |
| }, 1500); | |
| }); | |
| } | |
| function showToast(message, type = 'info') { | |
| const toast = document.createElement('div'); | |
| toast.className = `fixed bottom-4 right-4 px-6 py-3 rounded-lg shadow-lg text-white ${ | |
| type === 'success' ? 'bg-green-500' : 'bg-blue-500' | |
| } fade-in`; | |
| toast.textContent = message; | |
| document.body.appendChild(toast); | |
| setTimeout(() => { | |
| toast.remove(); | |
| }, 3000); | |
| } |