-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
129 lines (113 loc) Β· 4.87 KB
/
index.html
File metadata and controls
129 lines (113 loc) Β· 4.87 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<title>TEAM - Login</title>
<!-- PWA Meta Tags -->
<meta name="description" content="Team management and productivity tracking application">
<meta name="theme-color" content="#00ff00">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="TEAM">
<!-- Icons -->
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="icon" type="image/png" sizes="192x192" href="icon-192x192.png">
<link rel="apple-touch-icon" href="icon-180x180.png">
<link rel="apple-touch-icon" sizes="152x152" href="icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="icon-180x180.png">
<link rel="apple-touch-icon" sizes="167x167" href="icon-167x167.png">
<!-- Manifest -->
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="css/style.css?v=1009">
</head>
<body class="login-page">
<div class="login-box">
<div class="logo">TEAM</div>
<div class="login-subtitle">MANAGEMENT SYSTEM</div>
<div class="login-form">
<form id="loginForm">
<div class="form-group">
<label class="form-label">Username:</label>
<input type="text" class="form-input" id="username" autocomplete="off">
</div>
<div class="form-group">
<label class="form-label">Password:</label>
<input type="password" class="form-input" id="password">
</div>
<div class="form-group" style="margin-top:10px">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;color:#0f0;font-size:12px">
<input type="checkbox" id="rememberMe" checked style="width:16px;height:16px;cursor:pointer;accent-color:#0f0">
<span>Remember Me (Stay logged in)</span>
</label>
</div>
<button type="submit" class="btn btn-primary" style="width:100%" id="loginBtn">Login</button>
</form>
<div class="login-error" id="error"></div>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-app-compat.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.23.0/firebase-firestore-compat.js"></script>
<script src="js/config.js?v=1009"></script>
<script src="js/config.local.js?v=1009"></script>
<script src="js/db.js?v=1009"></script>
<!-- PWA Service Worker Registration - DISABLED for stability -->
<script>
// UNREGISTER any existing service workers to prevent offline errors
if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(registration => {
registration.unregister();
console.log('ποΈ Unregistered service worker');
});
});
}
</script>
<script>
console.log('π INDEX.HTML LOADED - v1008');
DB.init();
console.log('β
DB.init() completed');
document.getElementById('loginForm').onsubmit = async (e) => {
e.preventDefault();
console.log('π LOGIN FORM SUBMITTED');
const btn = document.getElementById('loginBtn');
const err = document.getElementById('error');
err.style.display = 'none';
btn.disabled = true;
btn.textContent = 'Loading...';
try {
const username = document.getElementById('username').value.trim();
const password = document.getElementById('password').value;
const rememberMe = document.getElementById('rememberMe').checked;
console.log('π€ Username:', username);
console.log('π Password length:', password.length);
console.log('πΎ Remember Me:', rememberMe);
const r = await DB.login(username, password, rememberMe);
console.log('π₯ Login result:', r);
if (r.success) {
console.log('β
LOGIN SUCCESS!');
console.log('π€ User role:', r.user.role);
console.log('πΎ Waiting for session to save...');
// Wait a moment for localStorage/sessionStorage to fully write
await new Promise(resolve => setTimeout(resolve, 100));
console.log('π Redirecting to admin.html');
window.location.replace('admin.html');
} else {
console.error('β LOGIN FAILED:', r.error);
err.textContent = r.error || 'Login failed';
err.style.display = 'block';
btn.disabled = false;
btn.textContent = 'Login';
}
} catch (error) {
console.error('β LOGIN ERROR:', error);
err.textContent = 'Error: ' + error.message;
err.style.display = 'block';
btn.disabled = false;
btn.textContent = 'Login';
}
};
</script>
</body>
</html>