\n"
"
%s \n"
,_("Cameras")
,webui->cntlst[0]->camera_id
,webui->cntlst[0]->conf.camera_name);
webu_write(webui, response);
}
} else if (webui->cam_threads > 1){
/* Motion.conf + separate camera.conf file */
snprintf(response, sizeof (response),
"
\n"
"
%s \n"
"
\n"
"
%s \n"
,_("Cameras")
,_("All"));
webu_write(webui, response);
for (indx=1;indx <= webui->cam_count;indx++){
if (webui->cntlst[indx]->conf.camera_name == NULL){
snprintf(response, sizeof (response),
"
%s %d \n"
,webui->cntlst[indx]->camera_id
, _("Camera"), webui->cntlst[indx]->camera_id);
} else {
snprintf(response, sizeof (response),
"
%s \n"
,webui->cntlst[indx]->camera_id
,webui->cntlst[indx]->conf.camera_name
);
}
webu_write(webui, response);
}
}
snprintf(response, sizeof (response),"%s",
"
\n"
"
\n");
webu_write(webui, response);
}
static void webu_html_navbar_action(struct webui_ctx *webui) {
/* Write out the options included in the actions dropdown*/
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),
"
\n"
"
%s \n"
"
\n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
%s \n"
"
\n"
"
\n"
,_("Action")
,_("Start Event")
,_("End Event")
,_("Snapshot")
,_("Change Configuration")
,_("Write Configuration")
,_("Tracking")
,_("Pause")
,_("Start")
,_("Restart")
,_("Quit"));
webu_write(webui, response);
}
static void webu_html_navbar(struct webui_ctx *webui) {
/* Write the navbar section*/
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
"
\n");
webu_write(webui, response);
webu_html_navbar_camera(webui);
webu_html_navbar_action(webui);
snprintf(response, sizeof (response),
"
%s \n"
" \n"
"
\n"
,_("Help"));
webu_write(webui, response);
}
static void webu_html_config_notice(struct webui_ctx *webui) {
/* Print out the header description of which parameters are included based upon the
* webcontrol_parms that was specified
*/
char response[WEBUI_LEN_RESP];
if (webui->cntlst[0]->conf.webcontrol_parms == 0){
snprintf(response, sizeof (response),
" \n"
,_("No Configuration Options"));
} else if (webui->cntlst[0]->conf.webcontrol_parms == 1){
snprintf(response, sizeof (response),
" \n"
,_("Limited Configuration Options"));
} else if (webui->cntlst[0]->conf.webcontrol_parms == 2){
snprintf(response, sizeof (response),
" \n"
,_("Advanced Configuration Options"));
} else{
snprintf(response, sizeof (response),
" \n"
,_("Restricted Configuration Options"));
}
webu_write(webui, response);
}
static void webu_html_h3desc(struct webui_ctx *webui) {
/* Write out the status description for the camera */
char response[WEBUI_LEN_RESP];
if (webui->cam_threads == 1){
snprintf(response, sizeof (response),
" \n"
,_("All Cameras")
,(!webui->cntlst[0]->running)? _("Not running") :
(webui->cntlst[0]->lost_connection)? _("Lost connection"):
(webui->cntlst[0]->pause)? _("Paused"):_("Active")
);
webu_write(webui,response);
} else {
snprintf(response, sizeof (response),
" \n"
,_("All Cameras"));
webu_write(webui,response);
}
}
static void webu_html_config(struct webui_ctx *webui) {
/* Write out the options to put into the config dropdown
* We use html data attributes to store the values for the options
* We always set a cam_all00 attribute and if the value if different for
* any of our cameras, then we also add a cam_xxxxx which has the config
* value for camera xxxxx The javascript then decodes these to display
*/
char response[WEBUI_LEN_RESP];
int indx_parm, indx, diff_vals;
const char *val_main, *val_thread;
char *val_temp;
snprintf(response, sizeof (response),"%s",
"
\n");
webu_write(webui, response);
webu_html_config_notice(webui);
snprintf(response, sizeof (response),
" \n"
"
\n"
,_("Save"));
webu_write(webui, response);
}
static void webu_html_track(struct webui_ctx *webui) {
/* Write the section for handling the tracking function */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),
"
\n"
" \n"
"
\n"
,_("Pan/Tilt")
,_("Absolute Change")
,_("Center")
,_("Pan")
,_("Tilt")
,_("Save"));
webu_write(webui, response);
}
static void webu_html_strminfo(struct strminfo_ctx *strm_info, int indx) {
/* This determines all the items we need to know to specify links and
* stream sources for the page. The options are 0-3 as of this writing
* where 0 = full streams, 1 = substreams, 2 = static images and 3 is
* the legacy code for creating streams. So we need to assign not only
* what images are to be sent but also whether we have tls/ssl.
* There are WAY too many options for this.
*/
if (strm_info->cntlst[indx]->conf.stream_preview_method == 99){
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","");
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"%s","");
strm_info->port = strm_info->cntlst[indx]->conf.stream_port;
} else {
/* If using the main port,we need to insert a thread number into url*/
if (strm_info->cntlst[0]->conf.stream_port != 0) {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"/%d"
,strm_info->cntlst[indx]->camera_id);
strm_info->port = strm_info->cntlst[0]->conf.stream_port;
if (strm_info->cntlst[0]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
} else {
snprintf(strm_info->lnk_camid,WEBUI_LEN_LNK,"%s","");
strm_info->port = strm_info->cntlst[indx]->conf.stream_port;
if (strm_info->cntlst[indx]->conf.stream_tls) {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","https");
} else {
snprintf(strm_info->proto,WEBUI_LEN_LNK,"%s","http");
}
}
if (strm_info->motion_images){
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/motion");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/motion");
} else {
/* Assign what images and links we want */
if (strm_info->cntlst[indx]->conf.stream_preview_method == 1){
/* Substream for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/substream");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 2){
/* Static image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/current");
} else if (strm_info->cntlst[indx]->conf.stream_preview_method == 4){
/* Source image for preview */
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/source");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/source");
} else {
/* Full stream for preview (method 0 or 3)*/
snprintf(strm_info->lnk_ref,WEBUI_LEN_LNK,"%s","/stream");
snprintf(strm_info->lnk_src,WEBUI_LEN_LNK,"%s","/stream");
}
}
}
}
static void webu_html_preview(struct webui_ctx *webui) {
/* Write the initial version of the preview section. The javascript
* will change this section when user selects a different camera */
char response[WEBUI_LEN_RESP];
int indx, indx_st, preview_scale;
struct strminfo_ctx strm_info;
strm_info.cntlst = webui->cntlst;
snprintf(response, sizeof (response),"%s",
"
\n"
"
\n"
" \n"
" \n");
webu_write(webui, response);
indx_st = 1;
if (webui->cam_threads == 1) indx_st = 0;
for (indx = indx_st; indxcam_threads; indx++){
if (webui->cntlst[indx]->conf.stream_preview_newline){
snprintf(response, sizeof (response),"%s"," \n");
webu_write(webui, response);
}
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
preview_scale = 45;
} else {
preview_scale = webui->cntlst[indx]->conf.stream_preview_scale;
}
strm_info.motion_images = FALSE;
webu_html_strminfo(&strm_info,indx);
snprintf(response, sizeof (response),
" "
" \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src
,preview_scale);
webu_write(webui, response);
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
strm_info.motion_images = TRUE;
webu_html_strminfo(&strm_info,indx);
snprintf(response, sizeof (response),
" "
" \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src
,preview_scale);
webu_write(webui, response);
}
}
snprintf(response, sizeof (response),"%s",
"
\n"
" \n"
" \n"
"
\n");
webu_write(webui, response);
}
static void webu_html_script_action(struct webui_ctx *webui) {
/* Write the javascript action_click() function.
* We do not have a good notification section on the page so the successful
* submission and response is currently a empty if block for the future
* enhancement to somehow notify the user everything worked */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function event_reloadpage() {\n"
" window.location.reload();\n"
" }\n\n"
);
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" function action_click(actval) {\n"
" if (actval == \"config\"){\n"
" document.getElementById('trk_form').style.display=\"none\";\n"
" document.getElementById('cfg_form').style.display=\"inline\";\n"
" } else if (actval == \"track\"){\n"
" document.getElementById('cfg_form').style.display=\"none\";\n"
" document.getElementById('trk_form').style.display=\"inline\";\n"
" } else {\n"
" document.getElementById('cfg_form').style.display=\"none\";\n"
" document.getElementById('trk_form').style.display=\"none\";\n"
" var camstr = document.getElementById('h3_cam').getAttribute('data-cam');\n"
" var camnbr = camstr.substring(4,9);\n"
" var http = new XMLHttpRequest();\n"
" if ((actval == \"/detection/pause\") || (actval == \"/detection/start\")) {\n"
" http.addEventListener('load', event_reloadpage); \n"
" }\n"
);
webu_write(webui, response);
snprintf(response, sizeof (response),
" var url = \"%s://%s:%d/\"; \n"
,webui->hostproto, webui->hostname
,webui->cntlst[0]->conf.webcontrol_port);
webu_write(webui, response);
snprintf(response, sizeof (response),
" if (camnbr == \"all00\"){\n"
" url = url + \"%05d\";\n"
" } else {\n"
" url = url + camnbr;\n"
" }\n"
" url = url + actval;\n"
,webui->cntlst[0]->camera_id);
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" http.open(\"GET\", url, true);\n"
" http.onreadystatechange = function() {\n"
" if(http.readyState == 4 && http.status == 200) {\n"
" }\n"
" }\n"
" http.send(null);\n"
" }\n"
" document.getElementById('act_btn').style.display=\"none\"; \n"
" document.getElementById('cfg_value').value = '';\n"
" document.getElementById('cfg_parms').value = 'default';\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_camera_thread(struct webui_ctx *webui) {
/* Write the javascript thread IF conditions of camera_click() function */
char response[WEBUI_LEN_RESP];
int indx, indx_st, preview_scale;
struct strminfo_ctx strm_info;
indx_st = 1;
if (webui->cam_threads == 1) indx_st = 0;
strm_info.cntlst = webui->cntlst;
for (indx = indx_st; indx
cam_threads; indx++){
snprintf(response, sizeof (response),
" if (camid == \"cam_%05d\"){\n"
,webui->cntlst[indx]->camera_id);
webu_write(webui, response);
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
preview_scale = 45;
} else {
preview_scale = 95;
}
strm_info.motion_images = FALSE;
webu_html_strminfo(&strm_info, indx);
snprintf(response, sizeof (response),
" preview=\" "
" \" \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname,strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src, preview_scale);
webu_write(webui, response);
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
strm_info.motion_images = TRUE;
webu_html_strminfo(&strm_info, indx);
snprintf(response, sizeof (response),
" preview=preview + \" "
" \" \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname,strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src, preview_scale);
webu_write(webui, response);
}
if (webui->cntlst[indx]->conf.camera_name == NULL){
snprintf(response, sizeof (response),
" header=\"\"\n"
,_("Camera")
, webui->cntlst[indx]->camera_id
,(!webui->cntlst[indx]->running)? _("Not running") :
(webui->cntlst[indx]->lost_connection)? _("Lost connection"):
(webui->cntlst[indx]->pause)? _("Paused"):_("Active")
);
} else {
snprintf(response, sizeof (response),
" header=\"\"\n"
, webui->cntlst[indx]->conf.camera_name
,(!webui->cntlst[indx]->running)? _("Not running") :
(webui->cntlst[indx]->lost_connection)? _("Lost connection"):
(webui->cntlst[indx]->pause)? _("Paused"):_("Active")
);
}
webu_write(webui, response);
snprintf(response, sizeof (response),"%s"," }\n");
webu_write(webui, response);
}
return;
}
static void webu_html_script_camera_all(struct webui_ctx *webui) {
/* Write the javascript "All" IF condition of camera_click() function */
char response[WEBUI_LEN_RESP];
int indx, indx_st, preview_scale;
struct strminfo_ctx strm_info;
indx_st = 1;
if (webui->cam_threads == 1) indx_st = 0;
strm_info.cntlst = webui->cntlst;
snprintf(response, sizeof (response), " if (camid == \"cam_all00\"){\n");
webu_write(webui, response);
for (indx = indx_st; indxcam_threads; indx++){
if (indx == indx_st){
snprintf(response, sizeof (response),"%s"," preview = \"\";\n");
webu_write(webui, response);
}
if (webui->cntlst[indx]->conf.stream_preview_newline){
snprintf(response, sizeof (response),"%s"," preview = preview + \" \";\n");
webu_write(webui, response);
}
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
preview_scale = 45;
} else {
preview_scale = webui->cntlst[indx]->conf.stream_preview_scale;
}
strm_info.motion_images = FALSE;
webu_html_strminfo(&strm_info, indx);
snprintf(response, sizeof (response),
" preview = preview + \" "
" \"; \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src
,preview_scale);
webu_write(webui, response);
if (webui->cntlst[indx]->conf.stream_preview_method == 3){
strm_info.motion_images = TRUE;
webu_html_strminfo(&strm_info, indx);
snprintf(response, sizeof (response),
" preview = preview + \" "
" \"; \n"
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_ref
,strm_info.proto, webui->hostname, strm_info.port
,strm_info.lnk_camid, strm_info.lnk_src
,preview_scale);
webu_write(webui, response);
}
}
snprintf(response, sizeof (response),
" header=\"\"\n"
" }\n"
,_("All Cameras"));
webu_write(webui, response);
return;
}
static void webu_html_script_camera(struct webui_ctx *webui) {
/* Write the javascript camera_click() function */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function camera_click(camid) {\n"
" var preview = \"\";\n"
" var header = \"\";\n");
webu_write(webui, response);
webu_html_script_camera_thread(webui);
webu_html_script_camera_all(webui);
snprintf(response, sizeof (response),"%s",
" document.getElementById(\"id_preview\").innerHTML = preview; \n"
" document.getElementById(\"id_header\").innerHTML = header; \n"
" document.getElementById('cfg_form').style.display=\"none\"; \n"
" document.getElementById('trk_form').style.display=\"none\"; \n"
" document.getElementById('cam_btn').style.display=\"none\"; \n"
" document.getElementById('cfg_value').value = '';\n"
" document.getElementById('cfg_parms').value = 'default';\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_menucam(struct webui_ctx *webui) {
/* Write the javascript display_cameras() function */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function display_cameras() {\n"
" document.getElementById('act_btn').style.display = 'none';\n"
" if (document.getElementById('cam_btn').style.display == 'block'){\n"
" document.getElementById('cam_btn').style.display = 'none';\n"
" } else {\n"
" document.getElementById('cam_btn').style.display = 'block';\n"
" }\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_menuact(struct webui_ctx *webui) {
/* Write the javascript display_actions() function */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function display_actions() {\n"
" document.getElementById('cam_btn').style.display = 'none';\n"
" if (document.getElementById('act_btn').style.display == 'block'){\n"
" document.getElementById('act_btn').style.display = 'none';\n"
" } else {\n"
" document.getElementById('act_btn').style.display = 'block';\n"
" }\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_evtclk(struct webui_ctx *webui) {
/* Write the javascript 'click' EventListener */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" document.addEventListener('click', function(event) {\n"
" const dropCam = document.getElementById('cam_drop');\n"
" const dropAct = document.getElementById('act_drop');\n"
" if (!dropCam.contains(event.target) && !dropAct.contains(event.target)) {\n"
" document.getElementById('cam_btn').style.display = 'none';\n"
" document.getElementById('act_btn').style.display = 'none';\n"
" }\n"
" });\n\n");
webu_write(webui, response);
}
static void webu_html_script_cfgclk(struct webui_ctx *webui) {
/* Write the javascript config_click function
* We do not have a good notification section on the page so the successful
* submission and response is currently a empty if block for the future
* enhancement to somehow notify the user everything worked */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function config_click() {\n"
" var camstr = document.getElementById('h3_cam').getAttribute('data-cam');\n"
" var camnbr = camstr.substring(4,9);\n"
" var opts = document.getElementById('cfg_parms');\n"
" var optsel = opts.options[opts.selectedIndex].value;\n"
" var baseval = document.getElementById('cfg_value').value;\n"
" var http = new XMLHttpRequest();\n");
webu_write(webui, response);
snprintf(response, sizeof (response),
" var url = \"%s://%s:%d/\"; \n"
,webui->hostproto, webui->hostname
,webui->cntlst[0]->conf.webcontrol_port);
webu_write(webui, response);
snprintf(response, sizeof (response),
" var optval=encodeURI(baseval);\n"
" if (camnbr == \"all00\"){\n"
" url = url + \"%05d\";\n"
" } else {\n"
" url = url + camnbr;\n"
" }\n"
,webui->cntlst[0]->camera_id);
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" url = url + \"/config/set?\" + optsel + \"=\" + optval;\n"
" http.open(\"GET\", url, true);\n"
" http.onreadystatechange = function() {\n"
" if(http.readyState == 4 && http.status == 200) {\n"
" }\n"
" }\n"
" http.send(null);\n"
" document.getElementById('cfg_value').value = \"\";\n"
" opts.options[opts.selectedIndex].setAttribute('data-'+camstr,baseval);\n"
" opts.value = 'default';\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_cfgchg(struct webui_ctx *webui) {
/* Write the javascript option_change function */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function config_change() {\n"
" var camSel = 'data-'+ document.getElementById('h3_cam').getAttribute('data-cam');\n"
" var opts = document.getElementById('cfg_parms');\n"
" var optval = opts.options[opts.selectedIndex].getAttribute(camSel);\n"
" if (optval == null){\n"
" optval = opts.options[opts.selectedIndex].getAttribute('data-cam_all00');\n"
" }\n"
" document.getElementById('cfg_value').value = optval;\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_trkchg(struct webui_ctx *webui) {
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function track_change() {\n"
" var opts = document.getElementById('trk_option');\n"
" var optval = opts.options[opts.selectedIndex].getAttribute('data-trk');\n"
" if (optval == 'pan'){\n"
" document.getElementById('trk_panx').disabled=false;\n"
" document.getElementById('trk_tilty').disabled = false;\n"
" document.getElementById('trk_lblx').style.display='none';\n"
" document.getElementById('trk_lbly').style.display='none';\n"
" document.getElementById('trk_lblpan').style.display='inline';\n"
" document.getElementById('trk_lbltilt').style.display='inline';\n");
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" } else if (optval =='abs'){\n"
" document.getElementById('trk_panx').disabled=false;\n"
" document.getElementById('trk_tilty').disabled = false;\n"
" document.getElementById('trk_lblx').value = 'X';\n"
" document.getElementById('trk_lbly').value = 'Y';\n"
" document.getElementById('trk_lblpan').style.display='none';\n"
" document.getElementById('trk_lbltilt').style.display='none';\n"
" document.getElementById('trk_lblx').style.display='inline';\n"
" document.getElementById('trk_lbly').style.display='inline';\n");
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" } else {\n"
" document.getElementById('cfg_form').style.display='none';\n"
" document.getElementById('trk_panx').disabled=true;\n"
" document.getElementById('trk_tilty').disabled = true;\n"
" }\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script_trkclk(struct webui_ctx *webui) {
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
" function track_click() {\n"
" var camstr = document.getElementById('h3_cam').getAttribute('data-cam');\n"
" var camnbr = camstr.substring(4,9);\n"
" var opts = document.getElementById('trk_option');\n"
" var optsel = opts.options[opts.selectedIndex].getAttribute('data-trk');\n"
" var optval1 = document.getElementById('trk_panx').value;\n"
" var optval2 = document.getElementById('trk_tilty').value;\n"
" var http = new XMLHttpRequest();\n");
webu_write(webui, response);
snprintf(response, sizeof (response),
" var url = \"%s://%s:%d/\"; \n"
,webui->hostproto, webui->hostname
,webui->cntlst[0]->conf.webcontrol_port);
webu_write(webui, response);
snprintf(response, sizeof (response),
" if (camnbr == \"all00\"){\n"
" url = url + \"%05d\";\n"
" } else {\n"
" url = url + camnbr;\n"
" }\n"
,webui->cntlst[0]->camera_id);
webu_write(webui, response);
snprintf(response, sizeof (response),"%s",
" if (optsel == 'pan'){\n"
" url = url + '/track/set?pan=' + optval1 + '&tilt=' + optval2;\n"
" } else if (optsel == 'abs') {\n"
" url = url + '/track/set?x=' + optval1 + '&y=' + optval2;\n"
" } else {\n"
" url = url + '/track/center'\n"
" }\n"
" http.open(\"GET\", url, true);\n"
" http.onreadystatechange = function() {\n"
" if(http.readyState == 4 && http.status == 200) {\n"
" }\n"
" }\n"
" http.send(null);\n"
" }\n\n");
webu_write(webui, response);
}
static void webu_html_script(struct webui_ctx *webui) {
/* Write the javascripts */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s", " \n");
webu_write(webui, response);
}
static void webu_html_body(struct webui_ctx *webui) {
/* Write the body section of the form */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s","\n");
webu_write(webui, response);
webu_html_navbar(webui);
webu_html_h3desc(webui);
webu_html_config(webui);
webu_html_track(webui);
webu_html_preview(webui);
webu_html_script(webui);
snprintf(response, sizeof (response),"%s", "\n");
webu_write(webui, response);
}
static void webu_html_page(struct webui_ctx *webui) {
/* Write the main page html */
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),
"\n"
"\n",webui->lang);
webu_write(webui, response);
webu_html_head(webui);
webu_html_body(webui);
snprintf(response, sizeof (response),"%s", "\n");
webu_write(webui, response);
}
void webu_html_badreq(struct webui_ctx *webui) {
char response[WEBUI_LEN_RESP];
snprintf(response, sizeof (response),"%s",
"\n"
"\n"
"\n"
"Bad Request
\n"
"The server did not understand your request.
\n"
"\n"
"\n");
webu_write(webui, response);
return;
}
void webu_html_main(struct webui_ctx *webui) {
/* Note some detection and config requested actions call the
* action function. This is because the legacy interface
* put these into those pages. We put them together here
* based upon the structure of the new interface
*/
int retcd;
retcd = 0;
if (strlen(webui->uri_camid) == 0){
webu_html_page(webui);
} else if ((!strcmp(webui->uri_cmd1,"config")) &&
(!strcmp(webui->uri_cmd2,"write"))) {
webu_process_action(webui);
} else if (!strcmp(webui->uri_cmd1,"config")) {
retcd = webu_process_config(webui);
} else if (!strcmp(webui->uri_cmd1,"action")){
webu_process_action(webui);
} else if (!strcmp(webui->uri_cmd1,"detection")){
webu_process_action(webui);
} else if (!strcmp(webui->uri_cmd1,"track")){
retcd = webu_process_track(webui);
} else{
MOTION_LOG(INF, TYPE_STREAM, NO_ERRNO,
_("Invalid action requested: >%s< >%s< >%s<")
,webui->uri_camid, webui->uri_cmd1, webui->uri_cmd2);
retcd = -1;
}
if (retcd < 0) webu_html_badreq(webui);
return;
}