From e819c374e4d2709b5ee56be111aa46ad3e9435cf Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Wed, 1 Apr 2026 16:55:29 +0200 Subject: [PATCH] Fix fundamental setting: remove input listener that spams server, only send on Enter/arrows --- webapp/path_navigator.html | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/webapp/path_navigator.html b/webapp/path_navigator.html index ea7a588..101e9b0 100644 --- a/webapp/path_navigator.html +++ b/webapp/path_navigator.html @@ -734,7 +734,7 @@ } } - // Fundamental input - auto-send on Enter, Up/Down arrows, or input change + // Fundamental input - send on Enter, Up/Down arrows document.getElementById("fundamentalInput").addEventListener("keydown", (e) => { if (e.key === "Enter") { e.preventDefault(); @@ -752,10 +752,24 @@ } }); - // Also trigger on input change (for the spinner buttons) - document.getElementById("fundamentalInput").addEventListener("input", () => { - setFundamental(); - }); + async function setFundamental() { + const input = document.getElementById("fundamentalInput"); + const fundamental = parseFloat(input.value); + if (!fundamental || fundamental <= 0) { + return; + } + try { + const response = await fetch("/api/set-fundamental", { + method: "POST", + headers: {"Content-Type": "application/json"}, + body: JSON.stringify({ fundamental: fundamental }) + }); + const data = await response.json(); + console.log("Fundamental set to:", data.fundamental, "Hz"); + } catch (e) { + console.log("Error setting fundamental", e); + } + } // File input handler document.getElementById("loadFileBtn").addEventListener("click", async () => {