Remove all jquery from getState roundtrip.

This commit is contained in:
mmcwilliams 2017-11-21 17:48:30 -05:00
parent ae9fd34445
commit 01dddcbb4b
1 changed files with 14 additions and 17 deletions

View File

@ -328,15 +328,16 @@
var setExposureScale = function () { var setExposureScale = function () {
'use strict'; 'use strict';
var scale = $('#scale').val(); const scale = document.getElementById('scale').value;
const elem = document.getElementById('exposure');
if (scale === 'ms') { if (scale === 'ms') {
$('#exposure').val(STATE.exposure); elem.STATE.exposure;
} else if (scale === 'sec') { } else if (scale === 'sec') {
$('#exposure').val(STATE.exposure / 1000); elem.value = STATE.exposure / 1000;
} else if (scale === 'min') { } else if (scale === 'min') {
$('#exposure').val(STATE.exposure / (1000 * 60)); elem.value = STATE.exposure / (1000 * 60);
} else if (scale === 'hour') { } else if (scale === 'hour') {
$('#exposure').val(STATE.exposure / (1000 * 60 * 60)); elem.value = STATE.exposure / (1000 * 60 * 60);
} }
STATE.scale = scale; STATE.scale = scale;
}; };
@ -446,9 +447,7 @@
} }
fetch('/status', opts) fetch('/status', opts)
.then(res => { .then(res => {
let r = res.json(); return res.json();
console.dir(r);
return r;
}) })
.then(web.getStateSuccess) .then(web.getStateSuccess)
.catch(err => { .catch(err => {
@ -457,16 +456,14 @@
}); });
}; };
web.getStateSuccess = function (res) { web.getStateSuccess = function (res) {
console.dir(res) let exposure;
return; let scale;
var exposure;
var scale;
if (res.frame.dir !== true) { if (res.frame.dir !== true) {
$('#dir').prop('checked', true); document.getElementById('dir').checked = true;
STATE.dir = res.frame.dir; STATE.dir = res.frame.dir;
setDirLabel(false); setDirLabel(false);
} }
$('#counter').val(res.counter); document.getElementById('counter').value = res.counter;
STATE.counter = res.counter; STATE.counter = res.counter;
//Exposure //Exposure
if (res.frame.exposure === 0) { if (res.frame.exposure === 0) {
@ -475,11 +472,11 @@
STATE.exposure = res.frame.exposure; STATE.exposure = res.frame.exposure;
exposure = shutter(STATE.exposure); exposure = shutter(STATE.exposure);
scale = scaleAuto(STATE.exposure); scale = scaleAuto(STATE.exposure);
$('#str').text(exposure.str); document.getElementById('str').value = exposure.str;
$('#scale').val(scale); document.getElementById('scale').value = scale;
setExposureScale(); setExposureScale();
$('#delay').val(res.frame.delay); document.getElementById('delay').value = res.frame.delay;
STATE.delay = res.frame.delay; STATE.delay = res.frame.delay;
}; };
web.setExposure = function () { web.setExposure = function () {