remove calendar dates notes - remain simple as it is for tasks only - Follow Up Deployment
Browse files- index.html +38 -231
- prompts.txt +3 -1
index.html
CHANGED
|
@@ -3,74 +3,26 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" />
|
| 6 |
-
<title>Shared
|
| 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-md flex
|
| 14 |
-
<
|
| 15 |
-
|
| 16 |
-
<
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<span>Connecting...</span>
|
| 20 |
-
</span>
|
| 21 |
-
</div>
|
| 22 |
-
</div>
|
| 23 |
-
<div class="flex mt-4 border-b border-gray-200 dark:border-gray-700">
|
| 24 |
-
<button id="tasks-tab" class="tab-button active px-4 py-2 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-500">Tasks</button>
|
| 25 |
-
<button id="calendar-tab" class="tab-button px-4 py-2 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Calendar Notes</button>
|
| 26 |
-
</div>
|
| 27 |
</header>
|
| 28 |
|
| 29 |
-
<!--
|
| 30 |
<main class="flex-1 p-4 max-w-2xl w-full mx-auto">
|
| 31 |
-
<
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
</div>
|
| 35 |
-
|
| 36 |
-
<!-- Calendar Notes Section -->
|
| 37 |
-
<div id="calendar-section" class="tab-content hidden">
|
| 38 |
-
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-4 mb-4">
|
| 39 |
-
<div id="calendar-header" class="flex justify-between items-center mb-4">
|
| 40 |
-
<h2 class="text-xl font-semibold" id="current-month"></h2>
|
| 41 |
-
<div class="flex gap-2">
|
| 42 |
-
<button id="prev-month" class="p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700">
|
| 43 |
-
<i data-feather="chevron-left"></i>
|
| 44 |
-
</button>
|
| 45 |
-
<button id="next-month" class="p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-700">
|
| 46 |
-
<i data-feather="chevron-right"></i>
|
| 47 |
-
</button>
|
| 48 |
-
</div>
|
| 49 |
-
</div>
|
| 50 |
-
<div id="calendar-days-header" class="grid grid-cols-7 gap-1 mb-2 text-center font-medium">
|
| 51 |
-
<div class="p-2">Mon</div>
|
| 52 |
-
<div class="p-2">Tue</div>
|
| 53 |
-
<div class="p-2">Wed</div>
|
| 54 |
-
<div class="p-2">Thu</div>
|
| 55 |
-
<div class="p-2">Fri</div>
|
| 56 |
-
<div class="p-2">Sat</div>
|
| 57 |
-
<div class="p-2">Sun</div>
|
| 58 |
-
</div>
|
| 59 |
-
<div id="calendar-grid" class="grid grid-cols-7 gap-1"></div>
|
| 60 |
-
</div>
|
| 61 |
-
<div id="calendar-notes-container" class="bg-white dark:bg-gray-800 rounded-lg shadow p-4">
|
| 62 |
-
<h3 class="text-lg font-semibold mb-4" id="selected-date-title">No date selected</h3>
|
| 63 |
-
<ul id="calendar-notes-list" class="space-y-3 mb-4"></ul>
|
| 64 |
-
<div class="flex mt-4" id="calendar-note-input-container">
|
| 65 |
-
<input id="calendar-note-input" type="text" placeholder="Add note for this date..."
|
| 66 |
-
class="flex-1 p-3 rounded-l-lg bg-gray-100 dark:bg-gray-700 border-none outline-none focus:ring-2 focus:ring-blue-500 transition text-base"
|
| 67 |
-
autocomplete="off" autocorrect="off" spellcheck="false" />
|
| 68 |
-
<button id="add-calendar-note" class="px-6 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-r-lg hover:opacity-90 transition active:scale-95">
|
| 69 |
-
<i data-feather="plus" class="w-5 h-5"></i>
|
| 70 |
-
</button>
|
| 71 |
-
</div>
|
| 72 |
-
</div>
|
| 73 |
-
</div>
|
| 74 |
</main>
|
| 75 |
|
| 76 |
<!-- Input -->
|
|
@@ -81,102 +33,18 @@
|
|
| 81 |
class="flex-1 p-3 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none focus:ring-2 focus:ring-blue-500 transition text-base"
|
| 82 |
autocomplete="name" autocorrect="off" spellcheck="false" />
|
| 83 |
</div>
|
| 84 |
-
<div class="flex
|
| 85 |
-
<
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
<
|
| 90 |
-
|
| 91 |
-
</button>
|
| 92 |
-
</div>
|
| 93 |
-
<div class="flex items-center gap-2">
|
| 94 |
-
<label class="text-sm text-gray-500 dark:text-gray-400">Date:</label>
|
| 95 |
-
<input id="task-date" type="date"
|
| 96 |
-
class="p-2 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none focus:ring-2 focus:ring-blue-500 transition text-sm" />
|
| 97 |
-
</div>
|
| 98 |
</div>
|
| 99 |
</div>
|
| 100 |
</footer>
|
| 101 |
|
| 102 |
-
<!--
|
| 103 |
-
<script>
|
| 104 |
-
const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
|
| 105 |
-
|
| 106 |
-
document.querySelectorAll('.tab-button').forEach(button => {
|
| 107 |
-
button.addEventListener('click', () => {
|
| 108 |
-
document.querySelectorAll('.tab-button').forEach(btn => {
|
| 109 |
-
btn.classList.remove('active','text-blue-600','dark:text-blue-400','border-blue-500');
|
| 110 |
-
btn.classList.add('text-gray-500','dark:text-gray-400');
|
| 111 |
-
});
|
| 112 |
-
button.classList.add('active','text-blue-600','dark:text-blue-400','border-blue-500');
|
| 113 |
-
button.classList.remove('text-gray-500','dark:text-gray-400');
|
| 114 |
-
|
| 115 |
-
document.querySelectorAll('.tab-content').forEach(content => {
|
| 116 |
-
content.classList.add('hidden');
|
| 117 |
-
content.classList.remove('active');
|
| 118 |
-
});
|
| 119 |
-
const sectionId = `${button.id.split('-')[0]}-section`;
|
| 120 |
-
document.getElementById(sectionId).classList.remove('hidden');
|
| 121 |
-
document.getElementById(sectionId).classList.add('active');
|
| 122 |
-
|
| 123 |
-
if (sectionId === 'calendar-section' && !window.calendarInitialized) {
|
| 124 |
-
initCalendar();
|
| 125 |
-
window.calendarInitialized = true;
|
| 126 |
-
}
|
| 127 |
-
});
|
| 128 |
-
});
|
| 129 |
-
|
| 130 |
-
function initCalendar() {
|
| 131 |
-
let currentDate = new Date();
|
| 132 |
-
|
| 133 |
-
function renderCalendar() {
|
| 134 |
-
const year = currentDate.getFullYear();
|
| 135 |
-
const month = currentDate.getMonth();
|
| 136 |
-
document.getElementById('current-month').textContent = `${months[month]} ${year}`;
|
| 137 |
-
|
| 138 |
-
// Start on Monday
|
| 139 |
-
const firstDayOfMonth = new Date(year, month, 1);
|
| 140 |
-
let firstDay = firstDayOfMonth.getDay(); // Sunday=0
|
| 141 |
-
firstDay = firstDay === 0 ? 6 : firstDay - 1; // Adjust Sunday to 6, Mon=0
|
| 142 |
-
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
| 143 |
-
|
| 144 |
-
const calendarGrid = document.getElementById('calendar-grid');
|
| 145 |
-
calendarGrid.innerHTML = '';
|
| 146 |
-
|
| 147 |
-
for (let i = 0; i < firstDay; i++) {
|
| 148 |
-
const cell = document.createElement('div');
|
| 149 |
-
cell.className = 'p-2 h-12 opacity-50';
|
| 150 |
-
calendarGrid.appendChild(cell);
|
| 151 |
-
}
|
| 152 |
-
|
| 153 |
-
const todayStr = new Date().toISOString().split('T')[0];
|
| 154 |
-
|
| 155 |
-
for (let day = 1; day <= daysInMonth; day++) {
|
| 156 |
-
const cell = document.createElement('div');
|
| 157 |
-
cell.className = 'p-2 h-12 border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer flex items-center justify-center';
|
| 158 |
-
cell.textContent = day;
|
| 159 |
-
const dayDateStr = `${year}-${(month+1).toString().padStart(2,'0')}-${day.toString().padStart(2,'0')}`;
|
| 160 |
-
cell.dataset.date = dayDateStr;
|
| 161 |
-
|
| 162 |
-
if (dayDateStr === todayStr) cell.classList.add('bg-blue-200','dark:bg-blue-900','font-semibold'); // today
|
| 163 |
-
else if (dayDateStr > todayStr) cell.classList.add('opacity-70'); // future
|
| 164 |
-
else cell.classList.add('opacity-90'); // past
|
| 165 |
-
|
| 166 |
-
cell.addEventListener('click', () => loadDateNotes(dayDateStr));
|
| 167 |
-
calendarGrid.appendChild(cell);
|
| 168 |
-
}
|
| 169 |
-
}
|
| 170 |
-
|
| 171 |
-
document.getElementById('prev-month').addEventListener('click', () => { currentDate.setMonth(currentDate.getMonth()-1); renderCalendar(); });
|
| 172 |
-
document.getElementById('next-month').addEventListener('click', () => { currentDate.setMonth(currentDate.getMonth()+1); renderCalendar(); });
|
| 173 |
-
|
| 174 |
-
renderCalendar();
|
| 175 |
-
feather.replace();
|
| 176 |
-
}
|
| 177 |
-
</script>
|
| 178 |
-
|
| 179 |
-
<!-- Firebase -->
|
| 180 |
<script type="module">
|
| 181 |
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
|
| 182 |
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp, orderBy, query, doc, deleteDoc, updateDoc, where }
|
|
@@ -194,10 +62,6 @@
|
|
| 194 |
const app = initializeApp(firebaseConfig);
|
| 195 |
const db = getFirestore(app);
|
| 196 |
|
| 197 |
-
// Globals for calendar
|
| 198 |
-
window.selectedDateStr = null;
|
| 199 |
-
window.unsubscribeCalendar = null;
|
| 200 |
-
|
| 201 |
const tasksList = document.getElementById('tasks-list');
|
| 202 |
const noteInput = document.getElementById('note-input');
|
| 203 |
const addNoteBtn = document.getElementById('add-note');
|
|
@@ -205,6 +69,7 @@
|
|
| 205 |
const nameInputContainer = document.getElementById('name-input-container');
|
| 206 |
const userNameInput = document.getElementById('user-name');
|
| 207 |
|
|
|
|
| 208 |
const storedName = localStorage.getItem('sharedNotesUserName');
|
| 209 |
if (storedName) {
|
| 210 |
nameInputContainer.style.display = 'none';
|
|
@@ -217,6 +82,7 @@
|
|
| 217 |
});
|
| 218 |
}
|
| 219 |
|
|
|
|
| 220 |
function setStatus(online) {
|
| 221 |
connectionStatus.innerHTML = online
|
| 222 |
? `<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span><span>Connected</span>`
|
|
@@ -226,66 +92,36 @@
|
|
| 226 |
window.addEventListener("offline", () => setStatus(false));
|
| 227 |
setStatus(navigator.onLine);
|
| 228 |
|
| 229 |
-
//
|
| 230 |
-
document.getElementById('add-calendar-note').addEventListener('click', addCalendarNote);
|
| 231 |
-
document.getElementById('calendar-note-input').addEventListener('keypress', (e) => {
|
| 232 |
-
if (e.key === 'Enter') addCalendarNote();
|
| 233 |
-
});
|
| 234 |
-
|
| 235 |
-
async function addCalendarNote() {
|
| 236 |
-
const text = document.getElementById('calendar-note-input').value.trim();
|
| 237 |
-
const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
|
| 238 |
-
if (!text || !userName || !window.selectedDateStr) return;
|
| 239 |
-
|
| 240 |
-
try {
|
| 241 |
-
await addDoc(collection(db, "notes"), {
|
| 242 |
-
text,
|
| 243 |
-
userName,
|
| 244 |
-
createdAt: serverTimestamp(),
|
| 245 |
-
date: window.selectedDateStr,
|
| 246 |
-
type: 'calendar'
|
| 247 |
-
});
|
| 248 |
-
document.getElementById('calendar-note-input').value = '';
|
| 249 |
-
} catch (err) {
|
| 250 |
-
console.error("Error adding calendar note:", err);
|
| 251 |
-
alert("Failed to add note.");
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
|
| 255 |
async function addNote() {
|
| 256 |
const text = noteInput.value.trim();
|
| 257 |
const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
|
| 258 |
if (!text || !userName) return;
|
| 259 |
|
| 260 |
-
const currentDate = new Date();
|
| 261 |
-
const dateStr = `${currentDate.getFullYear()}-${(currentDate.getMonth()+1).toString().padStart(2,'0')}-${currentDate.getDate().toString().padStart(2,'0')}`;
|
| 262 |
-
|
| 263 |
try {
|
| 264 |
await addDoc(collection(db, "notes"), {
|
| 265 |
text,
|
| 266 |
userName,
|
| 267 |
createdAt: serverTimestamp(),
|
| 268 |
-
date: dateStr,
|
| 269 |
type: 'tasks',
|
| 270 |
done: false
|
| 271 |
});
|
| 272 |
noteInput.value = '';
|
| 273 |
} catch (err) {
|
| 274 |
-
console.error("Error adding
|
| 275 |
-
alert("Failed to add
|
| 276 |
}
|
| 277 |
}
|
| 278 |
-
|
| 279 |
addNoteBtn.addEventListener('click', addNote);
|
| 280 |
noteInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') addNote(); });
|
| 281 |
|
| 282 |
-
function renderNoteItem(note
|
| 283 |
const li = document.createElement("li");
|
| 284 |
li.className = "note-item flex items-center justify-between p-4 bg-white dark:bg-gray-800 rounded-lg shadow-sm hover:shadow-md transition-all group";
|
| 285 |
li.innerHTML = `
|
| 286 |
<div class="flex items-center flex-1">
|
| 287 |
-
|
| 288 |
-
<div class="
|
| 289 |
<span class="note-text ${note.done ? "line-through text-gray-400 dark:text-gray-500" : ""}">${note.text}</span>
|
| 290 |
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">Added by ${note.userName || 'Anonymous'}</div>
|
| 291 |
</div>
|
|
@@ -293,61 +129,32 @@
|
|
| 293 |
<button class="delete-btn p-2 text-red-500 hover:bg-red-50 dark:hover:bg-gray-700 rounded-full opacity-100 md:opacity-0 md:group-hover:opacity-100 transition active:scale-95">
|
| 294 |
<i data-feather="trash-2" class="w-4 h-4"></i>
|
| 295 |
</button>`;
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
}
|
| 302 |
li.querySelector(".delete-btn").addEventListener("click", async () => {
|
| 303 |
try { await deleteDoc(doc(db, "notes", note.id)); }
|
| 304 |
-
catch (err) { console.error("Error deleting
|
| 305 |
});
|
| 306 |
-
|
| 307 |
}
|
| 308 |
|
| 309 |
-
//
|
| 310 |
const tasksQuery = query(collection(db, "notes"), where("type","==","tasks"), orderBy("createdAt","asc"));
|
| 311 |
tasksList.innerHTML = '<div class="text-center py-8"><div class="inline-block animate-spin h-8 w-8 border-t-2 border-b-2 border-blue-500 rounded-full"></div><p class="mt-2 text-gray-500">Loading tasks...</p></div>';
|
| 312 |
-
|
| 313 |
tasksList.innerHTML = "";
|
| 314 |
if (snapshot.empty) {
|
| 315 |
tasksList.innerHTML = '<div class="text-center py-8"><i data-feather="check-circle" class="w-12 h-12 mx-auto text-gray-400"></i><p class="mt-2 text-gray-500">No tasks yet.</p></div>';
|
| 316 |
feather.replace();
|
| 317 |
return;
|
| 318 |
}
|
| 319 |
-
snapshot.forEach(docSnap => renderNoteItem({ id: docSnap.id, ...docSnap.data() }
|
| 320 |
feather.replace();
|
| 321 |
});
|
| 322 |
-
|
| 323 |
-
// Initialize date picker for tasks
|
| 324 |
-
const today = new Date();
|
| 325 |
-
document.getElementById('task-date').valueAsDate = today;
|
| 326 |
-
document.getElementById('task-date').min = '2000-01-01';
|
| 327 |
-
document.getElementById('task-date').max = '2100-12-31';
|
| 328 |
-
|
| 329 |
-
// Calendar notes loader
|
| 330 |
-
function loadDateNotes(dateStr) {
|
| 331 |
-
window.selectedDateStr = dateStr;
|
| 332 |
-
document.getElementById('selected-date-title').textContent = `Notes for ${dateStr}`;
|
| 333 |
-
document.getElementById('calendar-note-input-container').style.display = 'flex';
|
| 334 |
-
|
| 335 |
-
if (window.unsubscribeCalendar) window.unsubscribeCalendar();
|
| 336 |
-
const q = query(collection(db, "notes"), where("type","==","calendar"), where("date","==",dateStr), orderBy("createdAt","asc"));
|
| 337 |
-
const notesList = document.getElementById('calendar-notes-list');
|
| 338 |
-
notesList.innerHTML = '<div class="text-center py-8"><div class="inline-block animate-spin h-8 w-8 border-t-2 border-b-2 border-blue-500 rounded-full"></div><p class="mt-2 text-gray-500">Loading notes...</p></div>';
|
| 339 |
-
|
| 340 |
-
window.unsubscribeCalendar = onSnapshot(q, (snapshot) => {
|
| 341 |
-
notesList.innerHTML = "";
|
| 342 |
-
if (snapshot.empty) {
|
| 343 |
-
notesList.innerHTML = '<div class="text-center py-8 text-gray-500">No notes for this date yet.</div>';
|
| 344 |
-
return;
|
| 345 |
-
}
|
| 346 |
-
snapshot.forEach(docSnap => renderNoteItem({ id: docSnap.id, ...docSnap.data() }, notesList));
|
| 347 |
-
feather.replace();
|
| 348 |
-
});
|
| 349 |
-
}
|
| 350 |
-
|
| 351 |
</script>
|
|
|
|
| 352 |
</body>
|
| 353 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" />
|
| 6 |
+
<title>Shared Tasks 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-md flex justify-between items-center sticky top-0 z-10 safe-area-top">
|
| 14 |
+
<h1 class="text-2xl font-bold bg-gradient-to-r from-blue-500 to-purple-600 bg-clip-text text-transparent">Shared Tasks</h1>
|
| 15 |
+
<span id="connection-status" class="flex items-center gap-2 text-sm px-3 py-1 rounded-full bg-gray-100 dark:bg-gray-700">
|
| 16 |
+
<span class="w-2 h-2 rounded-full bg-gray-400"></span>
|
| 17 |
+
<span>Connecting...</span>
|
| 18 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</header>
|
| 20 |
|
| 21 |
+
<!-- Tasks Section -->
|
| 22 |
<main class="flex-1 p-4 max-w-2xl w-full mx-auto">
|
| 23 |
+
<ul id="tasks-list" class="space-y-3">
|
| 24 |
+
<!-- Tasks will be loaded here -->
|
| 25 |
+
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
</main>
|
| 27 |
|
| 28 |
<!-- Input -->
|
|
|
|
| 33 |
class="flex-1 p-3 rounded-lg bg-gray-100 dark:bg-gray-700 border-none outline-none focus:ring-2 focus:ring-blue-500 transition text-base"
|
| 34 |
autocomplete="name" autocorrect="off" spellcheck="false" />
|
| 35 |
</div>
|
| 36 |
+
<div class="flex">
|
| 37 |
+
<input id="note-input" type="text" placeholder="Write a task..."
|
| 38 |
+
class="flex-1 p-3 rounded-l-lg bg-gray-100 dark:bg-gray-700 border-none outline-none focus:ring-2 focus:ring-blue-500 transition text-base"
|
| 39 |
+
autocomplete="off" autocorrect="off" spellcheck="false" />
|
| 40 |
+
<button id="add-note" class="px-6 bg-gradient-to-r from-blue-500 to-purple-600 text-white rounded-r-lg hover:opacity-90 transition active:scale-95">
|
| 41 |
+
<i data-feather="plus" class="w-5 h-5"></i>
|
| 42 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
</div>
|
| 44 |
</div>
|
| 45 |
</footer>
|
| 46 |
|
| 47 |
+
<!-- Firebase & Tasks Script -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
<script type="module">
|
| 49 |
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
|
| 50 |
import { getFirestore, collection, addDoc, onSnapshot, serverTimestamp, orderBy, query, doc, deleteDoc, updateDoc, where }
|
|
|
|
| 62 |
const app = initializeApp(firebaseConfig);
|
| 63 |
const db = getFirestore(app);
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
const tasksList = document.getElementById('tasks-list');
|
| 66 |
const noteInput = document.getElementById('note-input');
|
| 67 |
const addNoteBtn = document.getElementById('add-note');
|
|
|
|
| 69 |
const nameInputContainer = document.getElementById('name-input-container');
|
| 70 |
const userNameInput = document.getElementById('user-name');
|
| 71 |
|
| 72 |
+
// Load stored name
|
| 73 |
const storedName = localStorage.getItem('sharedNotesUserName');
|
| 74 |
if (storedName) {
|
| 75 |
nameInputContainer.style.display = 'none';
|
|
|
|
| 82 |
});
|
| 83 |
}
|
| 84 |
|
| 85 |
+
// Connection status
|
| 86 |
function setStatus(online) {
|
| 87 |
connectionStatus.innerHTML = online
|
| 88 |
? `<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span><span>Connected</span>`
|
|
|
|
| 92 |
window.addEventListener("offline", () => setStatus(false));
|
| 93 |
setStatus(navigator.onLine);
|
| 94 |
|
| 95 |
+
// Add task
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
async function addNote() {
|
| 97 |
const text = noteInput.value.trim();
|
| 98 |
const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
|
| 99 |
if (!text || !userName) return;
|
| 100 |
|
|
|
|
|
|
|
|
|
|
| 101 |
try {
|
| 102 |
await addDoc(collection(db, "notes"), {
|
| 103 |
text,
|
| 104 |
userName,
|
| 105 |
createdAt: serverTimestamp(),
|
|
|
|
| 106 |
type: 'tasks',
|
| 107 |
done: false
|
| 108 |
});
|
| 109 |
noteInput.value = '';
|
| 110 |
} catch (err) {
|
| 111 |
+
console.error("Error adding task:", err);
|
| 112 |
+
alert("Failed to add task.");
|
| 113 |
}
|
| 114 |
}
|
|
|
|
| 115 |
addNoteBtn.addEventListener('click', addNote);
|
| 116 |
noteInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') addNote(); });
|
| 117 |
|
| 118 |
+
function renderNoteItem(note) {
|
| 119 |
const li = document.createElement("li");
|
| 120 |
li.className = "note-item flex items-center justify-between p-4 bg-white dark:bg-gray-800 rounded-lg shadow-sm hover:shadow-md transition-all group";
|
| 121 |
li.innerHTML = `
|
| 122 |
<div class="flex items-center flex-1">
|
| 123 |
+
<input type="checkbox" class="done-checkbox w-5 h-5 mr-3 rounded border-gray-300 text-blue-600 focus:ring-blue-500" ${note.done ? "checked" : ""}>
|
| 124 |
+
<div class="w-[calc(100%-2rem)]">
|
| 125 |
<span class="note-text ${note.done ? "line-through text-gray-400 dark:text-gray-500" : ""}">${note.text}</span>
|
| 126 |
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">Added by ${note.userName || 'Anonymous'}</div>
|
| 127 |
</div>
|
|
|
|
| 129 |
<button class="delete-btn p-2 text-red-500 hover:bg-red-50 dark:hover:bg-gray-700 rounded-full opacity-100 md:opacity-0 md:group-hover:opacity-100 transition active:scale-95">
|
| 130 |
<i data-feather="trash-2" class="w-4 h-4"></i>
|
| 131 |
</button>`;
|
| 132 |
+
|
| 133 |
+
li.querySelector(".done-checkbox").addEventListener("change", async (e) => {
|
| 134 |
+
try { await updateDoc(doc(db, "notes", note.id), { done: e.target.checked }); }
|
| 135 |
+
catch (err) { console.error("Error updating task:", err); }
|
| 136 |
+
});
|
|
|
|
| 137 |
li.querySelector(".delete-btn").addEventListener("click", async () => {
|
| 138 |
try { await deleteDoc(doc(db, "notes", note.id)); }
|
| 139 |
+
catch (err) { console.error("Error deleting task:", err); }
|
| 140 |
});
|
| 141 |
+
tasksList.appendChild(li);
|
| 142 |
}
|
| 143 |
|
| 144 |
+
// Load tasks
|
| 145 |
const tasksQuery = query(collection(db, "notes"), where("type","==","tasks"), orderBy("createdAt","asc"));
|
| 146 |
tasksList.innerHTML = '<div class="text-center py-8"><div class="inline-block animate-spin h-8 w-8 border-t-2 border-b-2 border-blue-500 rounded-full"></div><p class="mt-2 text-gray-500">Loading tasks...</p></div>';
|
| 147 |
+
onSnapshot(tasksQuery, (snapshot) => {
|
| 148 |
tasksList.innerHTML = "";
|
| 149 |
if (snapshot.empty) {
|
| 150 |
tasksList.innerHTML = '<div class="text-center py-8"><i data-feather="check-circle" class="w-12 h-12 mx-auto text-gray-400"></i><p class="mt-2 text-gray-500">No tasks yet.</p></div>';
|
| 151 |
feather.replace();
|
| 152 |
return;
|
| 153 |
}
|
| 154 |
+
snapshot.forEach(docSnap => renderNoteItem({ id: docSnap.id, ...docSnap.data() }));
|
| 155 |
feather.replace();
|
| 156 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
</script>
|
| 158 |
+
|
| 159 |
</body>
|
| 160 |
</html>
|
prompts.txt
CHANGED
|
@@ -19,4 +19,6 @@ added notes should remain in notes tab, not in tasks tab
|
|
| 19 |
when task is added to be in task page, when note is added to be in notes page
|
| 20 |
MERGE CALENDAR AND NOTES IN ONE - WHEN NOTE IS ADDED - PUT IT IN THE DATE IN CALENDAR WHEN IT IS ADDED (REMAIN THERE)
|
| 21 |
allow me to add notes in calendar directly (different from tasks)
|
| 22 |
-
add option to be able to add for other days, not current date only
|
|
|
|
|
|
|
|
|
| 19 |
when task is added to be in task page, when note is added to be in notes page
|
| 20 |
MERGE CALENDAR AND NOTES IN ONE - WHEN NOTE IS ADDED - PUT IT IN THE DATE IN CALENDAR WHEN IT IS ADDED (REMAIN THERE)
|
| 21 |
allow me to add notes in calendar directly (different from tasks)
|
| 22 |
+
add option to be able to add for other days, not current date only
|
| 23 |
+
remove calendar dates notes - remain simple as it is for tasks only
|
| 24 |
+
remove calendar dates notes - remain simple as it is for tasks only
|