1
0
mirror of https://github.com/s00500/ESPUI.git synced 2024-11-22 04:00:55 +00:00

Fix update_gauge typo, Close #69

This commit is contained in:
Lukas Bachschwell 2020-06-01 18:04:13 +02:00
parent 5a6b92bb5f
commit 585c1608b8
Signed by: lbsadmin
GPG Key ID: CCC6AA87CC8DF425
3 changed files with 800 additions and 308 deletions

98
data/js/controls.js vendored
View File

@ -47,7 +47,7 @@ const UI_STEP = 16;
const UPDATE_STEP = 116; const UPDATE_STEP = 116;
const UI_GAUGE = 17; const UI_GAUGE = 17;
const UPTDATE_GAUGE = 117; const UPDATE_GAUGE = 117;
const UI_ACCEL = 18; const UI_ACCEL = 18;
const UPTDATE_ACCEL = 117; const UPTDATE_ACCEL = 117;
@ -171,9 +171,7 @@ function restoreGraphData(id) {
} }
function restart() { function restart() {
$(document) $(document).add("*").off();
.add("*")
.off();
$("#row").html(""); $("#row").html("");
websock.close(); websock.close();
start(); start();
@ -186,7 +184,7 @@ function conStatusError() {
$("#conStatus").html("Error / No Connection ↻"); $("#conStatus").html("Error / No Connection ↻");
$("#conStatus").off(); $("#conStatus").off();
$("#conStatus").on({ $("#conStatus").on({
click: restart click: restart,
}); });
} }
@ -209,24 +207,24 @@ function start() {
} else { } else {
websock = new WebSocket("ws://" + window.location.hostname + "/ws"); websock = new WebSocket("ws://" + window.location.hostname + "/ws");
} }
websock.onopen = function(evt) { websock.onopen = function (evt) {
console.log("websock open"); console.log("websock open");
$("#conStatus").addClass("color-green"); $("#conStatus").addClass("color-green");
$("#conStatus").text("Connected"); $("#conStatus").text("Connected");
websockConnected = true; websockConnected = true;
}; };
websock.onclose = function(evt) { websock.onclose = function (evt) {
console.log("websock close"); console.log("websock close");
conStatusError(); conStatusError();
}; };
websock.onerror = function(evt) { websock.onerror = function (evt) {
console.log(evt); console.log(evt);
conStatusError(); conStatusError();
}; };
var handleEvent = function(evt) { var handleEvent = function (evt) {
//console.log(evt); //console.log(evt);
var data = JSON.parse(evt.data); var data = JSON.parse(evt.data);
var e = document.body; var e = document.body;
@ -238,7 +236,7 @@ function start() {
} }
data.controls.forEach(element => { data.controls.forEach(element => {
var fauxEvent = { var fauxEvent = {
data: JSON.stringify(element) data: JSON.stringify(element),
}; };
handleEvent(fauxEvent); handleEvent(fauxEvent);
}); });
@ -303,14 +301,14 @@ function start() {
"</button></div>" "</button></div>"
); );
$("#btn" + data.id).on({ $("#btn" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
buttonclick(data.id, true); buttonclick(data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
buttonclick(data.id, false); buttonclick(data.id, false);
} },
}); });
break; break;
@ -410,54 +408,54 @@ function start() {
); );
$("#pf" + data.id).on({ $("#pf" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
padclick(UP, data.id, true); padclick(UP, data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
padclick(UP, data.id, false); padclick(UP, data.id, false);
} },
}); });
$("#pl" + data.id).on({ $("#pl" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
padclick(LEFT, data.id, true); padclick(LEFT, data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
padclick(LEFT, data.id, false); padclick(LEFT, data.id, false);
} },
}); });
$("#pr" + data.id).on({ $("#pr" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
padclick(RIGHT, data.id, true); padclick(RIGHT, data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
padclick(RIGHT, data.id, false); padclick(RIGHT, data.id, false);
} },
}); });
$("#pb" + data.id).on({ $("#pb" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
padclick(DOWN, data.id, true); padclick(DOWN, data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
padclick(DOWN, data.id, false); padclick(DOWN, data.id, false);
} },
}); });
$("#pc" + data.id).on({ $("#pc" + data.id).on({
touchstart: function(e) { touchstart: function (e) {
e.preventDefault(); e.preventDefault();
padclick(CENTER, data.id, true); padclick(CENTER, data.id, true);
}, },
touchend: function(e) { touchend: function (e) {
e.preventDefault(); e.preventDefault();
padclick(CENTER, data.id, false); padclick(CENTER, data.id, false);
} },
}); });
break; break;
@ -554,15 +552,13 @@ function start() {
); );
$("#tabscontent").append("<div id='tab" + data.id + "'></div>"); $("#tabscontent").append("<div id='tab" + data.id + "'></div>");
tabs = $(".tabscontent") tabs = $(".tabscontent").tabbedContent({ loop: true }).data("api");
.tabbedContent({ loop: true })
.data("api");
// switch to tab... // switch to tab...
$("a") $("a")
.filter(function() { .filter(function () {
return $(this).attr("href") === "#click-to-switch"; return $(this).attr("href") === "#click-to-switch";
}) })
.on("click", function(e) { .on("click", function (e) {
var tab = prompt("Tab to switch to (number or id)?"); var tab = prompt("Tab to switch to (number or id)?");
if (!tabs.switchTab(tab)) { if (!tabs.switchTab(tab)) {
alert("That tab does not exist :\\"); alert("That tab does not exist :\\");
@ -862,43 +858,31 @@ function switcher(number, state) {
} }
} }
var rangeSlider = function(isDiscrete) { var rangeSlider = function (isDiscrete) {
var slider = $(".range-slider"), var slider = $(".range-slider"),
range = $(".range-slider__range"), range = $(".range-slider__range"),
value = $(".range-slider__value"); value = $(".range-slider__value");
slider.each(function() { slider.each(function () {
value.each(function() { value.each(function () {
var value = $(this) var value = $(this).prev().attr("value");
.prev()
.attr("value");
$(this).html(value); $(this).html(value);
}); });
if (!isDiscrete) { if (!isDiscrete) {
range.on({ range.on({
input: function() { input: function () {
sliderchange( sliderchange($(this).attr("id").replace(/^\D+/g, ""));
$(this) },
.attr("id")
.replace(/^\D+/g, "")
);
}
}); });
} else { } else {
range.on({ range.on({
input: function() { input: function () {
$(this) $(this).next().html(this.value);
.next() },
.html(this.value); change: function () {
sliderchange($(this).attr("id").replace(/^\D+/g, ""));
}, },
change: function() {
sliderchange(
$(this)
.attr("id")
.replace(/^\D+/g, "")
);
}
}); });
} }
}); });

1006
data/js/controls.min.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long