Cybrkyd's Git Repositories

notes - commit: a958e86

commit a958e86d7b1a07b0dcdbbd136a6eb4bfa0227b2d042645ae7bd045f7ff273ebf
author Cybrkyd <git@cybrkyd.com> 2026-06-11 09:20:50 +0100
committer Cybrkyd <git@cybrkyd.com> 2026-06-11 09:20:50 +0100

Commit Message

Auto-save in-progress note every 3 seconds

📊 Diffstat

notes.py 20
1 files changed, 19 insertions(+), 1 deletions(-)

Diff

diff --git a/notes.py b/notes.py
index 859a494..aa2f580 100644
--- a/notes.py
+++ b/notes.py
@@ -436,10 +436,28 @@ toggleBtn.addEventListener("click", function() {
});
+
+ let autoSaveTimer = null;
+
document.getElementById("editor").addEventListener("input", function() {
updateCounts(this.value);
- });
+ // Auto-save only if we are editing an existing note
+ if (currentDocId === null) return;
+
+ clearTimeout(autoSaveTimer);
+ autoSaveTimer = setTimeout(async function() {
+ const text = document.getElementById("editor").value.trim();
+ if (!text) return;
+ try {
+ await apiPut(`/api/notes/${currentDocId}`, { content: text });
+ document.getElementById("docStatus").textContent =
+ `Note #${currentDocId} auto-saved at ${new Date().toLocaleTimeString()}`;
+ } catch (e) {
+ document.getElementById("docStatus").textContent = "Auto-save failed: " + e.message;
+ }
+ }, 3000);
+ });
updateStatus();
loadDocuments();