trenesky commited on
Commit
ca310e6
·
verified ·
1 Parent(s): b2ef97a

allow me to add notes in calendar directly (different from tasks) - Follow Up Deployment

Browse files
Files changed (2) hide show
  1. index.html +50 -11
  2. prompts.txt +2 -1
index.html CHANGED
@@ -60,7 +60,15 @@
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"></ul>
 
 
 
 
 
 
 
 
64
  </div>
65
  </div>
66
  </main>
@@ -200,7 +208,33 @@
200
  window.addEventListener("offline", () => setStatus(false));
201
  setStatus(navigator.onLine);
202
 
203
- async function addNote() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  const text = noteInput.value.trim();
205
  const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
206
  if (!text || !userName) return;
@@ -213,16 +247,11 @@
213
  text,
214
  userName,
215
  createdAt: serverTimestamp(),
216
- date: dateStr
 
 
217
  };
218
 
219
- if (activeTab === 'tasks') {
220
- noteData.type = 'tasks';
221
- noteData.done = false; // tasks start unchecked
222
- } else {
223
- noteData.type = 'calendar';
224
- }
225
-
226
  try {
227
  await addDoc(collection(db, "notes"), noteData);
228
  noteInput.value = '';
@@ -277,12 +306,16 @@
277
  feather.replace();
278
  });
279
 
 
 
 
280
  // Calendar load function
281
  window.loadDateNotes = function(dateStr) {
282
  window.selectedDateStr = dateStr;
283
  const date = new Date(dateStr);
284
  document.getElementById('selected-date-title').textContent =
285
  `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
 
286
  document.querySelectorAll('[data-date]').forEach(el => el.classList.remove('bg-blue-100','dark:bg-blue-900','active'));
287
  document.querySelector(`[data-date="${dateStr}"]`).classList.add('bg-blue-100','dark:bg-blue-900','active');
288
 
@@ -310,10 +343,16 @@
310
  });
311
  };
312
 
313
- window.addEventListener('beforeunload', () => { unsubscribeTasks(); if(window.unsubscribeCalendar) window.unsubscribeCalendar(); });
 
 
 
314
  </script>
315
 
316
  <style>
 
 
 
317
  .tab-button { transition: all 0.2s ease; }
318
  .tab-content { transition: opacity 0.3s ease; }
319
  @supports (padding: max(0px)) {
 
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>
 
208
  window.addEventListener("offline", () => setStatus(false));
209
  setStatus(navigator.onLine);
210
 
211
+ // Calendar note input handling
212
+ document.getElementById('add-calendar-note').addEventListener('click', addCalendarNote);
213
+ document.getElementById('calendar-note-input').addEventListener('keypress', (e) => {
214
+ if (e.key === 'Enter') addCalendarNote();
215
+ });
216
+
217
+ async function addCalendarNote() {
218
+ const text = document.getElementById('calendar-note-input').value.trim();
219
+ const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
220
+ if (!text || !userName || !window.selectedDateStr) return;
221
+
222
+ try {
223
+ await addDoc(collection(db, "notes"), {
224
+ text,
225
+ userName,
226
+ createdAt: serverTimestamp(),
227
+ date: window.selectedDateStr,
228
+ type: 'calendar'
229
+ });
230
+ document.getElementById('calendar-note-input').value = '';
231
+ } catch (err) {
232
+ console.error("Error adding calendar note:", err);
233
+ alert("Failed to add note.");
234
+ }
235
+ }
236
+
237
+ async function addNote() {
238
  const text = noteInput.value.trim();
239
  const userName = localStorage.getItem('sharedNotesUserName') || userNameInput.value.trim();
240
  if (!text || !userName) return;
 
247
  text,
248
  userName,
249
  createdAt: serverTimestamp(),
250
+ date: dateStr,
251
+ type: 'tasks',
252
+ done: false
253
  };
254
 
 
 
 
 
 
 
 
255
  try {
256
  await addDoc(collection(db, "notes"), noteData);
257
  noteInput.value = '';
 
306
  feather.replace();
307
  });
308
 
309
+ // Hide calendar note input when no date selected
310
+ document.getElementById('calendar-note-input-container').style.display = 'none';
311
+
312
  // Calendar load function
313
  window.loadDateNotes = function(dateStr) {
314
  window.selectedDateStr = dateStr;
315
  const date = new Date(dateStr);
316
  document.getElementById('selected-date-title').textContent =
317
  `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
318
+ document.getElementById('calendar-note-input-container').style.display = 'flex';
319
  document.querySelectorAll('[data-date]').forEach(el => el.classList.remove('bg-blue-100','dark:bg-blue-900','active'));
320
  document.querySelector(`[data-date="${dateStr}"]`).classList.add('bg-blue-100','dark:bg-blue-900','active');
321
 
 
343
  });
344
  };
345
 
346
+ window.addEventListener('beforeunload', () => {
347
+ unsubscribeTasks();
348
+ if(window.unsubscribeCalendar) window.unsubscribeCalendar();
349
+ });
350
  </script>
351
 
352
  <style>
353
+ #calendar-note-input-container {
354
+ display: none;
355
+ }
356
  .tab-button { transition: all 0.2s ease; }
357
  .tab-content { transition: opacity 0.3s ease; }
358
  @supports (padding: max(0px)) {
prompts.txt CHANGED
@@ -17,4 +17,5 @@ fix notes and calendar, make them working tabs, same as tasks
17
  fix notes and calendar, make them working tabs, same as tasks
18
  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)
 
 
17
  fix notes and calendar, make them working tabs, same as tasks
18
  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)