chanix21's picture
Create a responsive web-based Archiving Document Tracking System for one ICT Office.
25ce612 verified
Raw History Blame Contribute Delete
1.74 kB
// Global variables
let currentUser = null;
const documentStatuses = ['Pending', 'Ongoing', 'For Review', 'Approved', 'Archived'];
// DOM Ready
document.addEventListener('DOMContentLoaded', function() {
// Initialize components
initLoginForm();
// Check for authenticated user
checkAuth();
});
function initLoginForm() {
const loginForm = document.querySelector('form');
if (loginForm) {
loginForm.addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;
// Simulate login
simulateLogin(email, password);
});
}
}
function simulateLogin(email, password) {
// This would be replaced with actual API call in production
console.log(`Attempting login with ${email}`);
// Mock user data based on email
let role = 'staff';
if (email.includes('admin')) role = 'admin';
if (email.includes('supervisor')) role = 'supervisor';
currentUser = {
email,
name: email.split('@')[0].replace('.', ' '),
role,
token: 'mock-token-' + Math.random().toString(36).substr(2, 9)
};
// Redirect to dashboard
window.location.href = 'dashboard.html';
}
function checkAuth() {
// This would check for existing auth token in production
if (currentUser) {
window.location.href = 'dashboard.html';
}
}
// Utility function to format dates
function formatDate(dateString) {
const options = { year: 'numeric', month: 'short', day: 'numeric' };
return new Date(dateString).toLocaleDateString(undefined, options);
}