Added frontend code for limits
This commit is contained in:
25
www/main.js
25
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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user