Moving stuff around

This commit is contained in:
Skylar Grant 2022-12-22 22:19:24 -05:00
parent 82fe402b2e
commit 5b3a4038b4
2 changed files with 62 additions and 63 deletions

61
www/public/main.js Normal file
View File

@ -0,0 +1,61 @@
function sleep(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms);
});
}
function readJSON(path) {
var request = new XMLHttpRequest();
request.open("GET", path, false);
request.send(null)
var JSONObj = JSON.parse(request.responseText);
return JSONObj;
}
function parseStatus(data) {
switch (data) {
case 0:
return "Off";
break;
case 1:
return "On";
break
default:
return "Error";
break;
}
}
function refreshData() {
const log = document.getElementById('log-area');
log.contentWindow.location.reload();
sleep(100).then(() => {
document.getElementById('log-area').contentWindow.scrollTo(0, 9999999);
});
const augerStatus = document.getElementById('auger-status');
// const augerOn = document.getElementById('auger-on');
// const augerOff = document.getElementById('auger-off');
const igniterStatus = document.getElementById('igniter-status');
const blowerStatus = document.getElementById('blower-status');
// const pauseInt = document.getElementById('pause-int');
const vacuumStatus = document.getElementById('vacuum-status');
const pofStatus = document.getElementById('pof-status');
const config = readJSON('./config.json');
augerStatus.innerHTML = parseStatus(config.status.auger);
// augerOn.innerHTML = parseStatus(config.intervals.augerOn);
// augerOff.innerHTML = parseStatus(config.intervals.augerOff);
igniterStatus.innerHTML = parseStatus(config.status.igniter);
blowerStatus.innerHTML = parseStatus(config.status.blower);
// pauseInt.innerHTML = parseStatus(config.intervals.pause);
vacuumStatus.innerHTML = parseStatus(config.status.vacuum);
pofStatus.innerHTML = parseStatus(config.status.pof);
sleep(2000).then(() => {
refreshData();
});
};

View File

@ -35,68 +35,6 @@
<!-- <textarea id="log-area"></textarea> -->
<iframe id="log-area" src="log.txt"></iframe>
</div>
<script>
function sleep(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, ms);
});
}
function readJSON(path) {
var request = new XMLHttpRequest();
request.open("GET", path, false);
request.send(null)
var JSONObj = JSON.parse(request.responseText);
return JSONObj;
}
function parseStatus(data) {
switch (data) {
case 0:
return "Off";
break;
case 1:
return "On";
break
default:
return "Error";
break;
}
}
function refreshData() {
const log = document.getElementById('log-area');
log.contentWindow.location.reload();
sleep(100).then(() => {
document.getElementById('log-area').contentWindow.scrollTo(0, 9999999);
});
const augerStatus = document.getElementById('auger-status');
// const augerOn = document.getElementById('auger-on');
// const augerOff = document.getElementById('auger-off');
const igniterStatus = document.getElementById('igniter-status');
const blowerStatus = document.getElementById('blower-status');
// const pauseInt = document.getElementById('pause-int');
const vacuumStatus = document.getElementById('vacuum-status');
const pofStatus = document.getElementById('pof-status');
const config = readJSON('./config.json');
augerStatus.innerHTML = parseStatus(config.status.auger);
// augerOn.innerHTML = parseStatus(config.intervals.augerOn);
// augerOff.innerHTML = parseStatus(config.intervals.augerOff);
igniterStatus.innerHTML = parseStatus(config.status.igniter);
blowerStatus.innerHTML = parseStatus(config.status.blower);
// pauseInt.innerHTML = parseStatus(config.intervals.pause);
vacuumStatus.innerHTML = parseStatus(config.status.vacuum);
pofStatus.innerHTML = parseStatus(config.status.pof);
sleep(2000).then(() => {
refreshData();
});
};
</script>
<script src="./main.js" type="javascript"></script>
</body>
</html>