From 29e2e89aae15ed9af374bba6e07f48491f735014 Mon Sep 17 00:00:00 2001 From: Tracker-Friendly Date: Fri, 29 Mar 2024 20:05:46 +0000 Subject: [PATCH] Added live editing (client) --- static/js/main.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/static/js/main.js b/static/js/main.js index 36634b5..5431a75 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -185,6 +185,31 @@ function updateFont() { textSizeBox.innerText = currentFontSize + "px" } +function async waitforedit() { + while(true) { + await fetch("https://notes.canary.hectabit.org/api/waitforedit", { + method: "POST", + body: JSON.stringify({ + "secretKey": localStorage.getItem("DONOTSHARE-secretkey") + }), + headers: { + "Content-Type": "application/json; charset=UTF-8" + } + }) + .then(async (response) => { + async function doStuff() { + const data = await response.json(); + // Access the "note" field from the response + const note = data.note; + if (note == selectedNote) { + selectNote(selectedNote) + } + } + doStuff(); + }) + } +} + if (localStorage.getItem("SETTING-fontsize") === null) { localStorage.setItem("SETTING-fontsize", "16") updateFont() @@ -640,3 +665,5 @@ if (isFirstTimeVisitor() && /Android|iPhone|iPod/i.test(navigator.userAgent)) { if (firstNewVersion()) { displayError("What's new in Burgernotes 1.2?\n\nNote titles are now the first line of a note \(will not break compatibility with older notes\)\nIntroduced improved login screen\nNote titles now scroll correctly") } + +waitforedit()