trenesky commited on
Commit
c3ebc90
·
verified ·
1 Parent(s): f24850b

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
Files changed (2) hide show
  1. index.html +27 -1
  2. prompts.txt +2 -1
index.html CHANGED
@@ -34,6 +34,9 @@
34
  .note-item:hover .delete-btn {
35
  opacity: 1;
36
  }
 
 
 
37
  </style>
38
  </head>
39
  <body class="bg-gray-100 dark:bg-gray-900 min-h-screen transition-colors duration-300">
@@ -57,6 +60,7 @@
57
  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"
58
  autocapitalize="sentences"
59
  autocomplete="off"
 
60
  >
61
  <button
62
  id="add-btn"
@@ -139,7 +143,15 @@
139
  const li = document.createElement('li');
140
  li.className = 'note-item 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';
141
  li.innerHTML = `
142
- <span class="text-gray-800 dark:text-gray-200">${note.text}</span>
 
 
 
 
 
 
 
 
143
  <button
144
  data-id="${note.id}"
145
  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"
@@ -183,6 +195,7 @@
183
  if (text) {
184
  db.collection('notes').add({
185
  text: text,
 
186
  createdAt: firebase.firestore.FieldValue.serverTimestamp()
187
  })
188
  .then(() => {
@@ -232,6 +245,19 @@
232
  if (e.target.closest('.delete-btn')) {
233
  const id = e.target.closest('.delete-btn').dataset.id;
234
  deleteNote(id);
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  }
236
  });
237
 
 
34
  .note-item:hover .delete-btn {
35
  opacity: 1;
36
  }
37
+ .note-item {
38
+ cursor: pointer;
39
+ }
40
  </style>
41
  </head>
42
  <body class="bg-gray-100 dark:bg-gray-900 min-h-screen transition-colors duration-300">
 
60
  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"
61
  autocapitalize="sentences"
62
  autocomplete="off"
63
+ enterkeyhint="done"
64
  >
65
  <button
66
  id="add-btn"
 
143
  const li = document.createElement('li');
144
  li.className = 'note-item 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';
145
  li.innerHTML = `
146
+ <div class="flex items-center gap-3">
147
+ <input
148
+ type="checkbox"
149
+ ${note.completed ? 'checked' : ''}
150
+ data-id="${note.id}"
151
+ class="w-5 h-5 rounded border-gray-300 text-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-700"
152
+ >
153
+ <span class="text-gray-800 dark:text-gray-200 ${note.completed ? 'line-through text-gray-400 dark:text-gray-500' : ''}">${note.text}</span>
154
+ </div>
155
  <button
156
  data-id="${note.id}"
157
  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"
 
195
  if (text) {
196
  db.collection('notes').add({
197
  text: text,
198
+ completed: false,
199
  createdAt: firebase.firestore.FieldValue.serverTimestamp()
200
  })
201
  .then(() => {
 
245
  if (e.target.closest('.delete-btn')) {
246
  const id = e.target.closest('.delete-btn').dataset.id;
247
  deleteNote(id);
248
+ } else if (e.target.type === 'checkbox') {
249
+ const id = e.target.dataset.id;
250
+ const completed = e.target.checked;
251
+ db.collection('notes').doc(id).update({
252
+ completed: completed
253
+ })
254
+ .then(() => {
255
+ lastSync = new Date();
256
+ updateSyncTime();
257
+ })
258
+ .catch((error) => {
259
+ console.error("Error updating note:", error);
260
+ });
261
  }
262
  });
263
 
prompts.txt CHANGED
@@ -1,4 +1,5 @@
1
  need simple notepad with autosync option for multiple users, (something like groceries list for me and my wife)
2
  also to have dark mode
3
  make it compatibile for andoid devices
4
- sync should work automaticaly, when note is added to be remembered on notes (online)
 
 
1
  need simple notepad with autosync option for multiple users, (something like groceries list for me and my wife)
2
  also to have dark mode
3
  make it compatibile for andoid devices
4
+ sync should work automaticaly, when note is added to be remembered on notes (online)
5
+ when note is added, should have checkbox is is done or not, also should stay remembered, not to dissapier when refresh page