µTasker Forum
µTasker Forum => µTasker general => Topic started by: MirceaMurar on June 12, 2016, 09:13:57 AM
-
Hello Mark,
I am trying to get familiar with the simulator and how to interface a webpage with the uTasker operating system.
I achieved some basic functionalities and got an idea of how webpages are connected to uTasker.
What I would like to achieve next is something similar to this (please see attached picture).
Within a first html page the user has the possibility to jog an axis and save positions.
Then, in a configuration html page I would like to load and display saved positions for further configuration (something similar to attached picture).
Therefore the question is if it is possible to load a "select" HTML element with available options (options shall be saved within an array or on SD card) and let's say when a button is pressed to find out which are the options selected by the web page user.
Could you please provide some hints of how to manage this html element.
Best regards,
Mircea.
-
Hi
There are several examples of using a "select" element (drop-down list) in the web pages as used by the V1.4 project. The one presently selected is reported when the form is executed (eg. save button pressed).
Another way to control "select" elements - and more generally for various other types - is to use javascript to automatically send the form (execute a script) when a selection changes (onchange event) [various others like onclick or are also possible].
It is best to build the web page as pure http/javascript with static (dummy) values first to get the basic layout and get/puts operating. Then add the interaction to control what is actually displayed or replace parts with dynamically generated elements. After adding and testing each control one step at a time you will then achieve the complete page operation as desired.
Regards
Mark
-
Hi Mircea,
what we are doing in our projects to load data via javascript is the following:
1. Create a handler for you commands in "fnHandleWeb" in webInterface.c
if(uMemcmp(ptrData,"#yourCmd",8) == 0){
return fnHandleDynamicQuery(ptrData, http_session);
}
This will check if the string after the / in the URL is "#yourCmd" (e.g. 192.168.0.1/#yourCmd)
The # sign is there because there is no webPage starting with this char.
2. Set up the handler:
char fnHandleDynamicQuery(CHAR *ptrData, HTTP *http_session){
char buff[BUFF_SIZE] = {0}; //create a buffer with specified size
uMemset(buff,0,BUFF_SIZE); //empty the buffer
//fill the buffer here with the data you would like to display
//set the Buffer as file to be displayed
http_session->ptrFileStart = (unsigned char*)buff;
http_session->ucMimeType = MIME_HTML; // force HTML type
http_session->cDisplayFile = 0;
http_session->FileLength = len; //len is the length of the data you inserted into the buffer
return DISPLAY_INTERNAL;
}
3. Get the code with Javascript in your webpage (keyword: XMLHttpRequest)
I hope this helps you
Regards
Paul
-
Dear all,
thanks for your hints I will be testing this week and let you know if I succeeded.
Best regards,
Mircea.