From 606c1bd46b69660815d82c8bb16cecedbe087335 Mon Sep 17 00:00:00 2001 From: Brosef Date: Wed, 3 Jun 2026 19:09:45 +0100 Subject: [PATCH] Added frontend code for limits --- www/main.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/www/main.js b/www/main.js index 90f7bf3..6b0205a 100644 --- a/www/main.js +++ b/www/main.js @@ -1,3 +1,21 @@ +async function GET(path) { + return new Promise(function (onSuccess, onError) { + let xhr = new XMLHttpRequest(); + xhr.open('GET', path); + xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + if (xhr.status === 200) { + onSuccess(JSON.parse(xhr.responseText)); + } else { + onError(xhr); + } + } + } + xhr.onerror = () => onError(xhr); + xhr.send(null); + }); +} + async function POST(path, data={}) { return new Promise(function (onSuccess, onError) { var xhr = new XMLHttpRequest(); @@ -57,3 +75,10 @@ async function vibrate() { async function beep() { txFromUI('beep'); } + +window.addEventListener('load', () => { + GET('/limit').then((data) => { + document.getElementById('shockIntensity').max = data.limit; + document.getElementById('vibrateIntensity').max = data.limit; + }); +});