1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-06-22 11:20:19 +00:00

Put examples to lib

This commit is contained in:
2017-10-17 11:55:25 +02:00
parent 332e9afbfa
commit 93b78a900d
6 changed files with 742 additions and 10 deletions

@ -0,0 +1,55 @@
// TASKS:
// Roadmap
// Build changeable Labels
// Build a serial Console?
var websock;
function start() {
websock = new WebSocket('ws://' + window.location.hostname + '/ws');
websock.onopen = function(evt) {
console.log('websock open');
$("#conStatus").addClass("color-green");
$("#conStatus").text("Connected");
};
websock.onclose = function(evt) {
console.log('websock close');
$("#conStatus").removeClass("color-green");
$("#conStatus").addClass("color-red");
$("#conStatus").text("Error / No Connection");
};
websock.onerror = function(evt) {
console.log(evt);
$("#conStatus").removeClass("color-green");
$("#conStatus").addClass("color-red");
$("#conStatus").text("Error / No Connection");
};
websock.onmessage = function(evt) {
console.log(evt);
var data = JSON.parse(evt.data);
console.log(data);
var e = document.body;
if (data.type === 'domButton') {
//initial rendering of the Buttons
$('#row').append("<div class='two columns card'><h5>"+data.label+"</h5><hr/><button onClick='buttonclick(this)'' id="+data.id+"></button></div>");
}
if (data.type === 'domLabel') {
//initial rendering of the Labels
$('#row').append("<div class='two columns card'><h5>"+data.l_title+"</h5><hr /><h3><span class='label'>"+data.label+"</span></h3></div>");
}
else if (data.type === 'value') {
// Display some kind of value
}
else {
console.log('unknown event');
}
};
}
function buttonclick(e) {
websock.send("bdown:"+e.id);
/*
if release
websock.send("bup:"+e.id);
*/
}

File diff suppressed because one or more lines are too long