allow deleting, open note on new note button click, title for rename/delete, change font size for button+label

This commit is contained in:
zyqunix 2025-02-05 21:58:26 +01:00
parent a8fce26724
commit 82a5f8215e
3 changed files with 29 additions and 2 deletions

View file

@ -40,14 +40,37 @@ function createNoteElement(note) {
});
newNote.addEventListener('mousedown', (e) => {
if (e.shiftKey) {
if (e.shiftKey && e.button === 0) {
renameCurrentNote();
} else if (e.shiftKey && e.button === 2) {
deleteNote(note.id);
}
});
newNote.addEventListener('contextmenu', (e) => {
e.preventDefault();
});
return newNote;
}
function deleteNote(noteId) {
if (confirm("Are you sure you want to delete this note?")) {
let savedNotes = getNotesFromCookies();
savedNotes = savedNotes.filter(note => note.id !== noteId);
saveNotesToCookies(savedNotes);
updateNotesList();
if (currentNote && parseInt(currentNote.id) === noteId) {
editor.style.display = 'none';
document.querySelector('h2[class="hint"]').style.opacity = "1";
currentNote = null;
noteOpen = false;
}
}
}
function updateNotesList() {
const savedNotes = getNotesFromCookies();
notes.innerHTML = '';
@ -133,8 +156,11 @@ newNoteButton.addEventListener('click', () => {
savedNotes.push(newNote);
saveNotesToCookies(savedNotes);
updateNotesList();
newNoteElement.click();
});
stopNote.addEventListener('click', () => {
document.querySelector('h2[class="hint"]').style.opacity = "1";
noteOpen = false;