factory webcontrols
- Description:
Implements Javascript mechanisms to dialog with a connected object via a web page.
- In order to use these functionnalities, use a construct of the form:
<html> <head> <!-- page title and others head elements --> <link rel='stylesheet' href='https://line.gitlabpages.inria.fr/aide-group/esp32gpiocontrol/webcontrols.css'/> <script type='text/javascript' src='https://line.gitlabpages.inria.fr/aide-group/esp32gpiocontrol/webcontrols.js'></script> </head> <body style='width:800px'> <!-- page content --> </body> </html>
- To add a control button in this framewrok, simply introduce a construct of the form, adjusting the style at will:
<div class='button-ba'> <button onclick='doButton(this)' style='background-color:yellow'>Do it</button> <!-- other buttons --> </div>
Members
(static) verbose
- Description:
Defines if the curl call is verbose.
- If true output a message in the
<div id='console' ...
before and after the call.
- If true output a message in the
Defines if the curl call is verbose.
- If true output a message in the
<div id='console' ...
before and after the call.
Methods
(static) addButtonOnOff(id, options, callback)
- Description:
Creates a button which is alternatively on and off.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | A unique ID to index the HTML element |
options |
object | Optional options, defining the element on and off text and color, and optional CSS style directives:
|
callback |
callback | A |
(static) addButtonRange(id, options, callback)
- Description:
Creates a button to input a numerical value.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | A unique ID to index the HTML element |
options |
object | Optional options, defining the element value minimal, maximal and initial default value, the text input number of chars, the slider width in pixel, and optional CSS style directives:
|
callback |
callback | A
|
(static) addConsole(verbose)
- Description:
Adds a textual console to print some log information.
- It is inserted in the HTML using a construct of the form:
<script>webcontrols.addConsole();</script>
- The
webcontrols.consoleLog(string)
andwebcontrols.consoleClear()
functions allows to use the console.
Parameters:
Name | Type | Description |
---|---|---|
verbose |
boolean | If true the curl function outputs a message before and after the call. |
(static) consoleLog(text)
- Description:
Prints a message in the console.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The message string, without HTML tag, a newline is added. |
(static) loadJSON(url, callbackopt)
- Description:
Gets a remote JSON file.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | The JSON file URL. |
||
callback |
callback |
<optional> |
function(value){}
|
The callback that handles the JSON returned value, as a text. |
(static) consoleClear()
- Description:
Clears the text in the console.
(static) curl(urlopt, inputopt, methodopt, callbackopt) → {string}
- Description:
Performs a Javascript HTTP request to dialog with a web service and returns response.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string |
<optional> |
""
|
The HTTP URL.
|
input |
string |
<optional> |
""
|
The URL query or content:
|
method |
string |
<optional> |
"GET"
|
Either |
callback |
callback |
<optional> |
function(value){}
|
The callback that handles the query return value.
|
Returns:
The response value, or an error message, if any.
- Type
- string