diff --git a/frontend/svelte/package-lock.json b/frontend/svelte/package-lock.json index 3586104..61e3121 100644 --- a/frontend/svelte/package-lock.json +++ b/frontend/svelte/package-lock.json @@ -7,6 +7,9 @@ "": { "name": "svelte", "version": "0.0.1", + "dependencies": { + "bootstrap-icons": "^1.9.1" + }, "devDependencies": { "@sveltejs/adapter-auto": "next", "@sveltejs/kit": "next", @@ -436,6 +439,11 @@ "file-uri-to-path": "1.0.0" } }, + "node_modules/bootstrap-icons": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.9.1.tgz", + "integrity": "sha512-d4ZkO30MIkAhQ2nNRJqKXJVEQorALGbLWTuRxyCTJF96lRIV6imcgMehWGJUiJMJhglN0o2tqLIeDnMdiQEE9g==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -2677,6 +2685,11 @@ "file-uri-to-path": "1.0.0" } }, + "bootstrap-icons": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.9.1.tgz", + "integrity": "sha512-d4ZkO30MIkAhQ2nNRJqKXJVEQorALGbLWTuRxyCTJF96lRIV6imcgMehWGJUiJMJhglN0o2tqLIeDnMdiQEE9g==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", diff --git a/frontend/svelte/src/routes/+page.svelte b/frontend/svelte/src/routes/+page.svelte index e78dfca..517b1b3 100644 --- a/frontend/svelte/src/routes/+page.svelte +++ b/frontend/svelte/src/routes/+page.svelte @@ -17,8 +17,11 @@ notes = notes.filter(i => i === i); } - function sortNotesByDate(){ - notes.sort(function(x, y) { + /** + * Sorts the "notes" Array by the lastOpened Property of a Note + */ + function sortNotesByDate() { + notes.sort(function (x, y) { if (x.lastOpened > y.lastOpened) { return 1; } @@ -64,6 +67,17 @@ notes.push(note); } + /** + * Gives the user a prompt if they are sure to delete this note and deletes it if they confirm + * @param note The note to be removed + */ + function removeNotePrompt(note) { + const reallyDelete = confirm("Do you really want to delete this Note?"); + if (reallyDelete) { + removeNote(note); + } + } + /** * Removes the note from the "notes" Array * @param note The note to be removed @@ -71,57 +85,97 @@ function removeNote(note) { notes = notes.filter(i => i !== note); } + + /** + * Handle when the mouse hovers over a Note List Element + * @param noteId The ID of the note that is hovered over + */ + function handleMouseOverLi(noteId: number) { + document.getElementById("noteButton" + noteId).style.display = "block"; + } + + /** + * Handle when the mouse exits hovering over a Note List Element + * @param noteId The ID of the note that is hovered over + */ + function handleMouseOutLi(noteId: number) { + document.getElementById("noteButton" + noteId).style.display = "none"; + } + + /** + * Handles a click on a note list element + * @param note The note the user clicked on + */ + function onNoteLiClick(note) { + window.localStorage.setItem("clickedNoteId", note.id); + window.location = "/editor"; + } + +