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:
examples/softAP_UI_Test
55
examples/softAP_UI_Test/data/js/controls.js
vendored
Normal file
55
examples/softAP_UI_Test/data/js/controls.js
vendored
Normal file
@ -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);
|
||||
*/
|
||||
}
|
2
examples/softAP_UI_Test/data/js/zepto.js
Normal file
2
examples/softAP_UI_Test/data/js/zepto.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user