Spaces:
Running
Running
File size: 1,453 Bytes
bacb505 e0cbd77 0658440 bacb505 0658440 bacb505 0658440 bacb505 0658440 | 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 |
// 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();
}
} |