Spaces:
Sleeping
Sleeping
Update web/index.html
Browse files- web/index.html +45 -3
web/index.html
CHANGED
|
@@ -101,9 +101,9 @@
|
|
| 101 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 102 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
| 103 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
|
|
|
| 104 |
<li><a href="profile.html" class="nav-link">Profile</a></li>
|
| 105 |
-
<li><a href="login.html" class="nav-link">Login</a></li>
|
| 106 |
-
<li><a href="about.html" class="nav-link">About</a></li>
|
| 107 |
</ul>
|
| 108 |
|
| 109 |
<!-- Hamburger Menu -->
|
|
@@ -283,7 +283,49 @@
|
|
| 283 |
</div>
|
| 284 |
</footer>
|
| 285 |
|
| 286 |
-
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
// Fade-in on scroll
|
| 288 |
const fadeObserver = new IntersectionObserver(
|
| 289 |
(entries) => {
|
|
|
|
| 101 |
<ul class="hidden md:flex space-x-6 font-medium text-gray-800">
|
| 102 |
<li><a href="index.html" class="nav-link">Home</a></li>
|
| 103 |
<li><a href="analyzer.html" class="nav-link">Analyzer</a></li>
|
| 104 |
+
<li><a href="past_data.html" class="nav-link">Past Reports</a></li>
|
| 105 |
<li><a href="profile.html" class="nav-link">Profile</a></li>
|
| 106 |
+
<li id="authNavItem"><a href="login.html" class="nav-link">Login</a></li>
|
|
|
|
| 107 |
</ul>
|
| 108 |
|
| 109 |
<!-- Hamburger Menu -->
|
|
|
|
| 283 |
</div>
|
| 284 |
</footer>
|
| 285 |
|
| 286 |
+
<script type="module">
|
| 287 |
+
import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js';
|
| 288 |
+
import { getAuth, onAuthStateChanged, signOut } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-auth.js';
|
| 289 |
+
import { getFirestore, doc, getDoc, updateDoc } from 'https://www.gstatic.com/firebasejs/9.22.0/firebase-firestore.js';
|
| 290 |
+
|
| 291 |
+
const firebaseConfig = {
|
| 292 |
+
apiKey: "AIzaSyAPhM_Ee7cLzyKHs5zyFy8g5ZOk9-pubRI",
|
| 293 |
+
authDomain: "login-tutorial-7a9e1.firebaseapp.com",
|
| 294 |
+
projectId: "login-tutorial-7a9e1",
|
| 295 |
+
storageBucket: "login-tutorial-7a9e1.firebasestorage.app",
|
| 296 |
+
messagingSenderId: "491093197824",
|
| 297 |
+
appId: "1:491093197824:web:9f866..."
|
| 298 |
+
};
|
| 299 |
+
|
| 300 |
+
const app = initializeApp(firebaseConfig);
|
| 301 |
+
const auth = getAuth(app);
|
| 302 |
+
const db = getFirestore(app);
|
| 303 |
+
|
| 304 |
+
let currentUser = null;
|
| 305 |
+
|
| 306 |
+
onAuthStateChanged(auth, (user) => {
|
| 307 |
+
const authNavItem = document.getElementById('authNavItem');
|
| 308 |
+
if (authNavItem) {
|
| 309 |
+
if (user) {
|
| 310 |
+
authNavItem.innerHTML = '<button onclick="logout()" class="hover:text-[#6B9080] text-red-600">Logout</button>';
|
| 311 |
+
} else {
|
| 312 |
+
authNavItem.innerHTML = '<a href="login.html" class="hover:text-[#6B9080]">Login</a>';
|
| 313 |
+
}
|
| 314 |
+
}
|
| 315 |
+
});
|
| 316 |
+
|
| 317 |
+
|
| 318 |
+
window.logout = async () => {
|
| 319 |
+
try {
|
| 320 |
+
await signOut(auth);
|
| 321 |
+
localStorage.clear();
|
| 322 |
+
window.location.href = 'login.html';
|
| 323 |
+
} catch (error) {
|
| 324 |
+
console.error("Error signing out:", error);
|
| 325 |
+
}
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
|
| 329 |
// Fade-in on scroll
|
| 330 |
const fadeObserver = new IntersectionObserver(
|
| 331 |
(entries) => {
|