mirror of
https://github.com/s00500/ESPUI.git
synced 2024-11-22 04:00:55 +00:00
Allow Max control to add maxlength to text input. Update docs.
This commit is contained in:
parent
254912aee5
commit
6a513e9f65
11
README.md
11
README.md
@ -267,6 +267,17 @@ The textinput works very similar like the number input but with a string. You
|
|||||||
can enter a String into it and when you are done with your change it is sent to
|
can enter a String into it and when you are done with your change it is sent to
|
||||||
the ESP.
|
the ESP.
|
||||||
|
|
||||||
|
If you attach a Max control to the text input then a max length will be applied
|
||||||
|
to the control.
|
||||||
|
|
||||||
|
```
|
||||||
|
text = ESPUI.text("Label", callback, ControlColor::Dark, "Initial value");
|
||||||
|
ESPUI.addControl(ControlType::Max, "", "32", ControlColor::None, text);
|
||||||
|
```
|
||||||
|
|
||||||
|
However even with a set maximum length, user input should still be validated
|
||||||
|
because it is easy to bypass client-side checks.
|
||||||
|
|
||||||
#### Graph
|
#### Graph
|
||||||
|
|
||||||
![graph](https://github.com/s00500/ESPUI/blob/master/docs/ui_graph.png)
|
![graph](https://github.com/s00500/ESPUI/blob/master/docs/ui_graph.png)
|
||||||
|
6
data/js/controls.js
vendored
6
data/js/controls.js
vendored
@ -441,9 +441,15 @@ function start() {
|
|||||||
if (data.parentControl) {
|
if (data.parentControl) {
|
||||||
var parent = $("#id" + data.parentControl + " input");
|
var parent = $("#id" + data.parentControl + " input");
|
||||||
if (parent.size()) {
|
if (parent.size()) {
|
||||||
|
if(!parent.attr("type")) {
|
||||||
|
//type is not set so therefore it is a text input
|
||||||
|
parent.attr("maxlength", data.value);
|
||||||
|
} else {
|
||||||
|
//type might be range (slider) or number
|
||||||
parent.attr("max", data.value);
|
parent.attr("max", data.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UI_STEP:
|
case UI_STEP:
|
||||||
|
2
data/js/controls.min.js
vendored
2
data/js/controls.min.js
vendored
@ -26,7 +26,7 @@ data.selected+
|
|||||||
data.label+
|
data.label+
|
||||||
"</option>");}
|
"</option>");}
|
||||||
break;case UI_MIN:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("min",data.value);}}
|
break;case UI_MIN:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){parent.attr("min",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_MAX:if(data.parentControl){var parent=$("#id"+data.parentControl+" input");if(parent.size()){if(!parent.attr("type")){parent.attr("maxlength",data.value);}else{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:if(data.visible){addToHTML(data);graphData[data.id]=restoreGraphData(data.id);renderGraphSvg(graphData[data.id],"graph"+data.id);}
|
break;case UI_GRAPH:if(data.visible){addToHTML(data);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_ACCEL:if(hasAccel)break;hasAccel=true;if(data.visible){addToHTML(data);requestOrientationPermission();}
|
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_ACCEL:if(hasAccel)break;hasAccel=true;if(data.visible){addToHTML(data);requestOrientationPermission();}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user