remove calendar dates notes - remain simple as it is for tasks only - Follow Up Deployment
Browse files- index.html +14 -13
index.html
CHANGED
|
@@ -30,7 +30,7 @@
|
|
| 30 |
</header>
|
| 31 |
|
| 32 |
<!-- Login Form -->
|
| 33 |
-
<div id="login-container" class="max-w-md mx-auto p-4 mt-4 bg-white dark:bg-gray-800 rounded-lg shadow-md">
|
| 34 |
<input id="email" type="email" placeholder="Email" class="w-full p-3 mb-2 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none" />
|
| 35 |
<input id="password" type="password" placeholder="Password" class="w-full p-3 mb-2 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none" />
|
| 36 |
<button id="login-btn" class="w-full py-3 bg-blue-500 text-white rounded-lg hover:opacity-90 transition">Login</button>
|
|
@@ -65,11 +65,8 @@
|
|
| 65 |
<!-- Firebase & Script -->
|
| 66 |
<script type="module">
|
| 67 |
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
|
| 68 |
-
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp, orderBy, doc, deleteDoc, updateDoc, where, query }
|
| 69 |
-
|
| 70 |
-
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, onAuthStateChanged }
|
| 71 |
-
from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
|
| 72 |
-
import { enableIndexedDbPersistence } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
|
| 73 |
|
| 74 |
// Firebase config
|
| 75 |
const firebaseConfig = {
|
|
@@ -84,16 +81,17 @@
|
|
| 84 |
const db = getFirestore(app);
|
| 85 |
const auth = getAuth(app);
|
| 86 |
|
|
|
|
| 87 |
enableIndexedDbPersistence(db)
|
| 88 |
.then(() => console.log("Firebase offline persistence enabled"))
|
| 89 |
.catch(err => {
|
| 90 |
-
if (err.code === 'failed-precondition')
|
| 91 |
-
|
| 92 |
-
} else if (err.code === 'unimplemented') {
|
| 93 |
-
console.warn("Persistence is not available in this browser.");
|
| 94 |
-
}
|
| 95 |
});
|
| 96 |
|
|
|
|
|
|
|
|
|
|
| 97 |
// DOM elements
|
| 98 |
const loginContainer = document.getElementById('login-container');
|
| 99 |
const mainContent = document.getElementById('main-content');
|
|
@@ -135,15 +133,18 @@
|
|
| 135 |
}
|
| 136 |
});
|
| 137 |
|
|
|
|
| 138 |
onAuthStateChanged(auth, user => {
|
| 139 |
if (user) {
|
| 140 |
console.log("Logged in as", user.email);
|
| 141 |
-
loginContainer.
|
|
|
|
| 142 |
mainContent.classList.remove('hidden');
|
| 143 |
footerInput.classList.remove('hidden');
|
| 144 |
loadItems(currentTab);
|
| 145 |
} else {
|
| 146 |
-
loginContainer.
|
|
|
|
| 147 |
mainContent.classList.add('hidden');
|
| 148 |
footerInput.classList.add('hidden');
|
| 149 |
}
|
|
|
|
| 30 |
</header>
|
| 31 |
|
| 32 |
<!-- Login Form -->
|
| 33 |
+
<div id="login-container" class="max-w-md mx-auto p-4 mt-4 bg-white dark:bg-gray-800 rounded-lg shadow-md invisible">
|
| 34 |
<input id="email" type="email" placeholder="Email" class="w-full p-3 mb-2 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none" />
|
| 35 |
<input id="password" type="password" placeholder="Password" class="w-full p-3 mb-2 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none" />
|
| 36 |
<button id="login-btn" class="w-full py-3 bg-blue-500 text-white rounded-lg hover:opacity-90 transition">Login</button>
|
|
|
|
| 65 |
<!-- Firebase & Script -->
|
| 66 |
<script type="module">
|
| 67 |
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
|
| 68 |
+
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp, orderBy, doc, deleteDoc, updateDoc, where, query, enableIndexedDbPersistence } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
|
| 69 |
+
import { getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword, onAuthStateChanged, setPersistence, browserLocalPersistence } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
// Firebase config
|
| 72 |
const firebaseConfig = {
|
|
|
|
| 81 |
const db = getFirestore(app);
|
| 82 |
const auth = getAuth(app);
|
| 83 |
|
| 84 |
+
// Enable offline persistence
|
| 85 |
enableIndexedDbPersistence(db)
|
| 86 |
.then(() => console.log("Firebase offline persistence enabled"))
|
| 87 |
.catch(err => {
|
| 88 |
+
if (err.code === 'failed-precondition') console.warn("Multiple tabs open, persistence only in one tab.");
|
| 89 |
+
else if (err.code === 'unimplemented') console.warn("Persistence not available in this browser.");
|
|
|
|
|
|
|
|
|
|
| 90 |
});
|
| 91 |
|
| 92 |
+
// Ensure Auth persistence (remember me)
|
| 93 |
+
setPersistence(auth, browserLocalPersistence).catch(err => console.error("Persistence error:", err));
|
| 94 |
+
|
| 95 |
// DOM elements
|
| 96 |
const loginContainer = document.getElementById('login-container');
|
| 97 |
const mainContent = document.getElementById('main-content');
|
|
|
|
| 133 |
}
|
| 134 |
});
|
| 135 |
|
| 136 |
+
// Auth state handling (no flashing)
|
| 137 |
onAuthStateChanged(auth, user => {
|
| 138 |
if (user) {
|
| 139 |
console.log("Logged in as", user.email);
|
| 140 |
+
loginContainer.classList.add('hidden');
|
| 141 |
+
loginContainer.classList.remove('invisible');
|
| 142 |
mainContent.classList.remove('hidden');
|
| 143 |
footerInput.classList.remove('hidden');
|
| 144 |
loadItems(currentTab);
|
| 145 |
} else {
|
| 146 |
+
loginContainer.classList.remove('hidden');
|
| 147 |
+
loginContainer.classList.remove('invisible');
|
| 148 |
mainContent.classList.add('hidden');
|
| 149 |
footerInput.classList.add('hidden');
|
| 150 |
}
|