mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-22 04:00:55 +00:00
Merge pull request #131 from Noctr/master
This commit is contained in:
commit
6b3056ab31
29
data/js/controls.js
vendored
29
data/js/controls.js
vendored
@ -263,6 +263,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -279,6 +280,7 @@ function start() {
|
|||||||
"</span>" +
|
"</span>" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_BUTTON:
|
case UI_BUTTON:
|
||||||
@ -288,6 +290,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -319,6 +322,7 @@ function start() {
|
|||||||
buttonclick(data.id, false);
|
buttonclick(data.id, false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_SWITCHER:
|
case UI_SWITCHER:
|
||||||
@ -328,6 +332,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -353,6 +358,7 @@ function start() {
|
|||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
switcher(data.id, data.value);
|
switcher(data.id, data.value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_CPAD:
|
case UI_CPAD:
|
||||||
@ -363,6 +369,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -466,7 +473,7 @@ function start() {
|
|||||||
padclick(CENTER, data.id, false);
|
padclick(CENTER, data.id, false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//https://codepen.io/seanstopnik/pen/CeLqA
|
//https://codepen.io/seanstopnik/pen/CeLqA
|
||||||
@ -477,6 +484,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -499,6 +507,7 @@ function start() {
|
|||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
rangeSlider(!sliderContinuous);
|
rangeSlider(!sliderContinuous);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_NUMBER:
|
case UI_NUMBER:
|
||||||
@ -508,6 +517,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -526,6 +536,7 @@ function start() {
|
|||||||
")' />" +
|
")' />" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_TEXT_INPUT:
|
case UI_TEXT_INPUT:
|
||||||
@ -535,6 +546,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -553,9 +565,11 @@ function start() {
|
|||||||
")' />" +
|
")' />" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_TAB:
|
case UI_TAB:
|
||||||
|
if (data.visible) {
|
||||||
$("#tabsnav").append(
|
$("#tabsnav").append(
|
||||||
"<li><a onmouseup='tabclick(" + data.id + ")' href='#tab" + data.id + "'>" + data.value + "</a></li>"
|
"<li><a onmouseup='tabclick(" + data.id + ")' href='#tab" + data.id + "'>" + data.value + "</a></li>"
|
||||||
);
|
);
|
||||||
@ -574,6 +588,7 @@ function start() {
|
|||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_SELECT:
|
case UI_SELECT:
|
||||||
@ -583,6 +598,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -599,6 +615,7 @@ function start() {
|
|||||||
")' />" +
|
")' />" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_OPTION:
|
case UI_OPTION:
|
||||||
@ -651,6 +668,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -671,6 +689,7 @@ function start() {
|
|||||||
);
|
);
|
||||||
graphData[data.id] = restoreGraphData(data.id);
|
graphData[data.id] = restoreGraphData(data.id);
|
||||||
renderGraphSvg(graphData[data.id], "graph" + data.id);
|
renderGraphSvg(graphData[data.id], "graph" + data.id);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ADD_GRAPH_POINT:
|
case ADD_GRAPH_POINT:
|
||||||
var ts = Math.round(new Date().getTime() / 1000);
|
var ts = Math.round(new Date().getTime() / 1000);
|
||||||
@ -690,6 +709,7 @@ function start() {
|
|||||||
} else {
|
} else {
|
||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -708,6 +728,7 @@ function start() {
|
|||||||
")' />" +
|
")' />" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_ACCEL:
|
case UI_ACCEL:
|
||||||
@ -719,6 +740,7 @@ function start() {
|
|||||||
parent = $("#row");
|
parent = $("#row");
|
||||||
}
|
}
|
||||||
hasAccel = true;
|
hasAccel = true;
|
||||||
|
if (data.visible) {
|
||||||
parent.append(
|
parent.append(
|
||||||
"<div id='id" +
|
"<div id='id" +
|
||||||
data.id +
|
data.id +
|
||||||
@ -739,6 +761,7 @@ function start() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
requestOrientationPermission();
|
requestOrientationPermission();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UPDATE_LABEL:
|
case UPDATE_LABEL:
|
||||||
@ -799,11 +822,9 @@ function start() {
|
|||||||
websock.onmessage = handleEvent;
|
websock.onmessage = handleEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sliderCache = {};
|
|
||||||
function sliderchange(number) {
|
function sliderchange(number) {
|
||||||
var val = $("#sl" + number).val();
|
var val = $("#sl" + number).val();
|
||||||
sliderCache[number] !== val && websock.send("slvalue:" + val + ":" + number);
|
websock.send("slvalue:" + val + ":" + number);
|
||||||
sliderCache[number] = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function numberchange(number) {
|
function numberchange(number) {
|
||||||
|
60
data/js/controls.min.js
vendored
60
data/js/controls.min.js
vendored
@ -9,7 +9,7 @@ function handleVisibilityChange(){if(!websockConnected&&!document.hidden){restar
|
|||||||
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){console.log(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;}
|
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){console.log(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"+
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -22,8 +22,9 @@ data.id+
|
|||||||
"' class='label label-wrap'>"+
|
"' class='label label-wrap'>"+
|
||||||
data.value+
|
data.value+
|
||||||
"</span>"+
|
"</span>"+
|
||||||
"</div>");break;case UI_BUTTON:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");}
|
||||||
parent.append("<div id='id"+
|
break;case UI_BUTTON:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='one columns card tcenter "+
|
"' class='one columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -41,8 +42,9 @@ data.id+
|
|||||||
data.id+
|
data.id+
|
||||||
", false)'>"+
|
", false)'>"+
|
||||||
data.value+
|
data.value+
|
||||||
"</button></div>");$("#btn"+data.id).on({touchstart:function(e){e.preventDefault();buttonclick(data.id,true);},touchend:function(e){e.preventDefault();buttonclick(data.id,false);},});break;case UI_SWITCHER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</button></div>");$("#btn"+data.id).on({touchstart:function(e){e.preventDefault();buttonclick(data.id,true);},touchend:function(e){e.preventDefault();buttonclick(data.id,false);},});}
|
||||||
parent.append("<div id='id"+
|
break;case UI_SWITCHER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='one columns card tcenter "+
|
"' class='one columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -63,8 +65,9 @@ data.id+
|
|||||||
(data.value=="1"?"checked":"")+
|
(data.value=="1"?"checked":"")+
|
||||||
"/></div>"+
|
"/></div>"+
|
||||||
"</label>"+
|
"</label>"+
|
||||||
"</div>");switcher(data.id,data.value);break;case UI_CPAD:case UI_PAD:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");switcher(data.id,data.value);}
|
||||||
parent.append("<div id='id"+
|
break;case UI_CPAD:case UI_PAD:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -111,8 +114,9 @@ data.id+
|
|||||||
data.id+
|
data.id+
|
||||||
"'>OK</a>":"")+
|
"'>OK</a>":"")+
|
||||||
"</nav>"+
|
"</nav>"+
|
||||||
"</div>");$("#pf"+data.id).on({touchstart:function(e){e.preventDefault();padclick(UP,data.id,true);},touchend:function(e){e.preventDefault();padclick(UP,data.id,false);},});$("#pl"+data.id).on({touchstart:function(e){e.preventDefault();padclick(LEFT,data.id,true);},touchend:function(e){e.preventDefault();padclick(LEFT,data.id,false);},});$("#pr"+data.id).on({touchstart:function(e){e.preventDefault();padclick(RIGHT,data.id,true);},touchend:function(e){e.preventDefault();padclick(RIGHT,data.id,false);},});$("#pb"+data.id).on({touchstart:function(e){e.preventDefault();padclick(DOWN,data.id,true);},touchend:function(e){e.preventDefault();padclick(DOWN,data.id,false);},});$("#pc"+data.id).on({touchstart:function(e){e.preventDefault();padclick(CENTER,data.id,true);},touchend:function(e){e.preventDefault();padclick(CENTER,data.id,false);},});break;case UI_SLIDER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");$("#pf"+data.id).on({touchstart:function(e){e.preventDefault();padclick(UP,data.id,true);},touchend:function(e){e.preventDefault();padclick(UP,data.id,false);},});$("#pl"+data.id).on({touchstart:function(e){e.preventDefault();padclick(LEFT,data.id,true);},touchend:function(e){e.preventDefault();padclick(LEFT,data.id,false);},});$("#pr"+data.id).on({touchstart:function(e){e.preventDefault();padclick(RIGHT,data.id,true);},touchend:function(e){e.preventDefault();padclick(RIGHT,data.id,false);},});$("#pb"+data.id).on({touchstart:function(e){e.preventDefault();padclick(DOWN,data.id,true);},touchend:function(e){e.preventDefault();padclick(DOWN,data.id,false);},});$("#pc"+data.id).on({touchstart:function(e){e.preventDefault();padclick(CENTER,data.id,true);},touchend:function(e){e.preventDefault();padclick(CENTER,data.id,false);},});}
|
||||||
parent.append("<div id='id"+
|
break;case UI_SLIDER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter card-slider "+
|
"' class='two columns card tcenter card-slider "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -130,8 +134,9 @@ data.value+
|
|||||||
data.value+
|
data.value+
|
||||||
"</span>"+
|
"</span>"+
|
||||||
"</div>"+
|
"</div>"+
|
||||||
"</div>");rangeSlider(!sliderContinuous);break;case UI_NUMBER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");rangeSlider(!sliderContinuous);}
|
||||||
parent.append("<div id='id"+
|
break;case UI_NUMBER:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -146,8 +151,9 @@ data.value+
|
|||||||
"' onchange='numberchange("+
|
"' onchange='numberchange("+
|
||||||
data.id+
|
data.id+
|
||||||
")' />"+
|
")' />"+
|
||||||
"</div>");break;case UI_TEXT_INPUT:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");}
|
||||||
parent.append("<div id='id"+
|
break;case UI_TEXT_INPUT:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -162,9 +168,11 @@ data.value+
|
|||||||
"' onchange='textchange("+
|
"' onchange='textchange("+
|
||||||
data.id+
|
data.id+
|
||||||
")' />"+
|
")' />"+
|
||||||
"</div>");break;case UI_TAB:$("#tabsnav").append("<li><a onmouseup='tabclick("+data.id+")' href='#tab"+data.id+"'>"+data.value+"</a></li>");$("#tabscontent").append("<div id='tab"+data.id+"'></div>");tabs=$(".tabscontent").tabbedContent({loop:true}).data("api");$("a").filter(function(){return $(this).attr("href")==="#click-to-switch";}).on("click",function(e){var tab=prompt("Tab to switch to (number or id)?");if(!tabs.switchTab(tab)){alert("That tab does not exist :\\");}
|
"</div>");}
|
||||||
e.preventDefault();});break;case UI_SELECT:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
break;case UI_TAB:if(data.visible){$("#tabsnav").append("<li><a onmouseup='tabclick("+data.id+")' href='#tab"+data.id+"'>"+data.value+"</a></li>");$("#tabscontent").append("<div id='tab"+data.id+"'></div>");tabs=$(".tabscontent").tabbedContent({loop:true}).data("api");$("a").filter(function(){return $(this).attr("href")==="#click-to-switch";}).on("click",function(e){var tab=prompt("Tab to switch to (number or id)?");if(!tabs.switchTab(tab)){alert("That tab does not exist :\\");}
|
||||||
parent.append("<div id='id"+
|
e.preventDefault();});}
|
||||||
|
break;case UI_SELECT:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -177,7 +185,8 @@ data.id+
|
|||||||
"' onchange='selectchange("+
|
"' onchange='selectchange("+
|
||||||
data.id+
|
data.id+
|
||||||
")' />"+
|
")' />"+
|
||||||
"</div>");break;case UI_OPTION:if(data.parentControl){var parent=$("#select"+data.parentControl);parent.append("<option id='option"+
|
"</div>");}
|
||||||
|
break;case UI_OPTION:if(data.parentControl){var parent=$("#select"+data.parentControl);parent.append("<option id='option"+
|
||||||
data.id+
|
data.id+
|
||||||
"' value='"+
|
"' value='"+
|
||||||
data.value+
|
data.value+
|
||||||
@ -190,7 +199,7 @@ break;case UI_MIN:if(data.parentControl){var parent=$("#id"+data.parentControl+"
|
|||||||
break;case UI_MAX:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("max",data.value);}}
|
break;case UI_MAX:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("max",data.value);}}
|
||||||
break;case UI_STEP:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("step",data.value);}}
|
break;case UI_STEP:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("step",data.value);}}
|
||||||
break;case UI_GRAPH:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
break;case UI_GRAPH:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
parent.append("<div id='id"+
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -205,8 +214,9 @@ data.id+
|
|||||||
data.label+
|
data.label+
|
||||||
"</figcaption>"+
|
"</figcaption>"+
|
||||||
"</figure>"+
|
"</figure>"+
|
||||||
"</div>");graphData[data.id]=restoreGraphData(data.id);renderGraphSvg(graphData[data.id],"graph"+data.id);break;case ADD_GRAPH_POINT:var ts=Math.round(new Date().getTime()/1000);graphData[data.id].push({x:ts,y:data.value});saveGraphData();renderGraphSvg(graphData[data.id],"graph"+data.id);break;case CLEAR_GRAPH:graphData[data.id]=[];saveGraphData();renderGraphSvg(graphData[data.id],"graph"+data.id);break;case UI_GAUGE:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");graphData[data.id]=restoreGraphData(data.id);renderGraphSvg(graphData[data.id],"graph"+data.id);}
|
||||||
parent.append("<div id='id"+
|
break;case ADD_GRAPH_POINT:var ts=Math.round(new Date().getTime()/1000);graphData[data.id].push({x:ts,y:data.value});saveGraphData();renderGraphSvg(graphData[data.id],"graph"+data.id);break;case CLEAR_GRAPH:graphData[data.id]=[];saveGraphData();renderGraphSvg(graphData[data.id],"graph"+data.id);break;case UI_GAUGE:var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -221,8 +231,9 @@ data.value+
|
|||||||
"' onchange='numberchange("+
|
"' onchange='numberchange("+
|
||||||
data.id+
|
data.id+
|
||||||
")' />"+
|
")' />"+
|
||||||
"</div>");break;case UI_ACCEL:if(hasAccel)break;var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
"</div>");}
|
||||||
hasAccel=true;parent.append("<div id='id"+
|
break;case UI_ACCEL:if(hasAccel)break;var parent;if(data.parentControl){parent=$("#tab"+data.parentControl);}else{parent=$("#row");}
|
||||||
|
hasAccel=true;if(data.visible){parent.append("<div id='id"+
|
||||||
data.id+
|
data.id+
|
||||||
"' class='two columns card tcenter "+
|
"' class='two columns card tcenter "+
|
||||||
colorClass(data.color)+
|
colorClass(data.color)+
|
||||||
@ -237,9 +248,10 @@ data.id+
|
|||||||
"'></div><pre class='accelerometeroutput"+
|
"'></div><pre class='accelerometeroutput"+
|
||||||
data.id+
|
data.id+
|
||||||
"'></pre>"+
|
"'></pre>"+
|
||||||
"</div>");requestOrientationPermission();break;case UPDATE_LABEL:$("#l"+data.id).html(data.value);break;case UPDATE_SWITCHER:switcher(data.id,data.value=="0"?0:1);break;case UPDATE_SLIDER:slider_move($("#id"+data.id),data.value,"100",false);break;case UPDATE_NUMBER:$("#num"+data.id).val(data.value);break;case UPDATE_TEXT_INPUT:$("#text"+data.id).val(data.value);break;case UPDATE_SELECT:$("#select"+data.id).val(data.value);break;case UPDATE_BUTTON:case UPDATE_PAD:case UPDATE_CPAD:break;case UPDATE_GAUGE:$("#gauge"+data.id).val(data.value);break;case UPDATE_ACCEL:break;default:console.error("Unknown type or event");break;}
|
"</div>");requestOrientationPermission();}
|
||||||
|
break;case UPDATE_LABEL:$("#l"+data.id).html(data.value);break;case UPDATE_SWITCHER:switcher(data.id,data.value=="0"?0:1);break;case UPDATE_SLIDER:slider_move($("#id"+data.id),data.value,"100",false);break;case UPDATE_NUMBER:$("#num"+data.id).val(data.value);break;case UPDATE_TEXT_INPUT:$("#text"+data.id).val(data.value);break;case UPDATE_SELECT:$("#select"+data.id).val(data.value);break;case UPDATE_BUTTON:case UPDATE_PAD:case UPDATE_CPAD:break;case UPDATE_GAUGE:$("#gauge"+data.id).val(data.value);break;case UPDATE_ACCEL:break;default:console.error("Unknown type or event");break;}
|
||||||
if(data.type>=UPDATE_OFFSET&&data.type<UI_INITIAL_GUI){var element=$("#id"+data.id);if(data.type==UPDATE_SLIDER){element.removeClass("slider-turquoise slider-emerald slider-peterriver slider-wetasphalt slider-sunflower slider-carrot slider-alizarin");element.addClass("slider-"+colorClass(data.color));}else{element.removeClass("turquoise emerald peterriver wetasphalt sunflower carrot alizarin");element.addClass(colorClass(data.color));}}};websock.onmessage=handleEvent;}
|
if(data.type>=UPDATE_OFFSET&&data.type<UI_INITIAL_GUI){var element=$("#id"+data.id);if(data.type==UPDATE_SLIDER){element.removeClass("slider-turquoise slider-emerald slider-peterriver slider-wetasphalt slider-sunflower slider-carrot slider-alizarin");element.addClass("slider-"+colorClass(data.color));}else{element.removeClass("turquoise emerald peterriver wetasphalt sunflower carrot alizarin");element.addClass(colorClass(data.color));}}};websock.onmessage=handleEvent;}
|
||||||
var sliderCache={};function sliderchange(number){var val=$("#sl"+number).val();sliderCache[number]!==val&&websock.send("slvalue:"+val+":"+number);sliderCache[number]=val;}
|
function sliderchange(number){var val=$("#sl"+number).val();websock.send("slvalue:"+val+":"+number);}
|
||||||
function numberchange(number){var val=$("#num"+number).val();websock.send("nvalue:"+val+":"+number);}
|
function numberchange(number){var val=$("#num"+number).val();websock.send("nvalue:"+val+":"+number);}
|
||||||
function textchange(number){var val=$("#text"+number).val();websock.send("tvalue:"+val+":"+number);}
|
function textchange(number){var val=$("#text"+number).val();websock.send("tvalue:"+val+":"+number);}
|
||||||
function tabclick(number){var val=$("#tab"+number).val();websock.send("tabvalue:"+val+":"+number);}
|
function tabclick(number){var val=$("#tab"+number).val();websock.send("tabvalue:"+val+":"+number);}
|
||||||
|
@ -134,18 +134,20 @@ public:
|
|||||||
void (*callback)(Control*, int);
|
void (*callback)(Control*, int);
|
||||||
String value;
|
String value;
|
||||||
ControlColor color;
|
ControlColor color;
|
||||||
|
bool visible;
|
||||||
uint16_t parentControl;
|
uint16_t parentControl;
|
||||||
Control* next;
|
Control* next;
|
||||||
|
|
||||||
static constexpr uint16_t noParent = 0xffff;
|
static constexpr uint16_t noParent = 0xffff;
|
||||||
|
|
||||||
Control(ControlType type, const char* label, void (*callback)(Control*, int), const String& value,
|
Control(ControlType type, const char* label, void (*callback)(Control*, int), const String& value,
|
||||||
ControlColor color, uint16_t parentControl = Control::noParent)
|
ControlColor color, bool visible = true, uint16_t parentControl = Control::noParent)
|
||||||
: type(type),
|
: type(type),
|
||||||
label(label),
|
label(label),
|
||||||
callback(callback),
|
callback(callback),
|
||||||
value(value),
|
value(value),
|
||||||
color(color),
|
color(color),
|
||||||
|
visible(visible),
|
||||||
parentControl(parentControl),
|
parentControl(parentControl),
|
||||||
next(nullptr)
|
next(nullptr)
|
||||||
{
|
{
|
||||||
@ -159,6 +161,7 @@ public:
|
|||||||
callback(control.callback),
|
callback(control.callback),
|
||||||
value(control.value),
|
value(control.value),
|
||||||
color(control.color),
|
color(control.color),
|
||||||
|
visible(control.visible),
|
||||||
parentControl(control.parentControl),
|
parentControl(control.parentControl),
|
||||||
next(control.next)
|
next(control.next)
|
||||||
{ }
|
{ }
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user