var _elapsedTime = 0; function getParams() { const url = '/paraams'; fetch(url) .then((respone)=>{ return respone.json(); }) .then((data)=>{ document.getElementById('Iim').value = data.Iim || -1; document.getElementById('Imp').value = data.Imp || -1; document.getElementById('Tu').value = data.Tu || -1; document.getElementById('Tl').value = data.Tl || -1; M.updateTextFields(); }) } function setParams() { const data = new URLSearchParams(); data.append('Iim',document.getElementById('Iim').value); data.append('Imp',document.getElementById('Imp').value); data.append('Tu',document.getElementById('Tu').value); data.append('Tl',document.getElementById('Tl').value); fetch('/params', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: data }) } function joinNetwork() { const data = new URLSearchParams(); data.append('ssid', document.getElementById("ssid").value); data.append('pass', document.getElementById("pass").value); data.append('gateway', document.getElementById("gateway").value); data.append('ip', document.getElementById("ip").value); fetch('/setWiFi', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: data }) } async function scanNetworks() { let raw = await fetch("/scanNetworks"); let data = await raw.json(); var listHTML = ""; data.forEach((network)=>{ listHTML += ''+network.ssid+''+network.channel+''+network.rssi+''; }); document.getElementById("networks").innerHTML = listHTML; } setInterval(function () { aja() .url('/sensors') .on('success', function (data) { document.getElementById("tempinfo").value = data.temperature || -1; document.getElementById("humidityinfo").value = data.humidity || -1; document.getElementById("pressureinfo").value = data.pressure || -1; //document.getElementById("targetinfo").value = data.target.toFixed(2) || -1; _run = data.runProfile || 0; _elapsedTime = data.elapsedTime || 0; M.updateTextFields(); }) .go(); }, 4000); document.addEventListener('DOMContentLoaded', function() { M.AutoInit(); getParams(); // var elems = document.querySelectorAll('.tooltipped'); // var instances = M.Tooltip.init(elems, ttOptions); });