when note is added, should have checkbox is is done or not, also should stay remembered, not to dissapier when refresh page - Follow Up Deployment
Browse files- index.html +133 -292
index.html
CHANGED
|
@@ -1,306 +1,147 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en" class="dark">
|
| 3 |
<head>
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
<!-- Firebase SDK -->
|
| 11 |
-
<script src="https://www.gstatic.com/firebasejs/9.6.0/firebase-app-compat.js"></script>
|
| 12 |
-
<script src="https://www.gstatic.com/firebasejs/9.6.0/firebase-firestore-compat.js"></script>
|
| 13 |
-
|
| 14 |
-
<!-- Tailwind -->
|
| 15 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 16 |
-
|
| 17 |
-
<!-- Feather Icons -->
|
| 18 |
-
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 19 |
-
|
| 20 |
-
<script>
|
| 21 |
-
tailwind.config = {
|
| 22 |
-
darkMode: 'class',
|
| 23 |
-
theme: {
|
| 24 |
-
extend: {
|
| 25 |
-
colors: {
|
| 26 |
-
primary: {
|
| 27 |
-
50: '#f0f9ff',
|
| 28 |
-
100: '#e0f2fe',
|
| 29 |
-
500: '#3b82f6',
|
| 30 |
-
600: '#2563eb',
|
| 31 |
-
700: '#1d4ed8',
|
| 32 |
-
}
|
| 33 |
-
}
|
| 34 |
-
}
|
| 35 |
-
}
|
| 36 |
-
}
|
| 37 |
-
</script>
|
| 38 |
-
<style>
|
| 39 |
-
.note-item:hover .delete-btn {
|
| 40 |
-
opacity: 1;
|
| 41 |
-
}
|
| 42 |
-
</style>
|
| 43 |
</head>
|
| 44 |
-
<body class="bg-gray-100 dark:bg-gray-900 min-h-screen
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
<
|
| 56 |
-
|
| 57 |
-
<div class="flex gap-2">
|
| 58 |
-
<input
|
| 59 |
-
id="note-input"
|
| 60 |
-
type="text"
|
| 61 |
-
placeholder="Add a new note..."
|
| 62 |
-
class="flex-1 px-4 py-3 text-lg border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 dark:bg-gray-700 dark:text-white"
|
| 63 |
-
autocapitalize="sentences"
|
| 64 |
-
autocomplete="off"
|
| 65 |
-
>
|
| 66 |
-
<button
|
| 67 |
-
id="add-btn"
|
| 68 |
-
class="px-4 py-3 text-lg bg-primary-500 hover:bg-primary-600 text-white rounded-lg transition-colors duration-200 flex items-center gap-2"
|
| 69 |
-
>
|
| 70 |
-
<i data-feather="plus"></i> Add
|
| 71 |
-
</button>
|
| 72 |
-
</div>
|
| 73 |
-
</div>
|
| 74 |
-
|
| 75 |
-
<!-- Notes List -->
|
| 76 |
-
<div class="bg-white dark:bg-gray-800 rounded-lg shadow-md p-6 transition-colors duration-300">
|
| 77 |
-
<h2 class="text-xl font-semibold mb-4 text-gray-800 dark:text-white">Our Notes</h2>
|
| 78 |
-
<ul id="notes-list" class="space-y-3">
|
| 79 |
-
<!-- Notes will be added here dynamically -->
|
| 80 |
-
</ul>
|
| 81 |
-
</div>
|
| 82 |
-
|
| 83 |
-
<!-- User Status -->
|
| 84 |
-
<div class="mt-6 text-sm text-gray-500 dark:text-gray-400 flex items-center gap-2">
|
| 85 |
-
<span id="connection-status" class="flex items-center gap-1">
|
| 86 |
-
<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span>
|
| 87 |
-
<span>Connected</span>
|
| 88 |
-
</span>
|
| 89 |
-
<span>•</span>
|
| 90 |
-
<span id="last-sync">Last synced: Just now</span>
|
| 91 |
-
</div>
|
| 92 |
</div>
|
| 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 |
-
const
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
const noteInput = document.getElementById('note-input');
|
| 136 |
-
const addBtn = document.getElementById('add-btn');
|
| 137 |
-
const notesList = document.getElementById('notes-list');
|
| 138 |
-
const lastSyncEl = document.getElementById('last-sync');
|
| 139 |
-
|
| 140 |
-
// Render notes
|
| 141 |
-
function renderNotes() {
|
| 142 |
-
notesList.innerHTML = '';
|
| 143 |
-
notes.forEach((note) => {
|
| 144 |
-
const li = document.createElement('li');
|
| 145 |
-
li.className = 'note-item group flex items-center justify-between p-4 text-lg bg-gray-50 dark:bg-gray-700 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-600 transition-colors duration-200';
|
| 146 |
-
li.innerHTML = `
|
| 147 |
-
<div class="flex items-center gap-3 flex-1">
|
| 148 |
-
<input type="checkbox" data-id="${note.id}" class="done-checkbox w-5 h-5 text-primary-500 rounded focus:ring-primary-500"
|
| 149 |
-
${note.done ? 'checked' : ''}>
|
| 150 |
-
<span class="note-text ${note.done ? 'line-through text-gray-400 dark:text-gray-500' : 'text-gray-800 dark:text-gray-200'}">
|
| 151 |
-
${note.text}
|
| 152 |
-
</span>
|
| 153 |
-
</div>
|
| 154 |
-
<button
|
| 155 |
-
data-id="${note.id}"
|
| 156 |
-
class="delete-btn opacity-0 group-hover:opacity-100 text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-opacity duration-200"
|
| 157 |
-
>
|
| 158 |
-
<i data-feather="trash-2" class="w-4 h-4"></i>
|
| 159 |
-
</button>
|
| 160 |
-
`;
|
| 161 |
-
notesList.appendChild(li);
|
| 162 |
});
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
// Subscribe to real-time updates
|
| 167 |
-
function subscribeToNotes() {
|
| 168 |
-
unsubscribe = db.collection('notes')
|
| 169 |
-
.orderBy('createdAt', 'desc')
|
| 170 |
-
.onSnapshot((snapshot) => {
|
| 171 |
-
notes = [];
|
| 172 |
-
snapshot.forEach((doc) => {
|
| 173 |
-
notes.push({
|
| 174 |
-
id: doc.id,
|
| 175 |
-
text: doc.data().text,
|
| 176 |
-
done: doc.data().done || false,
|
| 177 |
-
createdAt: doc.data().createdAt || new Date()
|
| 178 |
-
});
|
| 179 |
-
});
|
| 180 |
-
lastSync = new Date();
|
| 181 |
-
updateSyncTime();
|
| 182 |
-
renderNotes();
|
| 183 |
-
}, (error) => {
|
| 184 |
-
console.error("Error getting notes:", error);
|
| 185 |
-
setDisconnected();
|
| 186 |
-
});
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
// Add new note
|
| 190 |
-
function addNote() {
|
| 191 |
-
const text = noteInput.value.trim();
|
| 192 |
-
if (text) {
|
| 193 |
-
db.collection('notes').add({
|
| 194 |
-
text: text,
|
| 195 |
-
done: false,
|
| 196 |
-
createdAt: firebase.firestore.FieldValue.serverTimestamp()
|
| 197 |
-
})
|
| 198 |
-
.then(() => {
|
| 199 |
-
noteInput.value = '';
|
| 200 |
-
lastSync = new Date();
|
| 201 |
-
updateSyncTime();
|
| 202 |
-
})
|
| 203 |
-
.catch((error) => {
|
| 204 |
-
console.error("Error adding note:", error);
|
| 205 |
-
});
|
| 206 |
-
}
|
| 207 |
-
}
|
| 208 |
-
|
| 209 |
-
// Delete note
|
| 210 |
-
function deleteNote(id) {
|
| 211 |
-
db.collection('notes').doc(id).delete()
|
| 212 |
-
.then(() => {
|
| 213 |
-
lastSync = new Date();
|
| 214 |
-
updateSyncTime();
|
| 215 |
-
})
|
| 216 |
-
.catch((error) => {
|
| 217 |
-
console.error("Error deleting note:", error);
|
| 218 |
-
});
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
// Toggle "done" state
|
| 222 |
-
function toggleDone(id, checked) {
|
| 223 |
-
db.collection('notes').doc(id).update({ done: checked })
|
| 224 |
-
.then(() => {
|
| 225 |
-
lastSync = new Date();
|
| 226 |
-
updateSyncTime();
|
| 227 |
-
})
|
| 228 |
-
.catch((error) => {
|
| 229 |
-
console.error("Error updating note:", error);
|
| 230 |
-
});
|
| 231 |
-
}
|
| 232 |
-
|
| 233 |
-
// Update sync time display
|
| 234 |
-
function updateSyncTime() {
|
| 235 |
-
lastSyncEl.textContent = `Last synced: ${formatTime(lastSync)}`;
|
| 236 |
-
}
|
| 237 |
-
|
| 238 |
-
// Format time
|
| 239 |
-
function formatTime(date) {
|
| 240 |
-
const diff = (new Date() - date) / 1000;
|
| 241 |
-
if (diff < 60) return 'Just now';
|
| 242 |
-
if (diff < 3600) return `${Math.floor(diff / 60)} minutes ago`;
|
| 243 |
-
if (diff < 86400) return `${Math.floor(diff / 3600)} hours ago`;
|
| 244 |
-
return date.toLocaleString();
|
| 245 |
-
}
|
| 246 |
-
|
| 247 |
-
// Connection indicator helpers
|
| 248 |
-
function setConnected() {
|
| 249 |
-
document.getElementById('connection-status').innerHTML = `
|
| 250 |
-
<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span>
|
| 251 |
-
<span>Connected</span>
|
| 252 |
-
`;
|
| 253 |
-
}
|
| 254 |
-
function setDisconnected() {
|
| 255 |
-
document.getElementById('connection-status').innerHTML = `
|
| 256 |
-
<span class="w-2 h-2 rounded-full bg-red-500"></span>
|
| 257 |
-
<span>Disconnected</span>
|
| 258 |
-
`;
|
| 259 |
-
}
|
| 260 |
-
|
| 261 |
-
// Event listeners
|
| 262 |
-
addBtn.addEventListener('click', addNote);
|
| 263 |
-
noteInput.addEventListener('keypress', (e) => {
|
| 264 |
-
if (e.key === 'Enter') addNote();
|
| 265 |
-
});
|
| 266 |
-
|
| 267 |
-
notesList.addEventListener('click', (e) => {
|
| 268 |
-
if (e.target.closest('.delete-btn')) {
|
| 269 |
-
const id = e.target.closest('.delete-btn').dataset.id;
|
| 270 |
-
deleteNote(id);
|
| 271 |
-
}
|
| 272 |
});
|
| 273 |
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
|
|
|
|
|
|
| 279 |
});
|
| 280 |
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
|
|
|
| 284 |
|
| 285 |
-
|
| 286 |
-
window.addEventListener('beforeunload', () => {
|
| 287 |
-
if (unsubscribe) unsubscribe();
|
| 288 |
-
});
|
| 289 |
-
|
| 290 |
-
// Initialize app
|
| 291 |
-
function initApp() {
|
| 292 |
-
subscribeToNotes();
|
| 293 |
-
updateSyncTime();
|
| 294 |
-
firebase.firestore().enableNetwork().then(setConnected).catch(setDisconnected);
|
| 295 |
-
}
|
| 296 |
-
|
| 297 |
-
initApp();
|
| 298 |
-
|
| 299 |
-
// Touch feedback for buttons
|
| 300 |
-
document.querySelectorAll('button').forEach(btn => {
|
| 301 |
-
btn.addEventListener('touchstart', () => btn.classList.add('opacity-80'));
|
| 302 |
-
btn.addEventListener('touchend', () => btn.classList.remove('opacity-80'));
|
| 303 |
-
});
|
| 304 |
-
</script>
|
| 305 |
</body>
|
| 306 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en" class="dark">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
| 6 |
+
<title>Shared Notes App</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
</head>
|
| 10 |
+
<body class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 min-h-screen flex flex-col">
|
| 11 |
+
|
| 12 |
+
<!-- Header -->
|
| 13 |
+
<header class="p-4 bg-white dark:bg-gray-800 shadow flex justify-between items-center">
|
| 14 |
+
<h1 class="text-xl font-bold">Shared Notes</h1>
|
| 15 |
+
<div class="flex items-center gap-4">
|
| 16 |
+
<span id="connection-status" class="flex items-center gap-1 text-sm">
|
| 17 |
+
<span class="w-2 h-2 rounded-full bg-gray-400"></span>
|
| 18 |
+
Connecting...
|
| 19 |
+
</span>
|
| 20 |
+
<button id="toggle-dark" class="p-2 rounded-full bg-gray-200 dark:bg-gray-700">
|
| 21 |
+
<i data-feather="moon"></i>
|
| 22 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
</div>
|
| 24 |
+
</header>
|
| 25 |
+
|
| 26 |
+
<!-- Notes List -->
|
| 27 |
+
<main class="flex-1 p-4">
|
| 28 |
+
<ul id="notes-list" class="space-y-2"></ul>
|
| 29 |
+
</main>
|
| 30 |
+
|
| 31 |
+
<!-- Input -->
|
| 32 |
+
<footer class="p-4 bg-white dark:bg-gray-800 shadow flex">
|
| 33 |
+
<input id="note-input" type="text" placeholder="Write a note..."
|
| 34 |
+
class="flex-1 p-2 rounded-l bg-gray-100 dark:bg-gray-700 border-none outline-none" />
|
| 35 |
+
<button id="add-note" class="px-4 bg-blue-500 text-white rounded-r">Add</button>
|
| 36 |
+
</footer>
|
| 37 |
+
|
| 38 |
+
<!-- Firebase + App -->
|
| 39 |
+
<script type="module">
|
| 40 |
+
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
|
| 41 |
+
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp, orderBy, query, doc, deleteDoc, updateDoc }
|
| 42 |
+
from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
|
| 43 |
+
|
| 44 |
+
// 🔧 Your Firebase config
|
| 45 |
+
const firebaseConfig = {
|
| 46 |
+
apiKey: "YOUR_API_KEY",
|
| 47 |
+
authDomain: "YOUR_AUTH_DOMAIN",
|
| 48 |
+
projectId: "YOUR_PROJECT_ID",
|
| 49 |
+
storageBucket: "YOUR_STORAGE_BUCKET",
|
| 50 |
+
messagingSenderId: "YOUR_SENDER_ID",
|
| 51 |
+
appId: "YOUR_APP_ID"
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
const app = initializeApp(firebaseConfig);
|
| 55 |
+
const db = getFirestore(app);
|
| 56 |
+
|
| 57 |
+
// DOM Elements
|
| 58 |
+
const notesList = document.getElementById('notes-list');
|
| 59 |
+
const noteInput = document.getElementById('note-input');
|
| 60 |
+
const addNoteBtn = document.getElementById('add-note');
|
| 61 |
+
const toggleDarkBtn = document.getElementById('toggle-dark');
|
| 62 |
+
const connectionStatus = document.getElementById('connection-status');
|
| 63 |
+
|
| 64 |
+
// 🌓 Dark mode toggle
|
| 65 |
+
toggleDarkBtn.addEventListener('click', () => {
|
| 66 |
+
document.documentElement.classList.toggle('dark');
|
| 67 |
+
localStorage.setItem('dark-mode', document.documentElement.classList.contains('dark'));
|
| 68 |
+
});
|
| 69 |
+
if (localStorage.getItem('dark-mode') === 'true') {
|
| 70 |
+
document.documentElement.classList.add('dark');
|
| 71 |
+
} else {
|
| 72 |
+
document.documentElement.classList.remove('dark');
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// 📡 Connection indicator
|
| 76 |
+
function setStatus(online) {
|
| 77 |
+
connectionStatus.innerHTML = online
|
| 78 |
+
? `<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span><span>Connected</span>`
|
| 79 |
+
: `<span class="w-2 h-2 rounded-full bg-red-500"></span><span>Offline</span>`;
|
| 80 |
+
}
|
| 81 |
+
window.addEventListener("online", () => setStatus(true));
|
| 82 |
+
window.addEventListener("offline", () => setStatus(false));
|
| 83 |
+
setStatus(navigator.onLine);
|
| 84 |
+
|
| 85 |
+
// ➕ Add note
|
| 86 |
+
addNoteBtn.addEventListener('click', async () => {
|
| 87 |
+
const text = noteInput.value.trim();
|
| 88 |
+
if (!text) return;
|
| 89 |
+
try {
|
| 90 |
+
await addDoc(collection(db, "notes"), {
|
| 91 |
+
text,
|
| 92 |
+
done: false,
|
| 93 |
+
createdAt: serverTimestamp()
|
| 94 |
});
|
| 95 |
+
noteInput.value = '';
|
| 96 |
+
} catch (err) {
|
| 97 |
+
console.error("Error adding note:", err);
|
| 98 |
+
}
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
// 🔄 Live notes from Firestore
|
| 102 |
+
const q = query(collection(db, "notes"), orderBy("createdAt", "asc"));
|
| 103 |
+
onSnapshot(q, (snapshot) => {
|
| 104 |
+
notesList.innerHTML = "";
|
| 105 |
+
snapshot.forEach((docSnap) => {
|
| 106 |
+
const note = { id: docSnap.id, ...docSnap.data() };
|
| 107 |
+
const li = document.createElement("li");
|
| 108 |
+
li.className = "note-item flex items-center justify-between p-2 bg-gray-200 dark:bg-gray-700 rounded group";
|
| 109 |
+
|
| 110 |
+
li.innerHTML = `
|
| 111 |
+
<div class="flex items-center flex-1">
|
| 112 |
+
<input type="checkbox" class="done-checkbox mr-2" ${note.done ? "checked" : ""}>
|
| 113 |
+
<span class="note-text ${note.done ? "line-through text-gray-400" : ""}">${note.text}</span>
|
| 114 |
+
</div>
|
| 115 |
+
<button class="delete-btn text-red-500 opacity-0 group-hover:opacity-100 transition">
|
| 116 |
+
<i data-feather="trash-2"></i>
|
| 117 |
+
</button>
|
| 118 |
+
`;
|
| 119 |
+
|
| 120 |
+
// ✅ Checkbox toggle
|
| 121 |
+
li.querySelector(".done-checkbox").addEventListener("change", async (e) => {
|
| 122 |
+
try {
|
| 123 |
+
await updateDoc(doc(db, "notes", note.id), {
|
| 124 |
+
done: e.target.checked
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
});
|
| 126 |
+
} catch (err) {
|
| 127 |
+
console.error("Error updating note:", err);
|
| 128 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
});
|
| 130 |
|
| 131 |
+
// 🗑️ Delete note
|
| 132 |
+
li.querySelector(".delete-btn").addEventListener("click", async () => {
|
| 133 |
+
try {
|
| 134 |
+
await deleteDoc(doc(db, "notes", note.id));
|
| 135 |
+
} catch (err) {
|
| 136 |
+
console.error("Error deleting note:", err);
|
| 137 |
+
}
|
| 138 |
});
|
| 139 |
|
| 140 |
+
notesList.appendChild(li);
|
| 141 |
+
});
|
| 142 |
+
feather.replace();
|
| 143 |
+
});
|
| 144 |
|
| 145 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
</body>
|
| 147 |
</html>
|