Spaces:
Running
Running
Download script.js from raibaebe/datavault-pro: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/spaces/raibaebe/datavault-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/raibaebe/datavault-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/raibaebe/datavault-pro/resolve/main/script.js
1.45 kB
| // API base URL | |
| const API_BASE_URL = 'https://jsonplaceholder.typicode.com'; | |
| // Handle login form submission | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const loginForm = document.querySelector('form'); | |
| if (loginForm) { | |
| loginForm.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const username = document.getElementById('username').value; | |
| const password = document.getElementById('password').value; | |
| // Simple admin check (in real app, use proper authentication) | |
| if (username === 'admin' && password === 'admin123') { | |
| window.location.href = '/admin.html'; | |
| } else { | |
| showLoginError('Invalid credentials. Admin login: admin/admin123'); | |
| } | |
| }); | |
| } | |
| // Check for error messages in URL (simulated) | |
| const urlParams = new URLSearchParams(window.location.search); | |
| if (urlParams.has('error')) { | |
| showLoginError(urlParams.get('error')); | |
| } | |
| }); | |
| function showLoginError(message) { | |
| const errorDiv = document.createElement('div'); | |
| errorDiv.className = 'error-message'; | |
| errorDiv.innerHTML = ` | |
| <i data-feather="alert-circle"></i> | |
| ${message || 'Invalid username or password. Please try again.'} | |
| `; | |
| const form = document.querySelector('form'); | |
| if (form) { | |
| form.prepend(errorDiv); | |
| feather.replace(); | |
| } | |
| } |