-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathindex.js
More file actions
25 lines (24 loc) · 775 Bytes
/
index.js
File metadata and controls
25 lines (24 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
document.addEventListener("DOMContentLoaded", function () {
const clearBtn = document.getElementById("clear-search");
if (clearBtn) {
clearBtn.addEventListener("click", function () {
const form = document.querySelector(".search-form");
if (form) {
const input = form.querySelector('input[name="q"]');
if (input) input.value = "";
form.submit(); // submit without q -> backend will show all notes
} else {
// fallback: reload base path without query string
window.location = window.location.pathname;
}
});
}
});
function deleteNote(noteId) {
fetch("/delete-note", {
method: "POST",
body: JSON.stringify({ noteId: noteId }),
}).then((_res) => {
window.location.href = "/";
});
}