Added frontend code for limits

This commit is contained in:
2026-06-03 19:09:45 +01:00
parent 6231059b82
commit 606c1bd46b

View File

@ -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={}) { async function POST(path, data={}) {
return new Promise(function (onSuccess, onError) { return new Promise(function (onSuccess, onError) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
@ -57,3 +75,10 @@ async function vibrate() {
async function beep() { async function beep() {
txFromUI('beep'); txFromUI('beep');
} }
window.addEventListener('load', () => {
GET('/limit').then((data) => {
document.getElementById('shockIntensity').max = data.limit;
document.getElementById('vibrateIntensity').max = data.limit;
});
});