mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-24 07:20:53 +00:00
No reload per default, just send JsonDom
This commit is contained in:
parent
81366af7f1
commit
eec13e4934
@ -1,4 +1,4 @@
|
|||||||
# ESPUI (v2.X)
|
# ESPUI
|
||||||
|
|
||||||
![ESPUI](https://github.com/s00500/ESPUI/blob/master/docs/ui_complete.png)
|
![ESPUI](https://github.com/s00500/ESPUI/blob/master/docs/ui_complete.png)
|
||||||
|
|
||||||
|
5
data/js/controls.js
vendored
5
data/js/controls.js
vendored
@ -232,6 +232,11 @@ function start() {
|
|||||||
var center = "";
|
var center = "";
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case UI_INITIAL_GUI:
|
case UI_INITIAL_GUI:
|
||||||
|
// Clear current elements
|
||||||
|
$("#row").html("");
|
||||||
|
$("#tabsnav").html("");
|
||||||
|
$("#tabscontent").html("");
|
||||||
|
|
||||||
if (data.sliderContinuous) {
|
if (data.sliderContinuous) {
|
||||||
sliderContinuous = data.sliderContinuous;
|
sliderContinuous = data.sliderContinuous;
|
||||||
}
|
}
|
||||||
|
2
data/js/controls.min.js
vendored
2
data/js/controls.min.js
vendored
@ -7,7 +7,7 @@ function restart(){$(document).add("*").off();$("#row").html("");websock.close()
|
|||||||
function conStatusError(){websockConnected=false;$("#conStatus").removeClass("color-green");$("#conStatus").addClass("color-red");$("#conStatus").html("Error / No Connection ↻");$("#conStatus").off();$("#conStatus").on({click:restart,});}
|
function conStatusError(){websockConnected=false;$("#conStatus").removeClass("color-green");$("#conStatus").addClass("color-red");$("#conStatus").html("Error / No Connection ↻");$("#conStatus").off();$("#conStatus").on({click:restart,});}
|
||||||
function handleVisibilityChange(){if(!websockConnected&&!document.hidden){restart();}}
|
function handleVisibilityChange(){if(!websockConnected&&!document.hidden){restart();}}
|
||||||
function start(){document.addEventListener("visibilitychange",handleVisibilityChange,false);if(window.location.port!=""||window.location.port!=80||window.location.port!=443){websock=new WebSocket("ws://"+window.location.hostname+":"+window.location.port+"/ws");}else{websock=new WebSocket("ws://"+window.location.hostname+"/ws");}
|
function start(){document.addEventListener("visibilitychange",handleVisibilityChange,false);if(window.location.port!=""||window.location.port!=80||window.location.port!=443){websock=new WebSocket("ws://"+window.location.hostname+":"+window.location.port+"/ws");}else{websock=new WebSocket("ws://"+window.location.hostname+"/ws");}
|
||||||
websock.onopen=function(evt){console.log("websock open");$("#conStatus").addClass("color-green");$("#conStatus").text("Connected");websockConnected=true;};websock.onclose=function(evt){console.log("websock close");conStatusError();};websock.onerror=function(evt){console.log(evt);conStatusError();};var handleEvent=function(evt){var data=JSON.parse(evt.data);var e=document.body;var center="";switch(data.type){case UI_INITIAL_GUI:if(data.sliderContinuous){sliderContinuous=data.sliderContinuous;}
|
websock.onopen=function(evt){console.log("websock open");$("#conStatus").addClass("color-green");$("#conStatus").text("Connected");websockConnected=true;};websock.onclose=function(evt){console.log("websock close");conStatusError();};websock.onerror=function(evt){console.log(evt);conStatusError();};var handleEvent=function(evt){var data=JSON.parse(evt.data);var e=document.body;var center="";switch(data.type){case UI_INITIAL_GUI:$("#row").html("");$("#tabsnav").html("");$("#tabscontent").html("");if(data.sliderContinuous){sliderContinuous=data.sliderContinuous;}
|
||||||
data.controls.forEach(element=>{var fauxEvent={data:JSON.stringify(element),};handleEvent(fauxEvent);});break;case UI_RELOAD:window.location.reload();break;case UI_TITEL:document.title=data.label;$("#mainHeader").html(data.label);break;case UI_LABEL:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
data.controls.forEach(element=>{var fauxEvent={data:JSON.stringify(element),};handleEvent(fauxEvent);});break;case UI_RELOAD:window.location.reload();break;case UI_TITEL:document.title=data.label;$("#mainHeader").html(data.label);break;case UI_LABEL:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
parent.append("<div id='id"+
|
parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
|
562
src/ESPUI.cpp
562
src/ESPUI.cpp
File diff suppressed because it is too large
Load Diff
12
src/ESPUI.h
12
src/ESPUI.h
@ -206,9 +206,8 @@ public:
|
|||||||
void prepareFileSystem(); // Initially preps the filesystem and loads a lot of stuff into SPIFFS
|
void prepareFileSystem(); // Initially preps the filesystem and loads a lot of stuff into SPIFFS
|
||||||
void list(); // Lists SPIFFS directory
|
void list(); // Lists SPIFFS directory
|
||||||
|
|
||||||
uint16_t addControl(ControlType type, const char *label, String value = String(""), ControlColor color = ControlColor::Turquoise,
|
uint16_t addControl(ControlType type, const char *label, String value = String(""), ControlColor color = ControlColor::Turquoise, uint16_t parentControl = Control::noParent, void (*callback)(Control *, int) = nullptr);
|
||||||
uint16_t parentControl = Control::noParent, void (*callback)(Control *, int) = nullptr);
|
bool removeControl(uint16_t id, bool force_reload_ui = false);
|
||||||
bool remControl(uint16_t id, bool reload_ui = true);
|
|
||||||
|
|
||||||
// create Elements
|
// create Elements
|
||||||
uint16_t button(const char *label, void (*callback)(Control *, int), ControlColor color, String value = ""); // Create Event Button
|
uint16_t button(const char *label, void (*callback)(Control *, int), ControlColor color, String value = ""); // Create Event Button
|
||||||
@ -225,8 +224,7 @@ public:
|
|||||||
// Output only
|
// Output only
|
||||||
uint16_t label(const char *label, ControlColor color, String value = ""); // Create Label
|
uint16_t label(const char *label, ControlColor color, String value = ""); // Create Label
|
||||||
uint16_t graph(const char *label, ControlColor color); // Create Graph display
|
uint16_t graph(const char *label, ControlColor color); // Create Graph display
|
||||||
uint16_t gauge(const char *label, ControlColor color, int value, int min = 0,
|
uint16_t gauge(const char *label, ControlColor color, int value, int min = 0, int max = 100); // Create Gauge display
|
||||||
int max = 100); // Create Gauge display
|
|
||||||
|
|
||||||
// Input only
|
// Input only
|
||||||
uint16_t accelerometer(const char *label, void (*callback)(Control *, int), ControlColor color);
|
uint16_t accelerometer(const char *label, void (*callback)(Control *, int), ControlColor color);
|
||||||
@ -242,8 +240,6 @@ public:
|
|||||||
void updateControl(uint16_t id, int clientId = -1);
|
void updateControl(uint16_t id, int clientId = -1);
|
||||||
void updateControl(Control *control, int clientId = -1);
|
void updateControl(Control *control, int clientId = -1);
|
||||||
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
void print(uint16_t id, String value);
|
void print(uint16_t id, String value);
|
||||||
void updateLabel(uint16_t id, String value);
|
void updateLabel(uint16_t id, String value);
|
||||||
void updateSwitcher(uint16_t id, bool nValue, int clientId = -1);
|
void updateSwitcher(uint16_t id, bool nValue, int clientId = -1);
|
||||||
@ -259,8 +255,8 @@ public:
|
|||||||
// Variables
|
// Variables
|
||||||
const char *ui_title = "ESPUI"; // Store UI Title and Header Name
|
const char *ui_title = "ESPUI"; // Store UI Title and Header Name
|
||||||
Control *controls = nullptr;
|
Control *controls = nullptr;
|
||||||
|
void jsonReload();
|
||||||
void jsonDom(AsyncWebSocketClient *client);
|
void jsonDom(AsyncWebSocketClient *client);
|
||||||
void jsonReload(AsyncWebSocketClient *client);
|
|
||||||
|
|
||||||
Verbosity verbosity;
|
Verbosity verbosity;
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user