From bda0b6f0ee5cc7b1f4b0c353a13bcfc83c6de7ef Mon Sep 17 00:00:00 2001 From: diya <149696438+DIYA-BHATT29@users.noreply.github.com> Date: Wed, 25 Feb 2026 21:13:50 +0530 Subject: [PATCH 1/3] Update script.js --- script.js | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 28ad504..49875c1 100644 --- a/script.js +++ b/script.js @@ -240,10 +240,39 @@ function deleteNote(index) { } function editNote(index) { - const updated = prompt("Edit note:", notes[index].text); - if (updated !== null && updated.trim() !== "") { - notes[index].text = updated.trim(); - saveNotes(); + const currentNote = notes[index]; + + // 1️⃣ Edit text + const updatedText = prompt("Edit note text:", currentNote.text); + if (updatedText === null) return; + + // 2️⃣ Edit labels (comma separated) + const currentLabels = currentNote.labels ? currentNote.labels.join(", ") : ""; + const updatedLabelsInput = prompt( + "Edit labels (comma separated: Important, Work, Personal, Ideas):", + currentLabels + ); + + if (updatedLabelsInput === null) return; + + // Clean + normalize labels + const allowedLabels = ["Important", "Work", "Personal", "Ideas"]; + + const updatedLabels = updatedLabelsInput + .split(",") + .map(label => label.trim()) + .filter(label => allowedLabels.includes(label)); + + // 3️⃣ Save updates + currentNote.text = updatedText.trim(); + currentNote.labels = updatedLabels; + + saveNotes(); + + + if (currentFilter !== "all") { + filterNotesByCategory(currentFilter); + } else { renderNotes(searchInput.value); } } @@ -470,4 +499,4 @@ document.getElementById("navTrash").addEventListener("click", () => { document.getElementById("navPersonal").classList.remove("active"); document.getElementById("navIdeas").classList.remove("active"); renderTrash(); -}); \ No newline at end of file +}); From 1940a5fdcaeb78aa9fc9ef817a9466df29c0eb70 Mon Sep 17 00:00:00 2001 From: diya <149696438+DIYA-BHATT29@users.noreply.github.com> Date: Thu, 26 Feb 2026 18:19:55 +0530 Subject: [PATCH 2/3] Update script.js --- script.js | 68 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/script.js b/script.js index 49875c1..eb3822f 100644 --- a/script.js +++ b/script.js @@ -238,41 +238,59 @@ function deleteNote(index) { renderNotes(searchInput.value); } } - function editNote(index) { - const currentNote = notes[index]; + const note = notes[index]; - // 1️⃣ Edit text - const updatedText = prompt("Edit note text:", currentNote.text); - if (updatedText === null) return; + // 1️⃣ Edit text first + const updatedText = prompt("Edit note text:", note.text); + if (updatedText === null || updatedText.trim() === "") return; - // 2️⃣ Edit labels (comma separated) - const currentLabels = currentNote.labels ? currentNote.labels.join(", ") : ""; - const updatedLabelsInput = prompt( - "Edit labels (comma separated: Important, Work, Personal, Ideas):", - currentLabels - ); + note.text = updatedText.trim(); - if (updatedLabelsInput === null) return; + // 2️⃣ Ask if user wants to edit labels + const changeLabels = confirm("Do you want to edit labels?"); + if (changeLabels) { - // Clean + normalize labels - const allowedLabels = ["Important", "Work", "Personal", "Ideas"]; + // Clear all checkboxes + labelCheckboxes.forEach(cb => cb.checked = false); - const updatedLabels = updatedLabelsInput - .split(",") - .map(label => label.trim()) - .filter(label => allowedLabels.includes(label)); + // Pre-check current labels + if (note.labels && note.labels.length > 0) { + labelCheckboxes.forEach(cb => { + if (note.labels.includes(cb.value)) { + cb.checked = true; + } + }); + } - // 3️⃣ Save updates - currentNote.text = updatedText.trim(); - currentNote.labels = updatedLabels; + alert("Update the labels below and click 'Add Note' to confirm label changes."); - saveNotes(); + // Temporarily change Add button behavior + addNoteBtn.textContent = "Save Label Changes"; - - if (currentFilter !== "all") { - filterNotesByCategory(currentFilter); + const saveLabelChanges = () => { + note.labels = getSelectedLabels(); + + saveNotes(); + + // Reset button + addNoteBtn.textContent = "Add Note"; + addNoteBtn.removeEventListener("click", saveLabelChanges); + + // Clear checkboxes + labelCheckboxes.forEach(cb => cb.checked = false); + + // Re-render properly + if (currentFilter !== "all") { + filterNotesByCategory(currentFilter); + } else { + renderNotes(searchInput.value); + } + }; + + addNoteBtn.addEventListener("click", saveLabelChanges); } else { + saveNotes(); renderNotes(searchInput.value); } } From c8668e2084223369499d42c7b55a1204f1509a99 Mon Sep 17 00:00:00 2001 From: diya <149696438+DIYA-BHATT29@users.noreply.github.com> Date: Sat, 28 Feb 2026 18:49:29 +0530 Subject: [PATCH 3/3] Update script.js --- script.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/script.js b/script.js index eb3822f..00202fd 100644 --- a/script.js +++ b/script.js @@ -518,3 +518,41 @@ document.getElementById("navTrash").addEventListener("click", () => { document.getElementById("navIdeas").classList.remove("active"); renderTrash(); }); + +/* =========================== + KEYBOARD SHORTCUTS +=========================== */ + +document.addEventListener("keydown", (e) => { + + if (e.altKey && e.key.toLowerCase() === "n") { + e.preventDefault(); + noteInput.focus(); + return; + } + + if (e.altKey && e.key.toLowerCase() === "s") { + e.preventDefault(); + searchInput.focus(); + return; + } + + if (e.altKey && e.key.toLowerCase() === "d") { + e.preventDefault(); + darkModeBtn.click(); + return; + } + + if (e.altKey && e.key.toLowerCase() === "t") { + e.preventDefault(); + document.getElementById("navTrash").click(); + return; + } + + if (e.key === "Escape") { + searchInput.value = ""; + renderNotes(); + return; + } + +});