Fix fundamental setting: remove input listener that spams server, only send on Enter/arrows
This commit is contained in:
parent
5b92e4ff83
commit
e819c374e4
|
|
@ -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) => {
|
document.getElementById("fundamentalInput").addEventListener("keydown", (e) => {
|
||||||
if (e.key === "Enter") {
|
if (e.key === "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -752,10 +752,24 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Also trigger on input change (for the spinner buttons)
|
async function setFundamental() {
|
||||||
document.getElementById("fundamentalInput").addEventListener("input", () => {
|
const input = document.getElementById("fundamentalInput");
|
||||||
setFundamental();
|
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
|
// File input handler
|
||||||
document.getElementById("loadFileBtn").addEventListener("click", async () => {
|
document.getElementById("loadFileBtn").addEventListener("click", async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue