diff --git a/index.php b/index.php index ef305ba..09e09d0 100644 --- a/index.php +++ b/index.php @@ -4,7 +4,17 @@ if( $CUser->Data['access'] > 5 ){ UI_PageHeaderExt( 'rgoose_general.js', - array('rgoose_timeline.js','rgoose_camera_editor.js','rgoose_mediaserver_module.js','rgoose_sysmap_editor.js','rgoose_location_editor.js','rgoose_dashboard.js', 'rgoose_devices_module.js', 'rgoose_users.js', 'rgoose_logs.js', 'rgoose_main.js') + array( 'rgoose_timeline.js', + 'rgoose_devices.js', + 'rgoose_cameras.js', + 'rgoose_mediaserver_module.js', + 'rgoose_sysmap_editor.js', + 'rgoose_location_editor.js', + 'rgoose_dashboard.js', + 'rgoose_users.js', + 'rgoose_logs.js', + 'rgoose_main.js' + ) ); } else { UI_PageHeaderExt( diff --git a/lib/controller/AddCameraNode.php b/lib/controller/AddCameraNode.php deleted file mode 100644 index 04cd0ba..0000000 --- a/lib/controller/AddCameraNode.php +++ /dev/null @@ -1,93 +0,0 @@ -Data['id'] > 1 ){ - if( $CUser->Data['access'] > 5 ){ - $Data = array(); - if(isset($_POST['SITEID'])) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; - if(isset($_POST['CID'])) $CamID = intval($_POST['CID']); else $CamID = 0; - if(isset($_POST['CTYPE'])) $CCTYPE = intval($_POST['CTYPE']); else $CCTYPE = 0; - if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; - if(isset($_POST['PTZ'])) $PTZ = intval($_POST['PTZ']); else $PTZ = 0; - if(isset($_POST['UART'])) $UART = intval($_POST['UART']); else $UART = 0; - if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; - if(isset($_POST['FMAX'])) $FMAX = floatval($_POST['FMAX']); else $FMAX = 0; - if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; - if(isset($_POST['TILTMODE'])) $TILTMODE = intval($_POST['TILTMODE']); else $TILTMODE = 0; - if(isset($_POST['PANMODE'])) $PANMODE = intval($_POST['PANMODE']); else $PANMODE = 0; - if(isset($_POST['PANANG'])) $PANANG = floatval( $_POST['PANANG']); else $PANANG = 360.0; - if(isset($_POST['TILTANG'])) $TILTANG = floatval( $_POST['TILTANG']); else $TILTANG = 90.0; - if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; - - if( $CSTR && ( $CCTYPE == ARGUS_ANALOG_STATIC_CAMERA || $CCTYPE == ARGUS_ANALOG_PTZ_CAMERA || $CCTYPE == ARGUS_IP_STATIC_CAMERA || $CCTYPE == ARGUS_IP_PTZ_CAMERA ) ){ - $QS = "SELECT * FROM `media_streams` WHERE `id`={$CSTR}"; - $T = $DATABASE->Query( $QS, false ); - $QS = "SELECT `id` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0 LIMIT 1"; - $CC = $DATABASE->Query( $QS, false ); - $ServerNODE = $CC[0]['id']; - if( count( $T ) ){ - $STREAM = $T[0]; - if( $CCTYPE == ARGUS_ANALOG_STATIC_CAMERA || $CCTYPE == ARGUS_ANALOG_PTZ_CAMERA ){ - $CAMUUID = md5( $SiteID.$CUser->Data['selected_site'].$STRRAM['mrl'] ); - // Create Camera Object Based On Stream - $QS = "INSERT INTO `cameras` SET `site_id`={$SiteID}, `node_id`=0, `online`=1, `type`={$CCTYPE}, `hardware`='Local_Grabber', `status`=0, uuid='{$CAMUUID}'"; - $DATABASE->Query( $QS, false ); - $CamID = $DATABASE->getLastInsertID(); - }; - if( $CamID != 0 ){ - if(isset($_POST['LAB'])) $CAM_NAM = $DATABASE->escape( $_POST['LAB'] ); else $CAM_NAME = 'CAM_' . $CamID; - $QS = "INSERT INTO nodes SET site_id={$SiteID}, type={$CCTYPE}, aux_id={$CamID}, aux_parameter={$STREAM['id']}, name='{$CAM_NAM}'"; - $DATABASE->Query( $QS, false ); - $NodeID = $DATABASE->getLastInsertID(); - if( $NodeID > 0 ){ - $QS = "UPDATE cameras SET protocol_aux='{$PROTOID}', tilt_angles={$TILTANG}, tilt_model={$TILTMODE}, pan_angles={$PANANG}, pan_model={$PANMODE}, node_id={$NodeID}, type={$CCTYPE}, protocol={$PTZ}, uart_id={$UART}, imager_type={$IMSIZE}, min_f={$FMIN}, max_f={$FMAX}, status=2 WHERE id={$CamID}"; - $DATABASE->Query( $QS, false ); - $QS = "INSERT INTO `access_log` SET `ts`=NOW(), `user_id`={$CUser->Data['id']}, `cmd`=13, `dataset`='{$LOG_DATA}'"; - $DATABASE->Query( $QS, false ); - if( $CCTYPE == ARGUS_ANALOG_STATIC_CAMERA || $CCTYPE == ARGUS_ANALOG_PTZ_CAMERA ){ - $RMD5 = md5( $CamID.' 30 '.$SiteID ); - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=30, `md5`='{$RMD5}', `aux_id`={$CamID}, `device`='Analog Video'"; - $DATABASE->Query( $QS, false ); - $AV_out_pin = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=4"; - $DATABASE->Query( $QS, false ); - } else { - $RMD5 = md5( $CamID.' 130 '.$SiteID ); - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=130, `md5`='{$RMD5}', `aux_id`={$CamID}, `device`='IP Video'"; - $DATABASE->Query( $QS, false ); - $DV_out_pin = $DATABASE->getLastInsertID(); - $RMD5 = md5( $CamID.' 100 '.$SiteID ); - $QS = "SELECT `ip` FROM `cameras` WHERE `id`={$CamID}"; - $CC = $DATABASE->Query( $QS, false ); - $IP = $CC[0]['ip']; - $QS = "INSERT INTO `resources` SET `node_id`={$NodeID}, `type`=100, `md5`='{$RMD5}', `aux_id`={$CamID}, `device`='{$IP}'"; - $DATABASE->Query( $QS, false ); - $NET_pin = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$DV_out_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=6"; - $DATABASE->Query( $QS, false ); - }; - if( $CCTYPE == ARGUS_ANALOG_PTZ_CAMERA || $CCTYPE == ARGUS_IP_PTZ_CAMERA ){ - if( $PTZ > 0 && $PTZ < 3 ){ - $RMD5 = md5( $CamID.' 1 '.$SiteID ); - $QS = "INSERT INTO `resources` SET`node_id`={$NodeID}, `type`=1, `md5`='{$RMD5}', `aux_id`={$CamID}, `device`='PTZ Uart'"; - $DATABASE->Query( $QS, false ); - $SERIAL_out_pin = $DATABASE->getLastInsertID(); - $QS = "SELECT `re`.`node_id` as `node`, `re`.`id` as `aux` FROM `cameras` `ca` LEFT JOIN `uart_settings` `us` ON `us`.`id`=`ca`.`uart_id` LEFT JOIN `resources` `re` ON `us`.`resource_id`=`re`.`id` WHERE `ca`.`id`={$CamID}"; - $CC = $DATABASE->Query( $QS, false ); - $SERIAL_in_NODE = $CC[0]['node']; - $SERIAL_in_PIN = $CC[0]['aux']; - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$AV_out_pin}, `to`={$SERIAL_in_NODE}, `to_aux`={$SERIAL_in_PIN}, `type`=1"; - $DATABASE->Query( $QS, false ); - } else { - $QS = "INSERT INTO `connections` SET `site_id`={$SiteID}, `from`={$NodeID}, `from_aux`={$NET_pin}, `to`={$ServerNODE}, `to_aux`=0, `type`=2"; - $DATABASE->Query( $QS, false ); - }; - }; - }; - }; - }; - }; - }; - } else { - header('location: /'); - }; -?> \ No newline at end of file diff --git a/lib/controller/addCameraNode.php b/lib/controller/addCameraNode.php new file mode 100644 index 0000000..7db084d --- /dev/null +++ b/lib/controller/addCameraNode.php @@ -0,0 +1,36 @@ +Data['id'] > 1 ){ + if( $CUser->Data['access'] > 5 ){ + $Data = array(); + if(isset($_POST['SITEID'])) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; + if(isset($_POST['CID'])) $CamID = intval($_POST['CID']); else $CamID = 0; + if(isset($_POST['CTYPE'])) $CCTYPE = intval($_POST['CTYPE']); else $CCTYPE = 0; + if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; + if(isset($_POST['PTZ'])) $PTZ = intval($_POST['PTZ']); else $PTZ = 0; + if(isset($_POST['UART'])) $UART = intval($_POST['UART']); else $UART = 0; + if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; + if(isset($_POST['FMAX'])) $FMAX = floatval($_POST['FMAX']); else $FMAX = 0; + if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; + if(isset($_POST['TILTMODE'])) $TILTMODE = intval($_POST['TILTMODE']); else $TILTMODE = 0; + if(isset($_POST['PANMODE'])) $PANMODE = intval($_POST['PANMODE']); else $PANMODE = 0; + if(isset($_POST['PANANG'])) $PANANG = floatval( $_POST['PANANG']); else $PANANG = 360.0; + if(isset($_POST['TILTANG'])) $TILTANG = floatval( $_POST['TILTANG']); else $TILTANG = 90.0; + if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; + if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; + if( $CSTR && $CNAME!='' ){ + $RV = false; + switch( $CCTYPE ){ + case ARGUS_ANALOG_STATIC_CAMERA: $RV = addAnalogStaticCamera( $SiteID, $CNAME, $CSTR, $IMSIZE, $FMIN ); break; + case ARGUS_ANALOG_PTZ_CAMERA: $RV = addAnalogPtzCamera( $SiteID, $CNAME, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); break; + case ARGUS_IP_STATIC_CAMERA: $RV = addAnalogStaticCamera( $SiteID, $CNAME, $CamID, $CSTR, $IMSIZE, $FMIN ); break; + case ARGUS_IP_PTZ_CAMERA: $RV = addAnalogPtzCamera( $SiteID, $CNAME, $CamID, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID ); break; + }; + } else { + + }; + }; + } else { + header('location: /'); + }; +?> \ No newline at end of file diff --git a/lib/controller/addNetworkNode.php b/lib/controller/addNetworkNode.php index 66e6c95..a3a040e 100644 --- a/lib/controller/addNetworkNode.php +++ b/lib/controller/addNetworkNode.php @@ -1,77 +1,151 @@ Data['id'] > 1 ){ - $SiteID = intval($_POST['NID']); - $NodeType = intval($_POST['TYPE']); - $Data['success'] = false; - if( $NodeType ){ - switch( $NodeType ){ - case 1://Als - case 2://Lfs - case 3://Pls - case 4://pls - $QS = "INSERT INTO `lrf_sensors` SET `type_id`={$NodeType}, `site_id`={$SiteID}"; - $DATABASE->Query( $QS, false ); - $DevID = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `nodes` SET `type`={$NodeType}, `site_id`={$SiteID}, `aux_id`={$DevID}"; - $DATABASE->Query( $QS, false ); - $NODEID = $DATABASE->getLastInsertID(); - $MM = md5(microtime()); - $QS = "INSERT INTO sockets SET node_id={$NODEID}, `aux_id`={$DevID}, `mode`=" . COM_MODE_IN . ", `type`=" . COM_TYPE_UART . ", binded=0, md5='{$MM}', `name`='Device Control Line'"; - $DATABASE->Query( $QS, false ); - $MM = md5(microtime()); - $QS = "INSERT INTO sockets SET node_id={$NODEID}, `aux_id`={$DevID}, `mode`=" . COM_MODE_OUT . ", `type`=" . COM_TYPE_UART . ", binded=0, md5='{$MM}', `name`='Camera Control Line'"; - $DATABASE->Query( $QS, false ); - $Data['success'] = true; - break; - case 5://3D - $QS = "INSERT INTO `lrf_sensors` SET `type_id`={$NodeType}, `site_id`={$SiteID}"; - $DATABASE->Query( $QS, false ); - $DevID = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO `nodes` SET `type`={$NodeType}, `site_id`={$SiteID}, `aux_id`={$DevID}"; - $DATABASE->Query( $QS, false ); - $NODEID = $DATABASE->getLastInsertID(); - $MM = md5(microtime()); - $QS = "INSERT INTO sockets SET node_id={$NODEID}, `aux_id`={$DevID}, `mode`=" . COM_MODE_INOUT . ", `type`=" . COM_TYPE_TCP . ", binded=0, md5='{$MM}', `name`='Network Connection'"; - $DATABASE->Query( $QS, false ); - $Data['success'] = true; - break; - case 20://IpUart - $SPD = intval( $_POST['UART_SPEED'] ); - $BITS = intval( $_POST['UART_BITS'] ); - $STOP = floatval( $_POST['UART_STOP'] ); - $PAR = strtoupper( substr($_POST['UART_PAR'],0,1) ); - $MODE = intval( $_POST['UART_MODE'] ); - $IP = $DATABASE->escape( $_POST['UART_IP'] ); - $PORT = intval( $_POST['UART_PORT'] ); - $QS = "INSERT INTO `uart_settings` SET `type`=2, `resource_id`=0, `mode`={$MODE}, `bit`={$BITS}, `parity`='{$PAR}', `stop_bit`={$STOP}, `port`={$PORT}, `path`='{$IP}'"; - $DATABASE->Query( $QS, false ); - $DevID = $DATABASE->getLastInsertID(); - $QS = "INSERT INTO nodes SET `type`={$NodeType}, `aux_id`={$DevID}, `site_id`={$SiteID}"; - $DATABASE->Query( $QS, false ); - $NODEID = $DATABASE->getLastInsertID(); - $DevICE = $IP .':'.$PORT; - $MM = md5( $DevICE ); - $QS = "INSERT INTO resources SET `type`=1, `site_id`={$SiteID}, `node_id`={$NODEID}, `aux_id`={$DevID}, `md5`='{$MM}', `device`='{$DevICE}'"; - $DATABASE->Query( $QS, false ); - $RES_UART = $DATABASE->getLastInsertID(); - $DevICE = $IP; - $MM = md5( $DevICE ); - $QS = "INSERT INTO resources SET `type`=100, `site_id`={$SiteID}, `node_id`={$NODEID}, `aux_id`={$DevID}, `md5`='{$MM}', `device`='{$DevICE}'"; - $DATABASE->Query( $QS, false ); - $RES_NET = $DATABASE->getLastInsertID(); - $QS = "UPDATE `uart_settings` SET `resource_id`={$RES_UART} WHERE `id`={$DevID}"; - $DATABASE->Query( $QS, false ); - $Server_NODE = 147; - $QS = "INSERT INTO connections SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$RES_NET}, `to`={$Server_NODE}, `to_aux`=0, `type`=".COM_TYPE_TCP; - $DATABASE->Query( $QS, false ); - - $Data['success'] = true; - break; - }; - }; - echo json_encode( $Data ); + $Data['success'] = false; + if( $CUser->Data['access'] > 5 ){ + if( isset($_POST['SITEID']) ) $SiteID = intval($_POST['SITEID']); else $SiteID = 0; + if( isset($_POST['TYPE']) ) $NodeType = intval($_POST['TYPE']); else $NodeType = 0; + if( $SiteID ){ + if( $NodeType ){ + $QS = "SELECT `id` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0"; + $SS = $DATABASE->Query( $QS, false ); + if( count( $SS ) ){ + $ServerNODE = intval($SS[0]['id']); + switch( $NodeType ){ + case ARGUS_ALS_SENSOR: + case ARGUS_LFS_SENSOR: + case ARGUS_PLS_200_SENSOR: + case ARGUS_PLS_360_SENSOR: + if(isset($_POST['SNAME'])) $CNAME = $DATABASE->escape($_POST['SNAME']); else $CNAME = ''; + if(isset($_POST['RANGE'])) $CRANGE = intval($_POST['RANGE']); else $CRANGE = 0; + if(isset($_POST['UART'])) $CUART = intval($_POST['UART']); else $CUART = 0; + if(isset($_POST['DEVID'])) $DEVID = intval($_POST['DEVID']); else $DEVID = 0; + if( $CNAME != '' && $CRANGE > 0 && $CUART > 0 ){ + $Data['success'] = addSerialSensor( $SiteID, $NodeType, $CRANGE, $CNAME, $CUART, $DEVID ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_3D_SENSOR://3D + if(isset($_POST['SNAME'])) $CNAME = $DATABASE->escape($_POST['SNAME']); else $CNAME = ''; + if(isset($_POST['PORT'])) $CPORT = validatePort($_POST['PORT']); else $CPORT = false; + if(isset($_POST['ADDR'])) $CADDR = validateIP4($_POST['ADDR']); else $CADDR = false; + if(isset($_POST['SERVER'])) $ServerNODE = intval($_POST['SERVER']); else $ServerNODE = 0; + if( $CNAME != '' && $CPORT !== false && $CADDR!==false && $ServerNODE > 0 ){ + $Data['success'] = add3DSensor( $SiteID, $ServerNODE, $CNAME, $CADDR, $CPORT ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_ANALOG_STATIC_CAMERA: + if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; + if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; + if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; + if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; + if( $CSTR && $CNAME!='' ){ + $Data['success'] = addAnalogStaticCamera( $SiteID, $ServerNODE, $CNAME, $CSTR, $IMSIZE, $FMIN ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_ANALOG_PTZ_CAMERA: + if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; + if(isset($_POST['PTZ'])) $PTZ = intval($_POST['PTZ']); else $PTZ = 0; + if(isset($_POST['UART'])) $UART = intval($_POST['UART']); else $UART = 0; + if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; + if(isset($_POST['FMAX'])) $FMAX = floatval($_POST['FMAX']); else $FMAX = 0; + if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; + if(isset($_POST['TILTMODE'])) $TILTMODE = intval($_POST['TILTMODE']); else $TILTMODE = 0; + if(isset($_POST['PANMODE'])) $PANMODE = intval($_POST['PANMODE']); else $PANMODE = 0; + if(isset($_POST['PANANG'])) $PANANG = floatval( $_POST['PANANG']); else $PANANG = 360.0; + if(isset($_POST['TILTANG'])) $TILTANG = floatval( $_POST['TILTANG']); else $TILTANG = 90.0; + if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; + if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; + if( $CSTR && $CNAME!='' ){ + $Data['success'] = addAnalogPtzCamera( $SiteID, $ServerNODE, $CNAME, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID, $UART ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_IP_STATIC_CAMERA: + if(isset($_POST['CID'])) $CamID = intval($_POST['CID']); else $CamID = 0; + if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; + if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; + if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; + if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; + if( $CSTR && $CNAME!='' ){ + $Data['success'] = addAnalogStaticCamera( $SiteID, $ServerNODE, $CNAME, $CamID, $CSTR, $IMSIZE, $FMIN ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_IP_PTZ_CAMERA: + if(isset($_POST['CID'])) $CamID = intval($_POST['CID']); else $CamID = 0; + if(isset($_POST['STREAM'])) $CSTR = intval($_POST['STREAM']); else $CSTR = 0; + if(isset($_POST['PTZ'])) $PTZ = intval($_POST['PTZ']); else $PTZ = 0; + if(isset($_POST['UART'])) $UART = intval($_POST['UART']); else $UART = 0; + if(isset($_POST['FMIN'])) $FMIN = floatval($_POST['FMIN']); else $FMIN = 0; + if(isset($_POST['FMAX'])) $FMAX = floatval($_POST['FMAX']); else $FMAX = 0; + if(isset($_POST['IMSIZE'])) $IMSIZE = intval($_POST['IMSIZE']); else $IMSIZE = 2; + if(isset($_POST['TILTMODE'])) $TILTMODE = intval($_POST['TILTMODE']); else $TILTMODE = 0; + if(isset($_POST['PANMODE'])) $PANMODE = intval($_POST['PANMODE']); else $PANMODE = 0; + if(isset($_POST['PANANG'])) $PANANG = floatval( $_POST['PANANG']); else $PANANG = 360.0; + if(isset($_POST['TILTANG'])) $TILTANG = floatval( $_POST['TILTANG']); else $TILTANG = 90.0; + if(isset($_POST['PROTOID'])) $PROTOID = intval( $_POST['PROTOID'] ); else $PROTOID = 0; + if(isset($_POST['LAB'])) $CNAME = $DATABASE->escape($_POST['LAB']); else $CNAME = ''; + if( $CSTR && $CNAME!='' ){ + $Data['success'] = addAnalogPtzCamera( $SiteID, $ServerNODE, $CNAME, $CamID, $CSTR, $IMSIZE, $FMIN, $FMAX, $PANMODE, $PANANG, $TILTMODE, $TILTANG, $PTZ, $PROTOID ); + } else { + $Data['msg'] = $Labels->GetLabel('PARAM_ERROR'); + }; + break; + case ARGUS_IP_UART_GATEWAY://IpUart + $SPD = intval( $_POST['UART_SPEED'] ); + $BITS = intval( $_POST['UART_BITS'] ); + $STOP = floatval( $_POST['UART_STOP'] ); + $PAR = strtoupper( substr($_POST['UART_PAR'],0,1) ); + $MODE = intval( $_POST['UART_MODE'] ); + $IP = $DATABASE->escape( $_POST['UART_IP'] ); + $PORT = intval( $_POST['UART_PORT'] ); + $QS = "INSERT INTO `uart_settings` SET `type`=2, `resource_id`=0, `mode`={$MODE}, `bit`={$BITS}, `parity`='{$PAR}', `stop_bit`={$STOP}, `port`={$PORT}, `path`='{$IP}'"; + $DATABASE->Query( $QS, false ); + $DevID = $DATABASE->getLastInsertID(); + $QS = "INSERT INTO nodes SET `type`={$NodeType}, `aux_id`={$DevID}, `site_id`={$SiteID}"; + $DATABASE->Query( $QS, false ); + $NODEID = $DATABASE->getLastInsertID(); + $DevICE = $IP .':'.$PORT; + $MM = md5( $DevICE ); + $QS = "INSERT INTO resources SET `type`=1, `site_id`={$SiteID}, `node_id`={$NODEID}, `aux_id`={$DevID}, `md5`='{$MM}', `device`='{$DevICE}'"; + $DATABASE->Query( $QS, false ); + $RES_UART = $DATABASE->getLastInsertID(); + $DevICE = $IP; + $MM = md5( $DevICE ); + $QS = "INSERT INTO resources SET `type`=100, `site_id`={$SiteID}, `node_id`={$NODEID}, `aux_id`={$DevID}, `md5`='{$MM}', `device`='{$DevICE}'"; + $DATABASE->Query( $QS, false ); + $RES_NET = $DATABASE->getLastInsertID(); + $QS = "UPDATE `uart_settings` SET `resource_id`={$RES_UART} WHERE `id`={$DevID}"; + $DATABASE->Query( $QS, false ); + $Server_NODE = 147; + $QS = "INSERT INTO connections SET `site_id`={$SiteID}, `from`={$NODEID}, `from_aux`={$RES_NET}, `to`={$Server_NODE}, `to_aux`=0, `type`=".COM_TYPE_TCP; + $DATABASE->Query( $QS, false ); + + $Data['success'] = true; + break; + }; + } else { + $Data['msg'] = $Labels->GetLabel('WRONG_SITE_ID'); + }; + } else { + $Data['msg'] = $Labels->GetLabel('UNKNOWN_NODE_TYPE'); + }; + } else { + $Data['msg'] = $Labels->GetLabel('NO_SITE_SELECTED'); + }; + } else { + $Data['msg'] = $Labels->GetLabel('No Access'); + }; + echo json_encode( $Data ); } else { - header('location: /'); + header('location: /'); }; ?> \ No newline at end of file diff --git a/lib/controller/dash/node_0.js b/lib/controller/dash/node_0.js index 3dbff19..3e76431 100644 --- a/lib/controller/dash/node_0.js +++ b/lib/controller/dash/node_0.js @@ -6,12 +6,12 @@ //Ext.Msg.alert('Message', 'The Settings tool was clicked.'); showServerToolBox(%%%NODEID%%%); } - },{ + }/*,{ id:'close', handler: function(e, target, panel){ panel.ownerCt.remove(panel, true); } - }], + }*/], frame: true, width: 258, height: 240, diff --git a/lib/controller/dash/node_10.js b/lib/controller/dash/node_10.js index 618ea1c..0bbb1d1 100644 --- a/lib/controller/dash/node_10.js +++ b/lib/controller/dash/node_10.js @@ -9,14 +9,14 @@ tools: [{ id:'gear', handler: function(){ - Ext.Msg.alert('Message', 'The Settings tool was clicked.'); + editAnalogStream( %%%STREAMID%%%, 1 ); } - },{ + }/*,{ id:'close', handler: function(e, target, panel){ - panel.ownerCt.remove(panel, true); + panel.ownerCt.remove(panel, true); } - }], + }*/], frame: true, bodyStyle: 'padding: 0px;', plr: null, diff --git a/lib/controller/dash/node_11.js b/lib/controller/dash/node_11.js new file mode 100644 index 0000000..3e878ae --- /dev/null +++ b/lib/controller/dash/node_11.js @@ -0,0 +1,97 @@ +{ + id: 'db_node_%%%NODEID%%%', + //xxtype: 'panel', + xtype: 'portlet', + //columnWidth:.33, + //layout: 'fit', + width: 258, + height: 268, + tools: [{ + id:'gear', + handler: function(){ + editAnalogStream( %%%STREAMID%%%, 1 ); + } + }/*,{ + id:'close', + handler: function(e, target, panel){ + panel.ownerCt.remove(panel, true); + } + }*/], + frame: true, + bodyStyle: 'padding: 0px;', + plr: null, + title: '%%%NODENAME%%%', + items:[{ + html: '', + },{ + xtype: 'spacer', + height: 5 + },{ + xtype: 'button', + id: 'ptz_btn_%%%NODEID%%%', + width: '100%', + text: 'PTZ Control', + enableToggle: true, + handler: function(){ + var t = Ext.getCmp('db_node_%%%NODEID%%%'); + if( Ext.getCmp('ptz_btn_%%%NODEID%%%').pressed ){ + t.setSize( 258, 362 ); + document.getElementById('img_btn_010_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_010_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_011_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_011_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_027_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_027_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_028_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_028_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_029_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_029_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_030_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_030_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_031_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_031_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_032_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_032_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_033_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_033_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_034_%%%NODEID%%%').addEventListener( 'mouseup', makePtzStop ); + document.getElementById('img_btn_034_%%%NODEID%%%').addEventListener( 'mousedown', makePtzMove ); + document.getElementById('img_btn_020_%%%NODEID%%%').addEventListener( 'mousedown', makePtzStop ); + } else { + t.setSize( 258, 268 ); + //Ext.Msg.alert('Message', 'The 270 tool was clicked.'); + }; + t.doLayout(); + } + },{ + xtype: 'spacer', + height: 3 + },{ + html: '
 
 
  
', + height: 90 + }], + listeners:{ + afterrender: function( t ){ + /* + t.plr = videojs.getPlayer('hls-%%%NODEID%%%'); + if( t.plr == null ){ + t.plr = videojs('hls-%%%NODEID%%%',{ + autoplay: 'muted', + controls: true, + controlBar: { + volumePanel: false, + playToggle: false, + pictureInPictureToggle: false + } + }); + }; + t.plr.src({type: 'application/x-mpegURL', src: '%%%SELURL%%%'}); + */ + return true; + }, + destroy: function( t ){ + if( t.plr != null ) t.plr.dispose(); + t.plr = null; + } + } +} \ No newline at end of file diff --git a/lib/controller/dash/node_3.js b/lib/controller/dash/node_3.js index bd323fb..cdc6872 100644 --- a/lib/controller/dash/node_3.js +++ b/lib/controller/dash/node_3.js @@ -7,7 +7,7 @@ id:'gear', handler: function(){ //Ext.Msg.alert('Message', 'The Settings tool was clicked.'); - showDetectionProfile( %%%NODEID%%% ); + showSensorToolBox( %%%NODEID%%% ); } }], listeners:{ diff --git a/lib/controller/dash/node_5.js b/lib/controller/dash/node_5.js index 6e061d7..0a8e15f 100644 --- a/lib/controller/dash/node_5.js +++ b/lib/controller/dash/node_5.js @@ -1,9 +1,164 @@ { id: 'db_node_%%%NODEID%%%', width: 258, - height: 200, - title: '3D Lidar', + height: 336, + title: '%%%NODENAME%%%', + tools: [{ + id:'gear', + handler: function(){ + //Ext.Msg.alert('Message', 'The Settings tool was clicked.'); + showSensorToolBox( %%%NODEID%%% ); + } + }], + listeners:{ + beforedestroy: function(){ + if( typeof nodeTHREEviewers[%%%NODEID%%%] !== 'undefined' ){ + //nodeTHREEviewers[%%%NODEID%%%].container + // object.geometry.dispose(); object.material.dispose(); scene.remove( object ); + stopAnimation(); + nodeTHREEviewers[%%%NODEID%%%].renderer.renderLists.dispose(); + delete nodeTHREEviewers[%%%NODEID%%%].renderer; + delete nodeTHREEviewers[%%%NODEID%%%].scene; + delete nodeTHREEviewers[%%%NODEID%%%].mesh; + delete nodeTHREEviewers[%%%NODEID%%%].geometry; + delete nodeTHREEviewers[%%%NODEID%%%].material; + delete nodeTHREEviewers[%%%NODEID%%%].texture; + delete nodeTHREEviewers[%%%NODEID%%%].camera; + delete nodeTHREEviewers[%%%NODEID%%%]; + }; + return true; + }, + afterrender: function(){ + //cleanupDraw( %%%NODEID%%% ); + //drawZoomLevels[%%%NODEID%%%]=100; + //const panorama = new PANOLENS.ImagePanorama( '/lib/controller/getDeviceDraw.php?NID=%%%NODEID%%%' ); + //const viewer = new PANOLENS.Viewer({container: 'targ_canvas_%%%NODEID%%%' }); + //viewer.add( panorama ); + nodeTHREEviewers[%%%NODEID%%%] = {}; + nodeTHREEviewers[%%%NODEID%%%].container = document.getElementById( 'container_%%%NODEID%%%' ); + + nodeTHREEviewers[%%%NODEID%%%].camera = new THREE.PerspectiveCamera( 75, 1, 1, 1100 ); + nodeTHREEviewers[%%%NODEID%%%].scene = new THREE.Scene(); + nodeTHREEviewers[%%%NODEID%%%].geometry = new THREE.SphereGeometry( 500, 60, 40 ); + // invert the geometry on the x-axis so that all of the faces point inward + nodeTHREEviewers[%%%NODEID%%%].geometry.scale( -1, 1, 1 ); + + nodeTHREEviewers[%%%NODEID%%%].texture = new THREE.TextureLoader().load( '/lib/controller/getDeviceDraw.php?NID=%%%NODEID%%%' ); + nodeTHREEviewers[%%%NODEID%%%].material = new THREE.MeshBasicMaterial( { map: nodeTHREEviewers[%%%NODEID%%%].texture } ); + nodeTHREEviewers[%%%NODEID%%%].mesh = new THREE.Mesh( nodeTHREEviewers[%%%NODEID%%%].geometry, nodeTHREEviewers[%%%NODEID%%%].material ); + nodeTHREEviewers[%%%NODEID%%%].scene.add( nodeTHREEviewers[%%%NODEID%%%].mesh ); + nodeTHREEviewers[%%%NODEID%%%].scene.add( l3dMapOverlayMesh ); + + nodeTHREEviewers[%%%NODEID%%%].renderer = new THREE.WebGLRenderer(); + nodeTHREEviewers[%%%NODEID%%%].renderer.setPixelRatio( 1 ); + nodeTHREEviewers[%%%NODEID%%%].renderer.setSize( nodeTHREEviewers[%%%NODEID%%%].container.clientWidth, 200 ); + nodeTHREEviewers[%%%NODEID%%%].container.appendChild( nodeTHREEviewers[%%%NODEID%%%].renderer.domElement ); + + nodeTHREEviewers[%%%NODEID%%%].container.style.touchAction = 'none'; + nodeTHREEviewers[%%%NODEID%%%].container.myVID = %%%NODEID%%%; + + nodeTHREEviewers[%%%NODEID%%%].container.addEventListener( 'pointerdown', onPointerDown ); + nodeTHREEviewers[%%%NODEID%%%].container.addEventListener( 'wheel', onDocumentMouseWheel ); + nodeTHREEviewers[%%%NODEID%%%].targets = new Array(); + nodeTHREEviewers[%%%NODEID%%%].targetShowCopunter = 0; + nodeTHREEviewers[%%%NODEID%%%].targetIndex = 0; + + //addl3dTarget( %%%NODEID%%%, 200, Math.PI/4, Math.PI/4 ); + //addl3dTarget( %%%NODEID%%%, 150, 0, 0 ); + //document.addEventListener( 'wheel', onDocumentMouseWheel ); + /* + container.addEventListener( 'dragover', function ( event ) { + + event.preventDefault(); + event.dataTransfer.dropEffect = 'copy'; + + } ); + container.addEventListener('dragenter', function () { + + document.body.style.opacity = 0.5; + + } ); + container.addEventListener('dragleave', function () { + + document.body.style.opacity = 1; + + } ); + container.addEventListener('drop', function ( event ) { + + event.preventDefault(); + + const reader = new FileReader(); + reader.addEventListener( 'load', function ( event ) { + + material.map.image.src = event.target.result; + material.map.needsUpdate = true; + + } ); + reader.readAsDataURL( event.dataTransfer.files[ 0 ] ); + + document.body.style.opacity = 1; + + } ); + */ + /* + document.addEventListener( 'dragover', function ( event ) { + + event.preventDefault(); + event.dataTransfer.dropEffect = 'copy'; + + } ); + + document.addEventListener( 'dragenter', function () { + + document.body.style.opacity = 0.5; + + } ); + + document.addEventListener( 'dragleave', function () { + + document.body.style.opacity = 1; + + } ); + + document.addEventListener( 'drop', function ( event ) { + + event.preventDefault(); + + const reader = new FileReader(); + reader.addEventListener( 'load', function ( event ) { + + material.map.image.src = event.target.result; + material.map.needsUpdate = true; + + } ); + reader.readAsDataURL( event.dataTransfer.files[ 0 ] ); + + document.body.style.opacity = 1; + + } ); + */ + //animateTargets(); + animate(); + + // + + //window.addEventListener( 'resize', onWindowResize ); + } + }, items:[{ - html: '3D Lidar' + html: '
', + height: 210 + },{ + id: 'status_%%%NODEID%%%', + border: true, + frame: true, + height: 36, + html: '' + },{ xtype: 'spacer', height: 3 },{ + id: 'det_status_%%%NODEID%%%', + border: true, + frame: true, + height: 46, + html: '' }] } \ No newline at end of file diff --git a/lib/controller/doDeviceOperation.php b/lib/controller/doDeviceOperation.php index caf6aef..92a9ba0 100644 --- a/lib/controller/doDeviceOperation.php +++ b/lib/controller/doDeviceOperation.php @@ -1,36 +1,31 @@ Data['id'] > 1 ){ - $NodeID = intval($_POST['NID']); - $SiteID = intval($_POST['SITE']); - $OPID = intval( $_POST['CMD'] ); - $PARAM = $_POST['PARAM']; - $QS = "SELECT * FROM nodes WHERE id={$NodeID}"; - $Data = array(); - $result = $DATABASE->Query( $QS, false ); - if( count( $result ) ){ - $T = $result[0]; - $TYP = intval( $T['type'] ); - $AID = intval( $T['aux_id'] ); - switch( $TYP ){ - case ARGUS_ALS_SENSOR: - case ARGUS_LFS_SENSOR: - case ARGUS_PLS_200_SENSOR: - case ARGUS_PLS_360_SENSOR: - case ARGUS_3D_SENSOR: - case ARGUS_NET_PLS_200:{ - //$QS = "SELECT * FROM lrf_sensors WHERE id={$AID}"; - //$result = $DATABASE->Query( $QS, false ); - //if( count($result)) { - // - //}; - $QS = "UPDATE `lrf_sensors` SET `pushed_cmd`={$OPID} WHERE id={$AID}"; - $DATABASE->Query( $QS ); + $Data = array(); + $Data['success'] = false; + if( isset( $_POST['NID'] ) ) { + $NodeID = intval($_POST['NID']); + } else $NodeID = 0; + if( isset( $_POST['CMD'] ) ){ + $CMD = intval( $_POST['CMD'] ); + } else { + $CMD = 0; + }; + if( isset( $_POST['PARAM'] ) ){ + $PARAM = $DATABASE->escape( $_POST['PARAM'] ); + } else { + $PARAM = ''; }; - }; - }; - echo json_encode( $Data ); - exit(); + if( $NodeID > 0 && $CMD > 0 ){ + $Data['success'] = true; + $QS = "INSERT INTO `nodes_qcq` SET `node_id`={$NodeID}, `cmd`={$CMD}, `status`=0, `parameter`='{$PARAM}'"; + $Data['query'] = $QS; + $DATABASE->Query( $QS, false ); + } else { + $Data['msg']='Wrong Parameters'; + }; + echo json_encode( $Data ); + exit(); }; header('location: /'); ?> \ No newline at end of file diff --git a/lib/controller/getAnalogStreamCtrl.php b/lib/controller/getAnalogStreamCtrl.php new file mode 100644 index 0000000..a075dc8 --- /dev/null +++ b/lib/controller/getAnalogStreamCtrl.php @@ -0,0 +1,212 @@ +Data['id'] > 1 ){ + $STREAM = intval( $_POST['STREAM'] ); + $QS = "SELECT * FROM `media_streams` WHERE `id` = {$STREAM}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $CS = $Result[0]; + if( $CS['source_type'] == 'A' ){ + $Sizes = array(); + $Formats = array(); + if( $CS['source_id'] == 0 ){ + $CMD="v4l2-ctl -d {$CS['mrl']} --list-formats-ext"; + $Data = `$CMD`; + $TArr = explode( "\n", $Data ); + foreach( $TArr as $R ){ + $CL = trim( $R ); + if( stripos($CL,']:')!== false ){ + $ID = intval( substr( $CL, 1 ) ); + $FCC = substr( $CL, stripos( $CL, ':' ) + 3, 4 ); + $DSC = substr( $CL, stripos( $CL, ':' ) + 9 ); + $Formats[] = array('id'=>$ID, '4cc'=>$FCC, 'desc'=>$DSC ); + }; + if( stripos($CL,'Size:')!== false ){ + $TBarr=explode( ' ', $CL ); + if( intval( $TBarr[1] ) ){ + $ZArr = explode( 'x', $TBarr[1] ); + $Sizes[$TBarr[1]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[1] ); + } else { + $ZArr = explode( 'x', $TBarr[2] ); + $Sizes[$TBarr[2]] = array( 'width'=>$ZArr[0], 'height'=>$ZArr[1], 'title'=>$TBarr[2] ); + }; + }; + }; + }; + $CMD="v4l2-ctl -d {$CS['mrl']} --list-ctrls-menu"; + $Data = `$CMD`; + $TArr = explode( "\n", $Data ); + $Controls = array(); + $MFlag = false; + $MID = 0; + $id = 0; + foreach( $TArr as $R ){ + $CL = trim( $R ); + if( stripos( $CL, ':' ) !== false ){ + $ctrl = array(); + $RR = explode( ':', $CL ); + $TArr=explode( ' ', $CL ); + if( stripos( $CL, 'int' )!== false ){ + $ctrl['type'] = 'slider'; + $ctrl['name'] = trim( $TArr[0] ); + $ctrl['name_cod'] = md5( $ctrl['name'] ); + $ctrl['id'] = hexdec( $TArr[1] ); + + $TArr=explode( ' ', $RR[1] ); + $TBrr = explode( '=', $TArr[1] ); + $ctrl['min'] = intval( $TBrr[1] ); + $TBrr = explode( '=', $TArr[2] ); + $ctrl['max'] = intval( $TBrr[1] ); + $TBrr = explode( '=', $TArr[3] ); + $ctrl['step'] = intval( $TBrr[1] ); + $TBrr = explode( '=', $TArr[5] ); + $ctrl['value'] = intval( $TBrr[1] ); + $MFlag = false; + $Controls[$id] = $ctrl; + $id++; + } else if( stripos( $CL, 'bool' )!== false ){ + $ctrl['type'] = 'checkbox'; + $ctrl['name'] = trim( $TArr[0] ); + $ctrl['name_cod'] = md5( $ctrl['name'] ); + $ctrl['id'] = hexdec( $TArr[1] ); + $TArr=explode( ' ', $RR[1] ); + $TBrr = explode( '=', $TArr[2] ); + $ctrl['value'] = intval( $TBrr[1] ); + $MFlag = false; + $Controls[$id] = $ctrl; + $id++; + } else if( stripos( $CL, 'menu' )!== false ){ + $ctrl['type'] = 'combo'; + $ctrl['name'] = trim( $TArr[0] ); + $ctrl['name_cod'] = md5( $ctrl['name'] ); + $ctrl['id'] = hexdec( $TArr[1] ); + $TArr=explode( ' ', $RR[1] ); + $TBrr = explode( '=', $TArr[4] ); + $ctrl['value'] = intval( $TBrr[1] ); + $MFlag = true; + $MID = $id; + $Controls[$id] = $ctrl; + $id++; + } else { + if( $MFlag ){ + $ZV = explode( ':', $CL ); + $cmi= array(); + $cmi['id']=intval( $ZV[0] ); + $cmi['text']=trim( $ZV[1] ); + $Controls[$MID]['data'][]=$cmi; + }; + }; + }; + }; + $CCC = 0; + $OUT = array(); + if(count( $Formats )){ + $ll = "{ + xtype: 'combo', + fieldLabel: '". $Labels->GetLabel('_FRAME_FORMAT_') ."', + lazyRender: true, + id: 'frmt_id', + name: 'frame_format', + mode: 'local', + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'frmt_id'); }}, + store: new Ext.data.ArrayStore({ + fields: ['fmt','fmt_txt'], + data: ["; + $cl = array(); + foreach( $Formats as $F ){ + $cl[]="[{$F['id']},\"{$F['desc']}\"]"; + }; + $ll .= implode( ',', $cl ); + $ll .="] + }), + valueField: 'fmt', + displayField: 'fmt_txt' + }"; + $OUT[$CCC] = $ll; + $CCC++; + }; + if( count( $Sizes ) ){ + $ll = "{ + xtype: 'combo', + fieldLabel: '". $Labels->GetLabel('_FRAME_SIZE_') ."', + lazyRender: true, + id: 'sizes_id', + name: 'frame_size', + mode: 'local', + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, 'sizes_id'); }}, + store: new Ext.data.ArrayStore({ + fields: ['size','size_txt'], + data: ["; + $cl = array(); + $id = 0; + $csid = 0; + foreach( $Sizes as $Key=>$Val ){ + if( $Val['width'] == $CS['img_width'] && $Val['height'] == $CS['img_height'] ) $csid = $Key;//$id; + //$cl[]="[{$id},\"{$Key}\"]"; + $cl[]="[\"{$Key}\",\"{$Key}\"]"; + $id++; + }; + $ll .= implode( ',', $cl ); + $ll .="] + }), + valueField: 'size', + displayField: 'size_txt', + value: '{$csid}' + + }"; + $OUT[$CCC] = $ll; + $CCC++; + }; + //print_r( $Controls ); + if( count( $Controls )){ + foreach( $Controls as $CC ){ + $ll = "{ xtype: '{$CC['type']}', id: '{$CC['id']}', name: '{$CC['name']}', fieldLabel: '".$Labels->GetLabel($CC['name_cod'])."', value: {$CC['value']}, listeners:{ change: function(t,n,o){ changeASS( {$STREAM }, '{$CC['id']}' ); } }, "; + switch( $CC['type'] ){ + case 'slider':{ + $ll .= "minValue: {$CC['min']}, maxValue: {$CC['max']}, width: 235 }"; + break; + }; + case 'checkbox':{ + if( $CC['value'] == 1 ){ + $ll .= "checked: true }"; + } else { + $ll .= "checked: false }"; + }; + break; + }; + case 'combo':{ + $ll .= "lazyRender: true, mode: 'local', forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, store: new Ext.data.ArrayStore({ + fields: ['{$CC['id']}_id','{$CC['id']}_txt'], + data: ["; + $cl = array(); + foreach( $CC['data'] as $D ) $cl[]="[{$D['id']},\"{$D['text']}\"]"; + $ll .= implode(',', $cl ); + $ll .="] + }), + valueField: '{$CC['id']}_id', + displayField: '{$CC['id']}_txt' + }"; + break; + }; + }; + $OUT[$CCC] = $ll; + $CCC++; + }; + }; //https://www.waveshare.com/wiki/SIM7600E-H_4G_HAT + $CCA = implode( ',', $OUT ); + echo "{ xtype: 'form', id:'an_str_edit', frame: false, autoScroll: true, border: false, layout: 'form', labelAlign: 'right', labelWidth: 150, items: [". $CCA ."] }"; + } else { + echo "{ xtype: 'panel', html: '
Incorrect Stream
'}"; + }; + } else { + echo "{ xtype: 'panel', html: '
Incorrect Stream
'}"; + }; + } else { + echo "{ xtype: 'panel', html: 'Access Error!'}"; + }; + + //$ v4l2-ctl --set-fmt-video=width=960,height=720 + //$ v4l2-ctl --set-ctrl=focus_auto=0,focus_absolute=0 +?> diff --git a/lib/controller/getDashBoardItems.php b/lib/controller/getDashBoardItems.php index 0af9fab..8a80114 100644 --- a/lib/controller/getDashBoardItems.php +++ b/lib/controller/getDashBoardItems.php @@ -93,6 +93,7 @@ $TPL[$index] = str_replace( '%%%URLS%%%', '[' . $CS . ']' , $TPL[$index] ); $TPL[$index] = str_replace( '%%%SELID%%%', 'value: '. $Z[0]['aux_parameter'] .',', $TPL[$index] ); $TPL[$index] = str_replace( '%%%SELURL%%%', $FU, $TPL[$index] ); + $TPL[$index] = str_replace( '%%%STREAMID%%%', $R['aux_parameter'], $TPL[$index] ); /* $QS="SELECT mss.*, ms.name, ms.img_width, ms.img_height FROM media_server_streams mss LEFT JOIN media_streams ms ON ( mss.media_stream_id = ms.id ) WHERE ms.source_id={$Z[0]['id']} AND mss.valid=1 AND mss.online=1"; $S=$DATABASE->Query( $QS ); diff --git a/lib/controller/getDetectionProfile.php b/lib/controller/getDetectionProfile.php index 5c7c57e..988636b 100644 --- a/lib/controller/getDetectionProfile.php +++ b/lib/controller/getDetectionProfile.php @@ -11,15 +11,197 @@ $AID = $T['aux_id']; $QS = "SELECT * FROM lrf_sensors WHERE id={$AID}"; $result = $DATABASE->Query( $QS, false ); - if( count($result)) { - $R = $result[0]; + if( count($result) ){ + $CS = $result[0]; $K['name'] = $T['name']; - $K['data_status'] = intval( $R['data_status'] ); - $K['online'] = intval($T['online']); - $K['profile_id'] = intval($R['detection_profile_id']); - $K['profiles'] = array(); - $QS = "SELECT DISTINCT `profile_id` as `id` FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} ORDER BY `profile_id`"; - foreach( $DATABASE->Query( $QS ) as $Z ) $K['profiles'][] = intval($Z['id']); + $K['data_status'] = intval( $CS['data_status'] ); + $K['online'] = intval( $T['online']); + switch( intval( $CS['type_id'] ) ){ + case 3:{ + $K['profile_id'] = intval( $CS['detection_profile_id'] ); + $K['profiles'] = array(); + $QS = "SELECT DISTINCT `profile_id` as `id` FROM `lrf_detection_profiles` WHERE `aux_id`={$AID} ORDER BY `profile_id`"; + foreach( $DATABASE->Query( $QS ) as $Z ) $K['profiles'][] = intval($Z['id']); + $K['additional'] = <<Data['id'] > 1 ){ header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); @@ -23,7 +23,7 @@ $Result = $DATABASE->Query( $QS, false ); if( count( $Result ) ){ if( $SAVE_AS_PICTURE ){ - if( $Result[0]['rendered'] == 'Y' ){ + if( $Result[0]['rendered'] == 'Y' ){ if( $AUX ){ $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png"; } else { @@ -35,168 +35,185 @@ if( file_exists( $FF ) ) { $FD = fopen( $FF, "rb" ); if( $FD ){ - $CL = fread( $FD, 4 ); - $size = unpack( "V", $CL ); - $pts = array(); - $as = $size[1]; - for($i=0; $i< $as; $i++ ){ + if( $Result[0]['type'] == 1 ){ + //$IM = imagecreatefrompng("../../style/assets/3d_draw_empty_100.png"); + $IM = imagecreatefromjpeg("../../style/assets/3d_draw_empty_100.jpg"); + imagesavealpha( $IM, true ); + $bg = imagecolorallocate($IM, 0, 0, 0); + $black = imagecolorallocate($IM, 255, 255, 0); + //$green = imagecolorallocate($IM, 0, 255, 0); + $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); + imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); + imagestring( $IM, 2, 6, 5, "LIBERMANDA", $black ); + imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" ); + imagedestroy( $IM ); + $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}"; + $DATABASE->Query( $QS ); + $FN = "data/device_draws/{$Result[0]['md5']}_100.png"; + } else { $CL = fread( $FD, 4 ); - $T = unpack( "V", $CL ); - //print_r( $T ); - $pts[] = $T[1] >> 16; - }; - fclose( $FD ); - $QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}"; - $PP = $DATABASE->Query( $QS ); - $stp = 2.0 * ( M_PI / $as ); - $MR = intval( $PP[0]['max_range'] ); - $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] ); + $size = unpack( "V", $CL ); + $pts = array(); + $as = $size[1]; + for($i=0; $i< $as; $i++ ){ + $CL = fread( $FD, 4 ); + $T = unpack( "V", $CL ); + //print_r( $T ); + $pts[] = $T[1] >> 16; + }; + fclose( $FD ); + $QS = "SELECT ls.base_shift, ls.max_range FROM nodes ns LEFT JOIN lrf_sensors ls ON ( ls.id=ns.aux_id ) WHERE ns.id={$NID}"; + $PP = $DATABASE->Query( $QS ); + $stp = 2.0 * ( M_PI / $as ); + $MR = intval( $PP[0]['max_range'] ); + $S = ( M_PI / 3000.0 ) * intval( $PP[0]['base_shift'] ); - $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png"); - imagesavealpha( $IM, true ); - $bg = imagecolorallocate($IM, 0, 0, 0); - $black = imagecolorallocate($IM, 255, 255, 0); - //$green = imagecolorallocate($IM, 0, 255, 0); - $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); - imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); - imagestring( $IM, 2, 6, 5, $MR . "m.", $black ); - $maxR = 98.0; - $rst = $maxR / 1025.0; - $x0 = 100; - $y0 = 100; - $ppA = array(); - $ppB = array(); - for( $i=0; $i< $as; $i++ ){ - if( $pts[$i] > 0 ){ - $cr = ($rst * $pts[$i]); - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $cr * cos( $ca ); - $ppA[] = $y0 + $cr * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); - } else { - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $maxR * cos( $ca ); - $ppA[] = $y0 + $maxR * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); + $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_100.png"); + imagesavealpha( $IM, true ); + $bg = imagecolorallocate($IM, 0, 0, 0); + $black = imagecolorallocate($IM, 255, 255, 0); + //$green = imagecolorallocate($IM, 0, 255, 0); + $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); + imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); + imagestring( $IM, 2, 6, 5, $MR . "m.", $black ); + $maxR = 98.0; + $rst = $maxR / 1025.0; + $x0 = 100; + $y0 = 100; + $ppA = array(); + $ppB = array(); + for( $i=0; $i< $as; $i++ ){ + if( $pts[$i] > 0 ){ + $cr = ($rst * $pts[$i]); + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $cr * cos( $ca ); + $ppA[] = $y0 + $cr * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + } else { + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $maxR * cos( $ca ); + $ppA[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + }; }; - }; - $ppB[] = $ppA[count($ppA)-2]; - $ppB[] = $ppA[count($ppA)-1]; - $popo = array_merge( $ppA, $ppB ); - imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); - imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" ); - imagedestroy( $IM ); - - $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png"); - imagesavealpha( $IM, true ); - $bg = imagecolorallocate($IM, 0, 0, 0); - $black = imagecolorallocate($IM, 255, 255, 0); - //$green = imagecolorallocate($IM, 0, 255, 0); - $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); - imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); - imagestring( $IM, 2, 6, 5, ( $MR / 2 ) . "m.", $black ); - $rst = $maxR / 513.0; - $ppA = array(); - $ppB = array(); - for( $i=0; $i< $as; $i++ ){ - if( $pts[$i] > 0 && $pts[$i] < 513 ){ - $cr = ($rst * $pts[$i]); - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $cr * cos( $ca ); - $ppA[] = $y0 + $cr * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); - } else { - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $maxR * cos( $ca ); - $ppA[] = $y0 + $maxR * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $ppA[count($ppA)-2]; + $ppB[] = $ppA[count($ppA)-1]; + $popo = array_merge( $ppA, $ppB ); + imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); + imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_100.png" ); + imagedestroy( $IM ); + + $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_50.png"); + imagesavealpha( $IM, true ); + $bg = imagecolorallocate($IM, 0, 0, 0); + $black = imagecolorallocate($IM, 255, 255, 0); + //$green = imagecolorallocate($IM, 0, 255, 0); + $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); + imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); + imagestring( $IM, 2, 6, 5, ( $MR / 2 ) . "m.", $black ); + $rst = $maxR / 513.0; + $ppA = array(); + $ppB = array(); + for( $i=0; $i< $as; $i++ ){ + if( $pts[$i] > 0 && $pts[$i] < 513 ){ + $cr = ($rst * $pts[$i]); + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $cr * cos( $ca ); + $ppA[] = $y0 + $cr * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + } else { + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $maxR * cos( $ca ); + $ppA[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + }; }; - }; - $ppB[] = $ppA[count($ppA)-2]; - $ppB[] = $ppA[count($ppA)-1]; - $popo = array_merge( $ppA, $ppB ); - imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); - imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" ); - imagedestroy( $IM ); - - $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png"); - imagesavealpha( $IM, true ); - $bg = imagecolorallocate($IM, 0, 0, 0); - $black = imagecolorallocate($IM, 255, 255, 0); - //$green = imagecolorallocate($IM, 0, 255, 0); - $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); - imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); - imagestring( $IM, 2, 6, 5, ( $MR / 4 ) . "m.", $black ); - $rst = $maxR / 257.0; - $ppA = array(); - $ppB = array(); - for( $i=0; $i< $as; $i++ ){ - if( $pts[$i] > 0 && $pts[$i] < 256 ){ - $cr = ($rst * $pts[$i]); - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $cr * cos( $ca ); - $ppA[] = $y0 + $cr * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); - } else { - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $maxR * cos( $ca ); - $ppA[] = $y0 + $maxR * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $ppA[count($ppA)-2]; + $ppB[] = $ppA[count($ppA)-1]; + $popo = array_merge( $ppA, $ppB ); + imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); + imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_50.png" ); + imagedestroy( $IM ); + + $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_25.png"); + imagesavealpha( $IM, true ); + $bg = imagecolorallocate($IM, 0, 0, 0); + $black = imagecolorallocate($IM, 255, 255, 0); + //$green = imagecolorallocate($IM, 0, 255, 0); + $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); + imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); + imagestring( $IM, 2, 6, 5, ( $MR / 4 ) . "m.", $black ); + $rst = $maxR / 257.0; + $ppA = array(); + $ppB = array(); + for( $i=0; $i< $as; $i++ ){ + if( $pts[$i] > 0 && $pts[$i] < 256 ){ + $cr = ($rst * $pts[$i]); + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $cr * cos( $ca ); + $ppA[] = $y0 + $cr * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + } else { + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $maxR * cos( $ca ); + $ppA[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + }; }; - }; - $ppB[] = $ppA[count($ppA)-2]; - $ppB[] = $ppA[count($ppA)-1]; - $popo = array_merge( $ppA, $ppB ); - imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); - imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" ); - imagedestroy( $IM ); - - $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png"); - imagesavealpha( $IM, true ); - $bg = imagecolorallocate($IM, 0, 0, 0); - $black = imagecolorallocate($IM, 255, 255, 0); - //$green = imagecolorallocate($IM, 0, 255, 0); - $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); - imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); - imagestring( $IM, 2, 6, 5, ( $MR / 8 ) . "m.", $black ); - $rst = $maxR / 129.0; - $ppA = array(); - $ppB = array(); - for( $i=0; $i< $as; $i++ ){ - if( $pts[$i] > 0 && $pts[$i] < 128 ){ - $cr = ($rst * $pts[$i]); - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $cr * cos( $ca ); - $ppA[] = $y0 + $cr * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $ppA[count($ppA)-2]; + $ppB[] = $ppA[count($ppA)-1]; + $popo = array_merge( $ppA, $ppB ); + imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); + imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_25.png" ); + imagedestroy( $IM ); + + $IM = imagecreatefrompng("../../style/assets/lfs_draw_empty_12.png"); + imagesavealpha( $IM, true ); + $bg = imagecolorallocate($IM, 0, 0, 0); + $black = imagecolorallocate($IM, 255, 255, 0); + //$green = imagecolorallocate($IM, 0, 255, 0); + $green = imagecolorallocatealpha( $IM, 0, 64, 0, 64 ); + imagefilledrectangle( $IM, 5, 5, 36, 18, $bg ); + imagestring( $IM, 2, 6, 5, ( $MR / 8 ) . "m.", $black ); + $rst = $maxR / 129.0; + $ppA = array(); + $ppB = array(); + for( $i=0; $i< $as; $i++ ){ + if( $pts[$i] > 0 && $pts[$i] < 128 ){ + $cr = ($rst * $pts[$i]); + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $cr * cos( $ca ); + $ppA[] = $y0 + $cr * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + } else { + $ca = 0.0 - ( $S + $i * $stp ); + $ppA[] = $x0 + $maxR * cos( $ca ); + $ppA[] = $y0 + $maxR * sin( $ca ); + $ppB[] = $x0 + $maxR * cos( $ca ); + $ppB[] = $y0 + $maxR * sin( $ca ); + }; + }; + $ppB[] = $ppA[count($ppA)-2]; + $ppB[] = $ppA[count($ppA)-1]; + $popo = array_merge( $ppA, $ppB ); + imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); + imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" ); + imagedestroy( $IM ); + $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}"; + $DATABASE->Query( $QS ); + if( $AUX ){ + $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png"; } else { - $ca = 0.0 - ( $S + $i * $stp ); - $ppA[] = $x0 + $maxR * cos( $ca ); - $ppA[] = $y0 + $maxR * sin( $ca ); - $ppB[] = $x0 + $maxR * cos( $ca ); - $ppB[] = $y0 + $maxR * sin( $ca ); + $FN = "data/device_draws/{$Result[0]['md5']}_100.png"; }; }; - $ppB[] = $ppA[count($ppA)-2]; - $ppB[] = $ppA[count($ppA)-1]; - $popo = array_merge( $ppA, $ppB ); - imagefilledpolygon( $IM, $popo, count( $popo ) / 2, $green ); - imagepng( $IM, "data/device_draws/{$Result[0]['md5']}_12.png" ); - imagedestroy( $IM ); - $QS = "UPDATE lrf_draw SET rendered='Y' WHERE id={$Result[0]['id']}"; - $DATABASE->Query( $QS ); - if( $AUX ){ - $FN = "data/device_draws/{$Result[0]['md5']}_{$AUX}.png"; - } else { - $FN = "data/device_draws/{$Result[0]['md5']}_100.png"; - }; }; } else { echo "No Res"; exit(); diff --git a/lib/controller/getDeviceMask.php b/lib/controller/getDeviceMask.php new file mode 100644 index 0000000..9e55589 --- /dev/null +++ b/lib/controller/getDeviceMask.php @@ -0,0 +1,37 @@ +Data['id'] > 1 ){ + $NodeID = intval($_POST['NID']); + $SiteID = intval($_POST['SITE']); + $LayerID = intval($_POST['MID']); + $LRFID = intval($_POST['LID']); + $QS = "SELECT * FROM nodes WHERE id={$NodeID} "; + $Data = array(); + $result = $DATABASE->Query( $QS, false ); + if( count( $result ) ){ + $T = $result[0]; + $AID = $T['aux_id']; + $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; + $result = $DATABASE->Query( $QS, false ); + if( count($result) ){ + $CM = $result[0]; + $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $ZA = $DATABASE->Query( $QS ); + $CV = array(); + if( count( $ZA ) ){ + foreach( $ZA as $VV ){ + $CV['colour']="rgba({$VV['r']},{$VV['g']},{$VV['b']})";//sprintf("#%02X%02X%02X", intval( $VV['r'] ), intval( $VV['g'] ), intval( $VV['b'] ) ); + $QS = "SELECT * FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$VV['id']}"; + $PP = $DATABASE->Query( $QS ); + $CV['points'] = array(); + foreach( $PP as $P ) $CV['points'][] = array( $P['x'], $P['y']); + $Data[] = $CV; + }; + }; + }; + }; + echo json_encode( $Data ); + exit(); + }; + header('location: /'); +?> \ No newline at end of file diff --git a/lib/controller/getNetwork.php b/lib/controller/getNetwork.php index 4b1193e..97d98f2 100644 --- a/lib/controller/getNetwork.php +++ b/lib/controller/getNetwork.php @@ -102,29 +102,29 @@ $cedge['to'] = $CD['to']; $cedge['arrows'] = 'to'; switch( $CD['type'] ){ - case COM_TYPE_UART: + case CON_TYPE_UART: $COL['color'] = '#e0e000'; $COL['opacity']= 0.9; $COL['highlight'] = '#ffff00'; break; - case COM_TYPE_TCP: + case CON_TYPE_TCP: $cedge['arrows'] = 'to, from'; $COL['color'] = '#0000e0'; $COL['opacity']= 0.9; $COL['highlight'] = '#0000ff'; break; - case COM_TYPE_DC_CTRL: + case CON_TYPE_DC_CTRL: $COL['color'] = '#00e000'; $COL['opacity']= 0.9; $COL['highlight'] = '#00ff00'; break; - case COM_TYPE_ANALOG_VIDEO: - case COM_TYPE_ANALOG_AUDIO: + case CON_TYPE_ANALOG_VIDEO: + case CON_TYPE_ANALOG_AUDIO: $COL['color'] = '#00e0e0'; $COL['opacity']= 0.9; $COL['highlight'] = '#00ffff'; break; - case COM_TYPE_DIGITAL_MEDIA: + case CON_TYPE_DIGITAL_MEDIA: $COL['color'] = '#e000e0'; $COL['opacity']= 0.9; $COL['highlight'] = '#ff00ff'; diff --git a/lib/controller/getNetworkNodeProps.php b/lib/controller/getNetworkNodeProps.php index 678391c..307c8c2 100644 --- a/lib/controller/getNetworkNodeProps.php +++ b/lib/controller/getNetworkNodeProps.php @@ -1,102 +1,220 @@ Data['id'] > 1 ){ - $Node = intval( $_POST['NODE'] ); - $QS = "SELECT * FROM nodes WHERE id = {$Node}"; - $Result = $DATABASE->Query( $QS, false ); - if( count( $Result ) ){ - $Props = $Result[0]; - $Type = intval( $Props['type'] ); - $TName = 'props/'.$Type.'_node_prop.js'; - $Data = file_get_contents( $TName ); - switch( $Type ){ - case 1: - case 2: - case 3: - case 4:{ - $QS="SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; - $RR = $DATABASE->Query( $QS ); - $CC = $RR[0]; - $Data = str_replace('%%%DEV_LABEL%%%', ''.$Props['name'], $Data ); - $Data = str_replace('%%%LRF_ID%%%', ''.$Props['aux_id'], $Data ); - $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); - $Data = str_replace('%%%DEVICE_ID%%%', $CC['device_id'] , $Data ); - $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); - $Data = str_replace('%%%MAX_RANGE%%%', $CC['max_range'] , $Data ); - $Data = str_replace('%%%M_ORDER%%%', $CC['m_order'] , $Data ); - $Data = str_replace('%%%M_OFFSET%%%', $CC['m_offset'] , $Data ); - $Data = str_replace('%%%M_WIDTH%%%', $CC['m_width'] , $Data ); - $Data = str_replace('%%%M_SST%%%', $CC['m_sst'] , $Data ); - $Data = str_replace('%%%S_ORDER%%%', $CC['s_order'] , $Data ); - $Data = str_replace('%%%S_OFFSET%%%', $CC['s_offset'] , $Data ); - $Data = str_replace('%%%S_WIDTH%%%', $CC['s_width'] , $Data ); - $Data = str_replace('%%%S_SST%%%', $CC['s_sst'] , $Data ); - break; - }; - case ARGUS_3D_SENSOR:{ - $QS="SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; - $RR = $DATABASE->Query( $QS ); - $CC = $RR[0]; - $Data = str_replace('%%%DEV_LABEL%%%', ''.$Props['name'], $Data ); - $Data = str_replace('%%%LRF_ID%%%', ''.$Props['aux_id'], $Data ); - $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); - $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); - $Data = str_replace('%%%IP_ADDRESS%%%', $CC['ip_address'] , $Data ); - $Data = str_replace('%%%IP_PORT%%%', $CC['port'] , $Data ); - $Data = str_replace('%%%M_ORDER%%%', $CC['m_order'] , $Data ); - $Data = str_replace('%%%M_OFFSET%%%', $CC['m_offset'] , $Data ); - $Data = str_replace('%%%M_WIDTH%%%', $CC['m_width'] , $Data ); - $Data = str_replace('%%%M_SST%%%', $CC['m_sst'] , $Data ); - $Data = str_replace('%%%S_ORDER%%%', $CC['s_order'] , $Data ); - $Data = str_replace('%%%S_OFFSET%%%', $CC['s_offset'] , $Data ); - $Data = str_replace('%%%S_WIDTH%%%', $CC['s_width'] , $Data ); - $Data = str_replace('%%%S_SST%%%', $CC['s_sst'] , $Data ); - break; - }; - case 13:{ - $QS="SELECT * FROM cameras WHERE id={$Props['aux_id']}"; - $RR = $DATABASE->Query( $QS ); - $C = $RR[0]; - if( $C['online'] == 1 ){ - $QS = "SELECT picture_proto, picture_port, picture, img_width FROM media_streams WHERE source_id={$Props['aux_id']} ORDER BY img_width ASC LIMIT 1"; - $RR = $DATABASE->Query( $QS ); - $MS = $RR[0]; - $PURL = $MS['picture_proto'] . '://' . $C['access_login']. ':' . $C['access_pass']. '@'. $C['ip'] . ':' . $MS['picture_port'] . $MS['picture']; - $Data = str_replace( '%%%PREVIMG%%%', $PURL, $Data ); - } else { - $Data = str_replace( '%%%PREVIMG%%%', '/style/assets/no_picture.jpg', $Data ); + $Node = intval( $_POST['NODE'] ); + $QS = "SELECT * FROM nodes WHERE id = {$Node}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $Props = $Result[0]; + $Type = intval( $Props['type'] ); + $TName = 'props/'.$Type.'_node_prop.js'; + $Data = file_get_contents( $TName ); + $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); + $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); + switch( $Type ){ + case ARGUS_SERVER: + //Info + $InfoData = ''; + $InfoParts = array(); + $InfoParts[] = '{ xtype: \'panel\', html: \'
'.$Server['identity'].'
\'}'; + if($Props['online']){ + $InfoParts[] = '{ xtype: \'panel\', html: \'
Online
\'}'; + }else{ + $InfoParts[] = '{ xtype: \'panel\', html: \'
Offline
\'}'; + }; + $InfoData = implode( ',', $InfoParts ); + $Data = str_replace('%%%INFO%%%', $InfoData, $Data ); + // Get Sockets + $SocketsData = ''; + $SockDataParts = array(); + $QS = "SELECT * FROM resources WHERE `node_id`={$Node}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + foreach( $Result as $R ){ + switch( $R['type'] ){ + case 1: + //Uart + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').'\'}'; + break; + case 6: + //USB DC + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').'\'}'; + break; + case 31: + //Video Grabber + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('FRAMEGRAB_PROP').'\'}'; + break; + case 100: + //Loopback + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('LOOPBACK_PROP').'\'}'; + break; + case 101: + //Ethernet Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('ETHERNET_PROP').'\'}'; + break; + case 102: + //WiFi Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WIFI_PROP').'\'}'; + break; + case 103: + //Virtual IP Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VIRTUALIP_PROP').'\'}'; + break; + case 104: + //VPN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VPN_TUN_PROP').'\'}'; + break; + case 105: + //WAN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WAN_LINE_PROP').'\'}'; + break; + //Media Encoder Sink + case 131: // Video Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Video Sink'.'\'}'; + break; + case 132: // Audio Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Audio Sink'.'\'}'; + break; + default: + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$R['device'].'\'}'; + }; + }; + $SocketsData = implode( ',', $SockDataParts ); + }; + $Data = str_replace('%%%SOCKETS%%%', $SocketsData, $Data ); + //Get Modules + $QS = "SELECT * FROM `server_modules` WHERE `server_id`={$Props['aux_id']}"; + $MDAT = $DATABASE->Query( $QS ); + if(count($MDAT)){ + $MODITEMS = array(); + foreach( $MDAT as $M ){ + switch( $M['type'] ){ + case 1:{ + //ZLMedia + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'Media Server\'}'; + break; + }; + case 2:{ + //DCB_USB + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'Dry Contacts\'}'; + break; + }; + case 3:{ + //Kafka + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'Kafka Proxy\'}'; + break; + }; + case 4:{ + //GPS + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'GPS Anchor\'}'; + break; + }; + case 5:{ + //Netvork + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'Network Proxy\'}'; + break; + }; + case 6:{ + //FlyHunter + $MODITEMS[] = '{ xtype:\'button\', width: \'100%\', text:\'Fly Hunter\', handler: function(){ module_prop_FlyHunter('.$M['id'].'); } }'; + break; + }; + }; + }; + $IMPL = implode( ',', $MODITEMS ); + $ModulesData = "{ items: [{$IMPL}]}"; + $Data = str_replace('%%%MODULES%%%', $ModulesData, $Data ); + } else { + $Data = str_replace('%%%MODULES%%%', '', $Data ); + }; + break; + case ARGUS_ALS_SENSOR: + case ARGUS_LFS_SENSOR: + case ARGUS_PLS_200_SENSOR: + case ARGUS_PLS_360_SENSOR:{ + $QS="SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; + $RR = $DATABASE->Query( $QS ); + $CC = $RR[0]; + $Data = str_replace('%%%DEV_LABEL%%%', ''.$Props['name'], $Data ); + $Data = str_replace('%%%LRF_ID%%%', ''.$Props['aux_id'], $Data ); + $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); + $Data = str_replace('%%%DEVICE_ID%%%', $CC['device_id'] , $Data ); + $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); + $Data = str_replace('%%%MAX_RANGE%%%', $CC['max_range'] , $Data ); + $Data = str_replace('%%%M_ORDER%%%', $CC['m_order'] , $Data ); + $Data = str_replace('%%%M_OFFSET%%%', $CC['m_offset'] , $Data ); + $Data = str_replace('%%%M_WIDTH%%%', $CC['m_width'] , $Data ); + $Data = str_replace('%%%M_SST%%%', $CC['m_sst'] , $Data ); + $Data = str_replace('%%%S_ORDER%%%', $CC['s_order'] , $Data ); + $Data = str_replace('%%%S_OFFSET%%%', $CC['s_offset'] , $Data ); + $Data = str_replace('%%%S_WIDTH%%%', $CC['s_width'] , $Data ); + $Data = str_replace('%%%S_SST%%%', $CC['s_sst'] , $Data ); + break; }; - break; - }; - case 20:{ - // Net UART - $QS="SELECT * FROM uart_settings WHERE id={$Props['aux_id']}"; - $RR=$DATABASE->Query( $QS ); - $C=$RR[0]; - $Data = str_replace( '%%%NODE_ID%%%',$Props['id'], $Data ); - $Data = str_replace( '%%%UART_ID%%%',$C['id'], $Data ); - $Data = str_replace( '%%%CONTYPE%%%',$C['mode'], $Data ); - switch( $C['mode'] ){ - case 0: $Data = str_replace( '%%%CON_TYPE%%%','UDP Client', $Data ); break; - case 1: $Data = str_replace( '%%%CON_TYPE%%%','TCP Client', $Data ); break; - case 2: $Data = str_replace( '%%%CON_TYPE%%%','UDP Server', $Data ); break; - case 3: $Data = str_replace( '%%%CON_TYPE%%%','TCP Server', $Data ); break; + case ARGUS_3D_SENSOR:{ + $QS="SELECT * FROM lrf_sensors WHERE id={$Props['aux_id']}"; + $RR = $DATABASE->Query( $QS ); + $CC = $RR[0]; + $Data = str_replace('%%%DEV_LABEL%%%', ''.$Props['name'], $Data ); + $Data = str_replace('%%%LRF_ID%%%', ''.$Props['aux_id'], $Data ); + $Data = str_replace('%%%NODEID%%%', ''.$Node, $Data ); + $Data = str_replace('%%%NODENAME%%%', $Props['name'] , $Data ); + $Data = str_replace('%%%IP_ADDRESS%%%', $CC['ip_address'] , $Data ); + $Data = str_replace('%%%IP_PORT%%%', $CC['port'] , $Data ); + $Data = str_replace('%%%M_ORDER%%%', $CC['m_order'] , $Data ); + $Data = str_replace('%%%M_OFFSET%%%', $CC['m_offset'] , $Data ); + $Data = str_replace('%%%M_WIDTH%%%', $CC['m_width'] , $Data ); + $Data = str_replace('%%%M_SST%%%', $CC['m_sst'] , $Data ); + $Data = str_replace('%%%S_ORDER%%%', $CC['s_order'] , $Data ); + $Data = str_replace('%%%S_OFFSET%%%', $CC['s_offset'] , $Data ); + $Data = str_replace('%%%S_WIDTH%%%', $CC['s_width'] , $Data ); + $Data = str_replace('%%%S_SST%%%', $CC['s_sst'] , $Data ); + break; + }; + case ARGUS_IP_PTZ_CAMERA:{ + $QS="SELECT * FROM cameras WHERE id={$Props['aux_id']}"; + $RR = $DATABASE->Query( $QS ); + $C = $RR[0]; + if( $C['online'] == 1 ){ + $QS = "SELECT picture_proto, picture_port, picture, img_width FROM media_streams WHERE source_id={$Props['aux_id']} ORDER BY img_width ASC LIMIT 1"; + $RR = $DATABASE->Query( $QS ); + $MS = $RR[0]; + $PURL = $MS['picture_proto'] . '://' . $C['access_login']. ':' . $C['access_pass']. '@'. $C['ip'] . ':' . $MS['picture_port'] . $MS['picture']; + $Data = str_replace( '%%%PREVIMG%%%', $PURL, $Data ); + } else { + $Data = str_replace( '%%%PREVIMG%%%', '/style/assets/no_picture.jpg', $Data ); + }; + break; + }; + case ARGUS_IP_UART_GATEWAY:{ + // Net UART + $QS="SELECT * FROM uart_settings WHERE id={$Props['aux_id']}"; + $RR=$DATABASE->Query( $QS ); + $C=$RR[0]; + $Data = str_replace( '%%%NODE_ID%%%',$Props['id'], $Data ); + $Data = str_replace( '%%%UART_ID%%%',$C['id'], $Data ); + $Data = str_replace( '%%%CONTYPE%%%',$C['mode'], $Data ); + switch( $C['mode'] ){ + case 0: $Data = str_replace( '%%%CON_TYPE%%%','UDP Client', $Data ); break; + case 1: $Data = str_replace( '%%%CON_TYPE%%%','TCP Client', $Data ); break; + case 2: $Data = str_replace( '%%%CON_TYPE%%%','UDP Server', $Data ); break; + case 3: $Data = str_replace( '%%%CON_TYPE%%%','TCP Server', $Data ); break; + }; + $Data = str_replace( '%%%ADR_IP%%%',$C['path'], $Data ); + $Data = str_replace( '%%%ADDR_PORT%%%',$C['port'], $Data ); + $Data = str_replace( '%%%UART_SPEED%%%',$C['speed'], $Data ); + $Data = str_replace( '%%%UART_BIT%%%',$C['bit'], $Data ); + $Data = str_replace( '%%%UART_PARITY%%%',$C['parity'], $Data ); + $Data = str_replace( '%%%UART_STOP%%%',$C['stop_bit'], $Data ); + break; }; - $Data = str_replace( '%%%ADR_IP%%%',$C['path'], $Data ); - $Data = str_replace( '%%%ADDR_PORT%%%',$C['port'], $Data ); - $Data = str_replace( '%%%UART_SPEED%%%',$C['speed'], $Data ); - $Data = str_replace( '%%%UART_BIT%%%',$C['bit'], $Data ); - $Data = str_replace( '%%%UART_PARITY%%%',$C['parity'], $Data ); - $Data = str_replace( '%%%UART_STOP%%%',$C['stop_bit'], $Data ); - break; + default: $Data = '{}'; }; - default: $Data = '{}'; + echo $Data; + } else { + echo '{ html: \'Node '.$_POST['NODE'].' Loadded\'}'; }; - echo $Data; - } else { - echo '{ html: \'Node '.$_POST['NODE'].' Loadded\'}'; - }; } else { - header('location: /'); + header('location: /'); }; ?> \ No newline at end of file diff --git a/lib/controller/getNetworkServerProps.php b/lib/controller/getNetworkServerProps.php index 531a20a..4a52185 100644 --- a/lib/controller/getNetworkServerProps.php +++ b/lib/controller/getNetworkServerProps.php @@ -31,36 +31,56 @@ $QS = "SELECT * FROM resources WHERE `node_id`={$Node}"; $Result = $DATABASE->Query( $QS, false ); if( count( $Result ) ){ - foreach( $Result as $R ){ - switch( $R['type'] ){ - case 1: - //Uart - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'UART Line'.'
\'}'; - break; - case 31: - //Video Grabber - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'Analog Video'.'
\'}'; - break; - case 100: - //Network Interface IPV4 - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'Network IPV4'.'
\'}'; - break; - case 101: - //Network Interface IPV6 - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'Network IPV6'.'
\'}'; - break; - //Media Encoder Sink - case 132: // Audio - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'Audio Sink'.'
\'}'; - break; - case 131: // Vide - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.'Video Sink'.'
\'}'; - break; - default: - $SockDataParts[] = '{ xtype: \'panel\', html: \'
'.$R['device'].'
\'}'; + foreach( $Result as $R ){ + switch( $R['type'] ){ + case 1: + //Uart + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').'\'}'; + break; + case 6: + //USB DC + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('UART_LINE_PROP').'\'}'; + break; + case 31: + //Video Grabber + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('FRAMEGRAB_PROP').'\'}'; + break; + case 100: + //Loopback + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('LOOPBACK_PROP').'\'}'; + break; + case 101: + //Ethernet Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('ETHERNET_PROP').'\'}'; + break; + case 102: + //WiFi Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WIFI_PROP').'\'}'; + break; + case 103: + //Virtual IP Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VIRTUALIP_PROP').'\'}'; + break; + case 104: + //VPN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('VPN_TUN_PROP').'\'}'; + break; + case 105: + //WAN Interface + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$Labels->GetLabel('WAN_LINE_PROP').'\'}'; + break; + //Media Encoder Sink + case 131: // Video Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Video Sink'.'\'}'; + break; + case 132: // Audio Encoder Sink + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.'Audio Sink'.'\'}'; + break; + default: + $SockDataParts[] = '{ xtype: \'panel\', boder: false, frame: false, html: \''.$R['device'].'\'}'; + }; }; - }; - $SocketsData = implode( ',', $SockDataParts ); + $SocketsData = implode( ',', $SockDataParts ); }; $Data = str_replace('%%%SOCKETS%%%', $SocketsData, $Data ); //Get Modules diff --git a/lib/controller/getNodeSettings.php b/lib/controller/getNodeSettings.php new file mode 100644 index 0000000..d44eb2d --- /dev/null +++ b/lib/controller/getNodeSettings.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/lib/controller/getResourceInfo.php b/lib/controller/getResourceInfo.php index 8d449a5..30263d9 100644 --- a/lib/controller/getResourceInfo.php +++ b/lib/controller/getResourceInfo.php @@ -1,5 +1,178 @@ GetLabel('_RES_ETHERNET_DESC_'); + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$RessourceID}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$RessourceID}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + $IP = array(); + foreach($II as $I){ + if( $I['type'] == 0 ){ + $IP = $I; + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + if( count( $IP ) ){ + $TArr = explode( '.', $IP['address'] ); + $Base = ''; + } else { + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'Ethernet-Cable-icon.png'; + $POPUS = 123; + $A_EDIT = ( $CI['mode'] < 2 )?'true':'false'; + $TPL = <<', + },{ + xtype: 'panel', + border: false, + frame: false, + width: 420, + height: 320, + items:[{ + frame: false, + border: false, + html: '

{$TTL}

' + },{ + xtype: 'tabpanel', + id: 'ifo_tab', + activeTab: 0, + items:[{ + title: 'Info', + html: '{$R_nfo}' + },{ + title: 'Settings', + layout: 'form', + labelAlign: 'right', + labelWidth: 150, + items:[{ + xtype: 'combo', + fieldLabel: 'Address Allocation', + lazyRender: true, + id: 'aa_type', + mode: 'local', + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + listeners:{ + change: function(t,n,o){ + if( n < 2 ){ + Ext.getCmp('aa_adr').disable(); + } else { + Ext.getCmp('aa_adr').enable(); + }; + } + }, + store: new Ext.data.ArrayStore({ + fields: ['aa_t','aa_txt'], + data: [ + [0,'Disabled'], + [1,'Dynamic (DHCP)'], + [2,'Static'], + [3,'Router'], + ] + }), + value: {$CI['mode']}, + valueField: 'aa_t', + displayField: 'aa_txt' + },{ + xtype: 'textfield', + id: 'aa_adr', + fieldLabel: 'Address', + value: '{$IP['address']}', + disabled: {$A_EDIT} + },{ + xtype: 'textfield', + id: 'aa_mask', + fieldLabel: 'Net Mask', + value: '{$IP['mask']}', + disabled: {$A_EDIT} + },{ + xtype: 'textfield', + id: 'aa_gtw', + fieldLabel: 'Gateway', + value: '{$IP['gateway']}', + disabled: true + },{ + xtype: 'textfield', + id: 'aa_bcast', + fieldLabel: 'Broadcast', + value: '{$IP['broadcast']}', + disabled: true + },{ + xtype: 'spacer', + height: 100 + },{ + xtype: 'button', + width: '100%', + text: 'Apply Changes' + },{ + xtype: 'spacer', + height: 20 + }] + },{ + title: 'Router', + layout: 'form', + labelAlign: 'right', + labelWidth: 150, + items:[{ + xtype: 'checkbox', + fieldLabel: 'Act as DHCP Server', + },{ + xtype: 'textfield', + fieldLabel: 'Start IP Range' + },{ + xtype: 'textfield', + fieldLabel: 'End IP Range' + }] + }] + }] + },{ + border: false, + width: 10 + }], + koko: {$POPUS} + } +END_TEMPLATE; + return $TPL; + }; if( $CUser->Data['id'] > 1 ){ $EID = intval( $_POST['RID'] ); $QS = "SELECT * FROM resources WHERE id = {$EID}"; @@ -11,13 +184,100 @@ $QS = "SELECT * FROM uart_settings WHERE id={$CR['aux_id']}"; $Result = $DATABASE->Query( $QS ); $Z = $Result[0]; - $R_name = 'UART connected to a Server Appliance'; + $R_name = $Labels->GetLabel('_RES_HW_UART_DESC_'); $R_dev = $CR['device']; $R_nfo = 'Speed: ' . $Z['speed'] . ', Bits: ' . $Z['bit'] . ', Parity: ' . $Z['parity'] . ', Stop Bit: '. $Z['stop_bit']; + $R_image = 'unnamed.png'; + break; + case 31: //Video In + $R_name = 'Video Frame Grabber'; + $R_dev = $CR['device']; + $QS="SELECT * FROM `media_streams` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + $R_nfo = 'Frame Size: '.$CI['img_width'].'x'.$CI['img_height'].'
Driver: '.$CI['mrl_proto']; + $R_image = 'RCA-Connector-Plug-icon.png'; + break; + case 101: // Ethernet + $R_name = $Labels->GetLabel('_RES_ETHERNET_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + echo makeEthernetInfo( $CR['aux_id'] ); + exit; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHROUTER' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'Ethernet-Cable-icon.png'; + break; + case 102: // WiFi + $R_name = $Labels->GetLabel('_RES_WIFI_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'wifi-modem-Vista-icon.png'; + break; + case 105: + $R_name = $Labels->GetLabel('_RES_WAN_DESC_'); + $R_dev = $CR['device']; + $QS="SELECT * FROM `network_interfaces` WHERE `id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $CI = $II[0]; + switch( $CI['mode'] ){ + case 0: $MS = $Labels->GetLabel( 'MODE_DISABLED' ); break; + case 1: $MS = $Labels->GetLabel( 'MODE_ETHDYNAMIC' ); break; + case 2: $MS = $Labels->GetLabel( 'MODE_ETHSTATIC' ); break; + case 3: $MS = $Labels->GetLabel( 'MODE_ACCESS_POINT' ); break; + }; + $QS="SELECT * FROM `networks` WHERE `nif_id`={$CR['aux_id']}"; + $II = $DATABASE->Query( $QS ); + $NetInfo =''; + foreach($II as $I){ + if( $I['type'] == 0 ){ + $NetInfo .= '
Address IPv4: '.$I['address'].'
Net Mask: '.$I['mask']; + } else { + $NetInfo .= '
Address IPv6: '.$I['address'].'
Net Mask: '.$I['mask']; + }; + }; + $R_nfo = 'Mode: '.$MS.'
MAC: '.$CI['mac'] . $NetInfo; + $R_image = 'wifi-modem-Vista-icon.png'; break; }; - echo "{ xtype: 'panel', html: '"; + echo "{ xtype: 'panel', border: false, frame: false, html: '
"; - echo "
"; echo ""; echo ""; echo ""; diff --git a/lib/controller/getStatus.php b/lib/controller/getStatus.php index bb41df1..f3f780a 100644 --- a/lib/controller/getStatus.php +++ b/lib/controller/getStatus.php @@ -5,12 +5,13 @@ if( $UID > 1 ){ $SiteID = intval( $_POST['SITE'] ); $LastNID = intval( $_POST['LNID'] ); - $LastServerPID = intval( $_POST['SPID'] ); + $LastTS = intval( $_POST['SPID'] ); + $FirstTS = intval( $_POST['LOAT'] ); $Data = array(); $ServerWasHuped = false; $ServerIsOnLine = true; $Data['status'] = 'OK'; - $CTS = time(); + $Data['CTS'] = time(); $Data['nodes'] = array(); $QS = "SELECT * FROM nodes WHERE site_id = {$SiteID} ORDER BY `type`"; $result = $DATABASE->Query( $QS, false ); @@ -31,13 +32,13 @@ $zult = $DATABASE->Query( $QS ); if( $zult[0]['online'] == 1 ){ $STS = intval( $zult[0]['ts'] ); - $CN['CTS'] = $CTS; + $CN['CTS'] = $Data['CTS']; $CN['STS'] = $STS; - if( ( $CTS - $STS ) > 1 ){ //3 seconds offline - $ServerIsOnLine = false; - $CN['status'] = 0; + if( ( $CN['CTS'] - $STS ) > 1 ){ //3 seconds offline + $ServerIsOnLine = false; + $CN['status'] = 0; } else { - $CN['status'] = 1; + $CN['status'] = 1; }; } else { $ServerIsOnLine = false; @@ -55,25 +56,99 @@ case ARGUS_PLS_200_SENSOR: case ARGUS_PLS_360_SENSOR: case ARGUS_NET_PLS_200:{ - // check Targets - $CN['targets'] = array(); - $QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY id DESC LIMIT 32"; - //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) AND (UNIX_TIMESTAMP(NOW())-ts)<60 ORDER BY id DESC LIMIT 32"; - //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY ts, ts_ms DESC LIMIT 32"; - //echo $QS . "\n\n"; - $zult = $DATABASE->Query( $QS ); - if( count( $zult ) ){ - $CN['status'] = 4; // Alarmed - $CT = array(); - foreach( $zult as $Z ){ - $CT['digital'] = $Z['range_digital']; - $CT['az'] = $Z['azimuth']; - $CN['targets'][] = $CT; + // check draw + if( $LastTS > 0 ){ + $QS = "SELECT `id` FROM `lrf_draw` WHERE `node_id`={$R['id']} AND UNIX_TIMESTAMP(`ts`) > {$FirstTS}"; + $R = $DATABASE->Query( $QS ); + if( count( $R ) ){ + $CN['reload_draw'] = true; + } else { + $CN['reload_draw'] = false; + }; + } else { + $CN['reload_draw'] = false; }; + if( $CN['status'] == 1 ){ + // check Targets + $CN['targets'] = array(); + $QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY id DESC LIMIT 32"; + //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) AND (UNIX_TIMESTAMP(NOW())-ts)<60 ORDER BY id DESC LIMIT 32"; + //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY ts, ts_ms DESC LIMIT 32"; + //echo $QS . "\n\n"; + $zult = $DATABASE->Query( $QS ); + if( count( $zult ) ){ + $CN['status'] = 4; // Alarmed + $CT = array(); + foreach( $zult as $Z ){ + $CT['digital'] = $Z['range_digital']; + $CT['az'] = $Z['azimuth']; + $CN['targets'][] = $CT; + }; + }; }; break; }; case ARGUS_3D_SENSOR:{ + // check draw + if( $LastTS > 0 ){ + $QS = "SELECT `id` FROM `lrf_draw` WHERE `node_id`={$R['id']} AND UNIX_TIMESTAMP(`ts`) > {$FirstTS}"; + $BB = $DATABASE->Query( $QS ); + if( count( $BB ) ){ + $CN['reload_draw'] = true; + } else { + $CN['reload_draw'] = false; + }; + } else { + $CN['reload_draw'] = false; + }; //663552 + $CN['master_present'] = false; + $CN['slave_present'] = false; + $CN['stat_present'] = false; + if( $CN['status'] == 1 ){ + $CN['master_present'] = true; + $QS = "SELECT * FROM `lrf_runtime_status` WHERE `lrf_id`={$R['aux_id']}"; + $Stat = $DATABASE->Query( $QS ); + if( count( $Stat ) ){ + $CS = $Stat[0]; + $MP = array(); + $GP = array(); + $WP = array(); + for( $idx = 0; $idx < 8; $idx++ ){ + $MP[] = round( floatval( $CS['master_mp_' . $idx ] ) / 663552.0, 2 ); + $GP[] = round( floatval( $CS['master_gp_' . $idx ] ) / 663552.0, 2 ); + $WP[] = round( floatval( $CS['master_wp_' . $idx ] ) / 663552.0, 2 ); + }; + for( $idx = 0; $idx < 8; $idx++ ){ + $MP[] = round( floatval( $CS['slave_mp_' . $idx ] ) / 663552.0, 2 ); + $GP[] = round( floatval( $CS['slave_gp_' . $idx ] ) / 663552.0, 2 ); + $WP[] = round( floatval( $CS['slave_wp_' . $idx ] ) / 663552.0, 2 ); + }; + $CN['runtime']['gp'] = $GP; + $CN['runtime']['mp'] = $MP; + $CN['runtime']['wp'] = $WP; + $CN['stat_present'] = true; + if( $CS['twinc']!= 0 ) $CN['slave_present'] = true; + }; + // check Targets + $CN['targets'] = array(); + $QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=11 OR evt_type=14) ORDER BY id DESC LIMIT 32"; + //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) AND (UNIX_TIMESTAMP(NOW())-ts)<60 ORDER BY id DESC LIMIT 32"; + //$QS="SELECT * FROM events_cloud WHERE node_id={$CN['id']} AND ( evt_type=13 OR evt_type=14) ORDER BY ts, ts_ms DESC LIMIT 32"; + //echo $QS . "\n\n"; + $zult = $DATABASE->Query( $QS ); + $colors = array( 0x00f6ff, 0x6c00ff, 0xff5400, 0x00ff24, 0x00aeff, 0xbaff00, 0xff0000, 0x0024ff ); + if( count( $zult ) ){ + $CN['status'] = 4; // Alarmed + $CT = array(); + foreach( $zult as $Z ){ + $CT['range'] = floatval($Z['range']); + $CT['az'] = floatval($Z['azimuth']); + $CT['el'] = floatval($Z['elevation']); + $CT['color'] = $colors[intval($Z['lrf_id'])]; + $CN['targets'][] = $CT; + }; + }; + }; break; }; case ARGUS_ANALOG_STATIC_CAMERA: @@ -86,11 +161,11 @@ if( count( $SR ) ) { $ST = $SR[0]; if( $ST['valid'] == 1 ){ - $CN['valid'] = true; - $QS="SELECT * FROM `module_embed_video_settings` WHERE `id`=1"; - $S=$DATABASE->Query( $QS ); - $CN['src'] = 'http://' . $_SERVER['SERVER_ADDR'].':' . $S[0]['web_port'] .'/stream?id='. $R['aux_parameter']; - break; + $CN['valid'] = true; + $QS="SELECT * FROM `module_embed_video_settings` WHERE `id`=1"; + $S=$DATABASE->Query( $QS ); + $CN['src'] = 'http://' . $_SERVER['SERVER_ADDR'].':' . $S[0]['web_port'] .'/stream?id='. $R['aux_parameter']; + break; }; }; }; @@ -109,27 +184,27 @@ $result = $DATABASE->Query( $QS ); if( count( $result ) ){ foreach( $result as $R ){ - $cn['id'] = intval( $R['id'] ); - $cn['react'] = false; - $cn['hide'] = true; - $cn['action']= ''; - switch( intval( $R['type'] ) ){ - case 0:{ - $cn['type']= 'info'; - $cn['msg'] = $Labels->GetLabel('SYS_WELCOME_MSG'); - break; - }; - case 1:{ - $cn['type']= 'error'; - $QS="SELECT `name` FROM `nodes` WHERE `id`={$R['obj_id']}"; - $RR = $DATABASE->Query( $QS ); - $cn['msg'] = $Labels->GetLabel('SYS_MSG_DEVINV') . ' ' . $RR[0]['name'] .''; - $cn['hide'] = false; - $cn['react'] = true; - $cn['action'] = $R['obj_id'].':'.$cn['id']; + $cn['id'] = intval( $R['id'] ); + $cn['react'] = false; + $cn['hide'] = true; + $cn['action']= ''; + switch( intval( $R['type'] ) ){ + case 0:{ + $cn['type']= 'info'; + $cn['msg'] = $Labels->GetLabel('SYS_WELCOME_MSG'); + break; + }; + case 1:{ + $cn['type']= 'error'; + $QS="SELECT `name` FROM `nodes` WHERE `id`={$R['obj_id']}"; + $RR = $DATABASE->Query( $QS ); + $cn['msg'] = $Labels->GetLabel('SYS_MSG_DEVINV') . ' ' . $RR[0]['name'] .''; + $cn['hide'] = false; + $cn['react'] = true; + $cn['action'] = $R['obj_id'].':'.$cn['id']; + }; }; - }; - $Data['notifications'][] = $cn; + $Data['notifications'][] = $cn; }; }; } else { diff --git a/lib/controller/listDiscoveredCameraSources.php b/lib/controller/listDiscoveredCameraSources.php index c8e0b64..c7f6acd 100644 --- a/lib/controller/listDiscoveredCameraSources.php +++ b/lib/controller/listDiscoveredCameraSources.php @@ -1,23 +1,59 @@ Data['id'] > 1 ){ - $QS = "SELECT * FROM cameras WHERE node_id=0"; - $Result = $DATABASE->Query($QS,false); - foreach( $Result as $CD ){ - $cnode['id'] = $CD['id']; - $cnode['status'] = $CD['status']; - $cnode['login'] = $CD['access_login']; - $cnode['password']= $CD['access_pass']; - $cnode['name'] = urldecode($CD['name']); - $cnode['hardware']= urldecode($CD['hardware']); - $cnode['caps'] = $CD['caps']; - $cnode['ip'] = $CD['ip']; - $cnode['mac'] = $CD['mac']; - $Data['nodes'][] = $cnode; + function getDeviceName( $Dev ){ + $CMD = 'v4l2-ctl -D -d ' . $Dev; + $Data = `$CMD`; + $TArr = explode( "\n", $Data ); + $RD = array(); + foreach( $TArr as $R ){ + $CL = trim( $R ); + $TB = explode(':', $CL ); + if( stripos( $R, 'Model' )!== false ) $RD['name'] = trim( $TB[1] ); + if( stripos( $R, 'Driver name' )!== false ) $RD['dev'] = trim( $TB[1] ); + }; + if( count( $RD ) ) return $RD; + return array('name'=>'-noname-','dev'=>'unknown'); }; - echo json_encode( $Data ); + if( $CUser->Data['id'] > 1 ){ + if( isset( $_POST['cam_sources'] ) ){ + if( $_POST['cam_sources'] == 'ipv' ){ + $QS = "SELECT * FROM `cameras` WHERE `node_id`=0"; + $Result = $DATABASE->Query($QS,false); + foreach( $Result as $CD ){ + $cnode['id'] = $CD['id']; + $cnode['status'] = $CD['status']; + $cnode['login'] = $CD['access_login']; + $cnode['password']= $CD['access_pass']; + $cnode['name'] = urldecode($CD['name']); + $cnode['hardware']= urldecode($CD['hardware']); + $cnode['caps'] = 'IP'; + $cnode['ip'] = $CD['ip']; + $cnode['mac'] = $CD['mac']; + $cnode['ena'] = 1; + $Data['nodes'][] = $cnode; + }; + } else { + $QS = "SELECT * FROM `media_streams` WHERE `source_type`='A' AND `source_id`=0"; + $Result = $DATABASE->Query($QS,false); + foreach( $Result as $CD ){ + $cnode['id'] = $CD['id']; + $cnode['status'] = 'local'; + $T = getDeviceName($CD['mrl']); + $cnode['name'] = $T['name']; + $cnode['hardware']= $T['dev']; + $cnode['caps'] = 'Analog'; + $cnode['ip'] = '['.$CD['img_width'] .'x' . $CD['img_height'] .']'; + $cnode['mac'] = $CD['mrl']; + if( $T['dev']=='unknown') $cnode['ena'] = 0; else $cnode['ena'] = 1; + $Data['nodes'][] = $cnode; + }; + }; + echo json_encode( $Data ); + } else { + header('location: /'); + }; } else { - header('location: /'); + header('location: /'); }; ?> \ No newline at end of file diff --git a/lib/controller/listServers.php b/lib/controller/listServers.php new file mode 100644 index 0000000..3b780d6 --- /dev/null +++ b/lib/controller/listServers.php @@ -0,0 +1,22 @@ +Data['id'] > 1 ){ + $Data = array(); + $Data['success'] = false; + if( isset( $_POST['SITE'] ) ){ + $SiteID = intval( $_POST['SITE'] ); + $QS = "SELECT `id`, `name` FROM `nodes` WHERE `site_id`={$SiteID} AND `type`=0"; + $Result = $DATABASE->Query($QS,false); + $Data['servers'] = array(); + foreach( $Result as $CD ){ + $cnode['server_id'] = $CD['id']; + $cnode['server_name'] = $CD['name']; + $Data['servers'][] = $cnode; + }; + $Data['success'] = true; + }; + echo json_encode( $Data ); + } else { + header('location: /'); + }; +?> \ No newline at end of file diff --git a/lib/controller/listUarts.php b/lib/controller/listUarts.php new file mode 100644 index 0000000..81bf584 --- /dev/null +++ b/lib/controller/listUarts.php @@ -0,0 +1,22 @@ +Data['id'] > 1 ){ + $Data = array(); + $Data['success'] = false; + if( isset( $_POST['SITE'] ) ){ + $SiteID = intval( $_POST['SITE'] ); + $QS = "SELECT re.aux_id as id, re.device as name FROM resources re LEFT JOIN nodes no ON( re.node_id = no.id ) WHERE ( re.type=1 OR re.type=129 ) AND no.site_id={$SiteID}"; + $Result = $DATABASE->Query($QS,false); + $Data['ports'] = array(); + foreach( $Result as $CD ){ + $cnode['uart_id'] = $CD['id']; + $cnode['uart_name'] = $CD['name']; + $Data['ports'][] = $cnode; + }; + $Data['success'] = true; + }; + echo json_encode( $Data ); + } else { + header('location: /'); + }; +?> \ No newline at end of file diff --git a/lib/controller/props/0_node_prop.js b/lib/controller/props/0_node_prop.js index a501fa1..7b998d5 100644 --- a/lib/controller/props/0_node_prop.js +++ b/lib/controller/props/0_node_prop.js @@ -1,6 +1,7 @@ { xtype: 'form', labelWidth: 75, // label settings here cascade unless overridden + border: false, frame: false, bodyStyle:'padding:5px 5px 0', //width: 190, @@ -11,13 +12,15 @@ items: [{ xtype: 'panel', height: 100, + border: false, + frame: false, html: '


%%%NODENAME%%%

' },{ xtype: 'button', text: 'Settings', width: '100%', handler: function(){ - alert('Settings'); + showSettings(%%%NODEID%%%); } },{ xtype:'fieldset', diff --git a/lib/controller/resetAllSettings.php b/lib/controller/resetAllSettings.php index 3a1d4ab..fe4053e 100644 --- a/lib/controller/resetAllSettings.php +++ b/lib/controller/resetAllSettings.php @@ -26,7 +26,28 @@ $QS = "DELETE FROM `media_streams` WHERE `id`={$R['aux_id']}"; $DATABASE->Query( $QS ); break; - }; + }; + // Handle Network Interfaces + case 100: + case 101: + case 102: + case 103: + case 104: + case 105:{ + $QS = "DELETE FROM `network_interfaces` WHERE `id`={$R['aux_id']}"; + $DATABASE->Query( $QS ); + $QS = "DELETE FROM `networks` WHERE `nif_id`={$R['aux_id']}"; + $DATABASE->Query( $QS ); + $QS = "DELETE FROM `network_infrastructure` WHERE `nif_id`={$R['aux_id']}"; + $DATABASE->Query( $QS ); + $QS = "DELETE FROM `wifis` WHERE `nif_id`={$R['aux_id']}"; + $DATABASE->Query( $QS ); + break; + }; + // Handle Access Point + case 125:{ + break; + }; }; $QS = "DELETE FROM `resources` WHERE `id`={$R['id']}"; $DATABASE->Query( $QS ); @@ -115,7 +136,7 @@ $QS = "SELECT * FROM `nodes` WHERE `site_id`={$SITE} AND `type`=0"; $SR = $DATABASE->Query( $QS ); foreach( $SR as $S ){ - $QS = "INSERT INTO `servers_queue` SET `server_id`={$S['aux_id']}, `ts`=NOW(), `cmd`=251"; + $QS = "INSERT INTO `nodes_qcq` SET `node_id`={$S['id']}, `cmd`=251"; $DATABASE->Query( $QS ); }; } else { diff --git a/lib/controller/setAnalogStreamCtrl.php b/lib/controller/setAnalogStreamCtrl.php new file mode 100644 index 0000000..369345a --- /dev/null +++ b/lib/controller/setAnalogStreamCtrl.php @@ -0,0 +1,36 @@ +Data['id'] > 1 ){ + $STREAM = intval( $_POST['STREAM'] ); + $PID = $_POST['PID']; + if( $_POST['VALUE'] == 'true' ){ + $VALUE = 1; + } else { + $VALUE = intval( $_POST['VALUE'] ); + }; + if( $STREAM > 0 && $PID!= '' ){ + $QS = "SELECT * FROM `media_streams` WHERE `id` = {$STREAM}"; + $Result = $DATABASE->Query( $QS, false ); + if( count( $Result ) ){ + $CS = $Result[0]; + if( $CS['source_type'] == 'A' ){ + $CMD = ""; + if( $PID == 'frame_format' ){ + $CMD = "v4l2-ctl -d {$CS['mrl']} --set-fmt-video=pixelformat=MJPG"; + } else if( $PID == 'frame_size' ){ + $TArr = explode( 'x', $_POST['VALUE'] ); + if( count( $TArr ) == 2 ){ + $CMD = "v4l2-ctl -d {$CS['mrl']} --set-fmt-video=width={$TArr[0]},height={$TArr[1]}"; + $QS = "UPDATE `media_streams` SET `img_width`={$TArr[0]}, `img_height`={$TArr[1]} WHERE `id`={$STREAM}"; + $DATABASE->Query($QS); + }; + } else { + $CMD = "v4l2-ctl -d {$CS['mrl']} --set-ctrl={$PID}={$VALUE}"; + }; + if( $CMD != '' ) $Ret = `$CMD`; + echo $CMD; + }; + }; + }; + }; +?> \ No newline at end of file diff --git a/lib/controller/updateLrfSettings.php b/lib/controller/updateLrfSettings.php index 16c0da6..9dc38ac 100644 --- a/lib/controller/updateLrfSettings.php +++ b/lib/controller/updateLrfSettings.php @@ -8,13 +8,17 @@ if(isset($_POST['SADDR'])){ $ADDR = intval($_POST['SADDR']); $RANGE = floatval($_POST['SRANGE']); - $QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE}, `label`='{$NAME}' WHERE id={$S_ID}"; + $QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE} WHERE id={$S_ID}"; $DATABASE->Query( $QS ); + //$QS="UPDATE `lrf_sensors` SET `device_id`={$ADDR}, `max_range`={$RANGE}, `label`='{$NAME}' WHERE id={$S_ID}"; + //$DATABASE->Query( $QS ); } else { $IP= $DATABASE->escape($_POST['SIPADDR']); $NAME = $DATABASE->escape($_POST['SNAME']); - $QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}', `label`='{$NAME}' WHERE id={$S_ID}"; + $QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}' WHERE id={$S_ID}"; $DATABASE->Query( $QS ); + //$QS="UPDATE `lrf_sensors` SET `ip_address`='{$IP}', `label`='{$NAME}' WHERE id={$S_ID}"; + //$DATABASE->Query( $QS ); }; $QS="UPDATE `nodes` SET `name`='{$NAME}' WHERE `aux_id`={$S_ID}"; $DATABASE->Query( $QS ); diff --git a/lib/controller/updateUserSettings.php b/lib/controller/updateUserSettings.php index 81ea1fd..0fbb2a7 100644 --- a/lib/controller/updateUserSettings.php +++ b/lib/controller/updateUserSettings.php @@ -4,14 +4,20 @@ if( isset( $_POST['SSS'] ) ){ $SETTING_ID = intval($_POST['SSS']); switch( $SETTING_ID ){ - case 15:{ - $WIDTH = intval($_POST['WID']); - $HEIGHT = intval($_POST['HEI']); - $QS="UPDATE `users` SET `width`={$WIDTH}, `height`={$HEIGHT} WHERE id={$CUser->Data['id']}"; - $DATABASE->Query( $QS ); - $LOG->ScreenChanges( $CUser->Data['width'], $CUser->Data['height'], $WIDTH, $HEIGHT ); - break; - }; + case 15:{ + $WIDTH = intval($_POST['WID']); + $HEIGHT = intval($_POST['HEI']); + $QS="UPDATE `users` SET `width`={$WIDTH}, `height`={$HEIGHT} WHERE id={$CUser->Data['id']}"; + $DATABASE->Query( $QS ); + //$LOG->ScreenChanges( $CUser->Data['width'], $CUser->Data['height'], $WIDTH, $HEIGHT ); + break; + }; + case 26:{ + $CID = intval($_POST['CID']); + $QS="UPDATE `users` SET `last_content_view`={$CID} WHERE id={$CUser->Data['id']}"; + $DATABASE->Query( $QS ); + break; + }; }; }; }; diff --git a/lib/controller/uploadDeviceMask.php b/lib/controller/uploadDeviceMask.php new file mode 100644 index 0000000..c82b4dd --- /dev/null +++ b/lib/controller/uploadDeviceMask.php @@ -0,0 +1,91 @@ +Data['id'] > 1 ){ + $NodeID = intval($_POST['NID']); + //$SiteID = intval($_POST['SITE']); + $LayerID = intval($_POST['MID']); + $LRFID = intval($_POST['LID']); + $SERIAL = json_decode( $_POST['MDTA'] ); + $MHEI = intval($_POST['MIH']); + $SHX = intval($_POST['MSHX']); + $SHY = intval($_POST['MSHY']); + $QS = "SELECT * FROM nodes WHERE id={$NodeID} "; + $Data = array(); + $NPC = 0; + $SCHEDULE_JOB = 0; // NOJOB + $result = $DATABASE->Query( $QS, false ); + if( count( $result ) && $MHEI ){ + $SCALE = 288.0 / floatval( $MHEI ); + $T = $result[0]; + $AID = $T['aux_id']; + $QS = "SELECT * FROM `lrf_masks` WHERE `sensor_id`={$AID} AND `lrf_id`={$LRFID} AND `layer`={$LayerID}"; + $result = $DATABASE->Query( $QS, false ); + $CV = array(); + if( count($result) == 0 ){ // No Masks Where Defined + $QS = "INSERT INTO `lrf_masks` SET `sensor_id`={$AID}, `lrf_id`={$LRFID}, `layer`={$LayerID}"; + $DATABASE->Query( $QS, false ); + $MID = $DATABASE->getLastInsertID(); + } else { + $CM = $result[0]; + $QS = "SELECT * FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $ZA = $DATABASE->Query( $QS ); + foreach( $ZA as $A ){ + $QS = "DELETE FROM `lrf_mask_vertex_points` WHERE `vertex_id`={$A['id']}"; + $DATABASE->Query( $QS ); + }; + $QS = "DELETE FROM `lrf_mask_vertexes` WHERE `mask_id`={$CM['id']}"; + $DATABASE->Query( $QS ); + //$QS = "DELETE FROM `lrf_masks` WHERE `mask_id`={$CM['id']}"; + //$DATABASE->Query( $QS ); + $SCHEDULE_JOB = 1; // Clear Mask + foreach( $SERIAL[0][1]->children as $CCC ){ + $R = $CCC[1]->fillColor[0] * 255; + $G = $CCC[1]->fillColor[1] * 255; + $B = $CCC[1]->fillColor[2] * 255; + $QS = "INSERT INTO `lrf_mask_vertexes` SET `mask_id`={$CM['id']}, `r`={$R}, `g`={$G}, `b`={$B}"; + $DATABASE->Query( $QS, false ); + $VID = $DATABASE->getLastInsertID(); + foreach( $CCC[1]->segments as $SS ){ + if( count( $SS ) == 2 ){ + $X = intval( $SCALE * floatval( intval( $SS[0] ) - $SHX ) ); + $Y = intval( $SCALE * floatval( intval( $SS[1] ) - $SHY ) ); + } else { + $X = intval( $SCALE * floatval( intval( $SS[0][0] ) - $SHX ) ); + $Y = intval( $SCALE * floatval( intval( $SS[0][1] ) - $SHY ) ); + }; + if( $X < 0 ) $X = 0; + if( $X > 2304 ) $X = 2304; + if( $Y < 0 ) $Y = 0; + if( $Y > 288 ) $Y = 288; + $QS = "INSERT INTO `lrf_mask_vertex_points` SET `vertex_id`={$VID}, `x`={$X}, `y`={$Y}"; + $DATABASE->Query( $QS, false ); + $NPC++; + $SCHEDULE_JOB = 2; // Update - Set Mask + }; + }; + }; + switch( $SCHEDULE_JOB ){ + case 1:{ + $CMD = 75+$LayerID; + $QS = "INSERT INTO `nodes_qcq` SET node_id={$NodeID}, `cmd`={$CMD}, `parameter`='{$LRFID}'"; + $DATABASE->Query( $QS, false ); + break; + }; + case 2:{ + $CMD = 60+$LayerID; + $QS = "INSERT INTO `nodes_qcq` SET node_id={$NodeID}, `cmd`={$CMD}, `parameter`='{$LRFID}'"; + $DATABASE->Query( $QS, false ); + break; + }; + }; + $Data[] = $CV; + }; + if( $NPC > 2 ){ + // Need to shcedule Rasterisation and send to device + + }; + echo json_encode( $Data ); + exit(); + }; + header('location: /'); +?> \ No newline at end of file diff --git a/lib/javascript/jsapi_dynamic/rgoose_camera_editor.js b/lib/javascript/jsapi_dynamic/rgoose_cameras.js similarity index 60% rename from lib/javascript/jsapi_dynamic/rgoose_camera_editor.js rename to lib/javascript/jsapi_dynamic/rgoose_cameras.js index 0964434..d92da32 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_camera_editor.js +++ b/lib/javascript/jsapi_dynamic/rgoose_cameras.js @@ -5,9 +5,11 @@ var SelectedCam = 0; var SelectedSource = 0; var SelectedCamTYPE = 0; -var connectCamDialog = null; +var connectIPCamDialog = null; +var connectAnalCamDialog = null; var addIpCamDialog = null; var addE2UDialog = null; +var addAnalogCamDialog = null; var cameraListStore = new Ext.data.JsonStore({ root: 'nodes', @@ -25,13 +27,16 @@ var cameraListStore = new Ext.data.JsonStore({ type: 'string' },{ name: 'caps', - type: 'int' + type: 'string' },{ name: 'ip', type: 'string' },{ name: 'mac', type: 'string' + },{ + name: 'ena', + type: 'int' }], proxy : new Ext.data.HttpProxy({ method: 'POST', @@ -67,13 +72,35 @@ var sourceListStore = new Ext.data.JsonStore({ }] }); -var cameraListSelModel = new Ext.grid.RowSelectionModel({ +var IPCameraListSelModel = new Ext.grid.RowSelectionModel({ singleSelect: true, listeners: { rowselect: function(sm, row, rec) { SelectedCam = rec.data.id; - var CB = Ext.getCmp('con_to_src'); - CB.enable(); + var CB = Ext.getCmp('con_to_ip_src'); + if( rec.data.ena ){ + CB.enable(); + } else { + CB.disable(); + }; + } + } +}); + +var AnalogCameraListSelModel = new Ext.grid.RowSelectionModel({ + singleSelect: true, + listeners: { + rowselect: function(sm, row, rec) { + SelectedSource = rec.data.id; + var CB = Ext.getCmp('con_to_anal_src'); + var CC = Ext.getCmp('cha_an_strim_set'); + if( rec.data.ena ){ + CB.enable(); + CC.enable(); + } else { + CB.disable(); + CC.disable(); + }; } } }); @@ -108,10 +135,10 @@ function camCapRenderer(val){ return p1+p2+p3; }; -var cameraListColModel = new Ext.grid.ColumnModel({ +var IPCameraListColModel = new Ext.grid.ColumnModel({ columns: [ {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, - {header: "Type",width: 60, sortable: false, fixed: true, menuDisabled: true, renderer: camCapRenderer, dataIndex: 'caps' }, + {header: "Type",width: 60, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'caps' }, {header: "IP Address", width: 120, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ip' }, {header: "MAC", width: 120, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'mac' }, {header: "Name", dataIndex: 'name' }, @@ -129,6 +156,27 @@ var cameraListColModel = new Ext.grid.ColumnModel({ } }); +var AnalogCameraListColModel = new Ext.grid.ColumnModel({ + columns: [ + {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, + {header: "Type",width: 60, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'caps' }, + {header: "Frame Size", width: 60, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ip' }, + {header: "Device", width: 120, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'mac' }, + {header: "Name", width: 200, dataIndex: 'name' }, + {header: "HW", menuDisabled: true, dataIndex: 'hardware' } + ], + defaults: { + sortable: true, + menuDisabled: true, + width: 100 + }, + listeners: { + hiddenchange: function(cm, colIndex, hidden) { + //saveConfig(colIndex, hidden); + } + } +}); + var sourceListColModel = new Ext.grid.ColumnModel({ columns: [ {header: "id", width: 50, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' }, @@ -193,7 +241,7 @@ function loadCameraSettings( SC ){ }; function preloadOnvifCredentials( SC ){ - showCamPropDialog(); + showIPCamPropDialog(); Ext.Ajax.request({ url: '/lib/controller/getOnvifCredentials.php', params: { @@ -297,9 +345,9 @@ function discoverOnvifProfiles( CamID, camUser, camPasswd ){ var CamPropType = 0; -function showCamPropDialog(){ - if( connectCamDialog == null ){ - connectCamDialog = new Ext.Window({ +function showIPCamPropDialog(){ + if( connectIPCamDialog == null ){ + connectIPCamDialog = new Ext.Window({ modal: true, title: (CamPropType)?'GetLabel('_CON_2_IP_CAM_');?>':'IP Camera Settings', width: 600, @@ -536,17 +584,17 @@ function showCamPropDialog(){ }, items:[{ width: 200, - html: 'PTZ Control' + html: 'GetLabel('__PTZ_CONTROL__');?>' },{ xtype: 'combo', - fieldLabel: 'Ptz Control', + fieldLabel: 'GetLabel('__PTZ_CONTROL__');?>', lazyRender: true, id: 'ptz_proto', mode: 'local', store: new Ext.data.ArrayStore({ fields: ['type','type_txt'], data: [ - [0,'No PTZ'], + [0,'GetLabel('_NO_PTZ_');?>'], [1,'Sony VISCA'], [2,'Pelco-D'], [3,'OnVif'], @@ -583,10 +631,10 @@ function showCamPropDialog(){ },{ html: ' ' },{ - html: 'UART Port' + html: 'GetLabel('_UART_PORT_');?>' },{ xtype: 'combo', - fieldLabel: 'UART Port', + fieldLabel: 'GetLabel('_UART_PORT_');?>', lazyRender: true, id: 'uart_id', mode: 'local', @@ -594,7 +642,7 @@ function showCamPropDialog(){ store: new Ext.data.ArrayStore({ fields: ['uart','uart_txt'], data: [Query( $QS ); if( count( $RR ) ){ $RE=array(); @@ -603,7 +651,7 @@ function showCamPropDialog(){ }; echo implode( ',', $RE ); } else { - echo "[0, 'No UARTS DEFINED']"; + echo "[0, \"".$Labels->GetLabel('_NO_UARTS_DEF_')."\"]"; }; ?>] }), @@ -612,7 +660,7 @@ function showCamPropDialog(){ },{ html: ' ' },{ - html: 'Camera ID' + html: 'GetLabel('_CAM_PROTO_ID_');?>' },{ xtype: 'numberfield', id: 'prot_id', @@ -791,7 +839,7 @@ function showCamPropDialog(){ }; if( AllOK ){ Ext.Ajax.request({ - url: '/lib/controller/AddCameraNode.php', + url: '/lib/controller/addCameraNode.php', params: { SITEID: , UID: , @@ -826,7 +874,475 @@ function showCamPropDialog(){ } else { }; - connectCamDialog.show(); + connectIPCamDialog.show(); +}; + +function showAnalCamPropDialog(){ + if( connectAnalCamDialog == null ){ + connectAnalCamDialog = new Ext.Window({ + modal: true, + title: 'GetLabel('_CREA_ANAL_CAM_');?>', + width: 600, + height: 500, + layout: 'vbox', + closeAction: 'hide', + border: false, + items:[{ + xtype: 'form', + width: '100%', + labelWidth: 200, + labelAlign: 'right', + labelSeparator: '', + items: [{ + xtype: 'spacer', + height: 5 + },{ + id: 'cam_label', + xtype: 'textfield', + fieldLabel: 'GetLabel('_CAM_MAP_NAME_');?>' + //width: 200 + },{ + xtype: 'spacer', + height: 5 + }] + },{ + id: 'coc_tabs', + xtype: 'tabpanel', + activeTab: 0, + items: [{ + title: 'Lens Settings', + xtype: 'form', + id: 'lens_tab', + disabled: false, + items:[{ + layout: 'table', + layoutConfig: { + columns: 3 + }, + defaults: { + frame: false, + bodyStyle: 'padding:10px', + border: false + }, + items:[{ + width: 200, + html: 'Sensor Size' + },{ + xtype: 'combo', + fieldLabel: 'Sensor Size', + lazyRender: true, + id: 'sens_size', + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: ['size','size_txt'], + data: [ + [0,'1/3.6"'], + [1,'1/3.2"'], + [2,'1/3"'], + [3,'1/2.7"'], + [4,'1/2"'], + [5,'1/1.8"'], + [6,'2/3"'], + [7,'1"'], + [8,'4/3"'], + [9,'APS-C'], + [10,'35 mm'], + [11,'645'] + ] + }), + valueField: 'size', + displayField: 'size_txt' + },{ + html: ' ' + },{ + html: 'Fixed Zoom' + },{ + xtype: 'radio', + id: 'no_zoom', + name: 'zoom_ena', + value: 0, + checked: true + },{ + html: ' ' + },{ + html: 'Variable Zoom' + },{ + xtype: 'radio', + id: 'on_zoom', + hideLabel: false, + fieldLabel: 'Variable Zoom', + html: 'koko', + name: 'zoom_ena', + value: 1, + checked: false, + handler: function( a, c ){ + if( c ){ + Ext.getCmp('max_foc').enable(); + Ext.getCmp('zoom_val').enable(); + var mf = Ext.getCmp('min_foc').getValue(); + if( mf > 0 ){ + Ext.getCmp('max_foc').setValue( mf ); + Ext.getCmp('zoom_val').setValue( 1 ); + }; + } else { + Ext.getCmp('max_foc').disable(); + Ext.getCmp('zoom_val').disable(); + Ext.getCmp('zoom_disp').update(' '); + }; + } + },{ + html: ' ' + },{ + html: 'Min. Focal Length' + },{ + xtype: 'numberfield', + id: 'min_foc', + width: '95%', + minValue: 1.0, + maxValue: 270.0 + },{ + html: ' ' + },{ + html: 'Max. Focal Length' + },{ + xtype: 'numberfield', + id: 'max_foc', + width: '95%', + disabled: true, + minValue: 1.0, + maxValue: 270.0, + listeners:{ + change: function( a, c, b ){ + if( b == c ) return; + var mf = Ext.getCmp('min_foc').getValue(); + if( mf > 0 ){ + if( c < mf ){ + Ext.getCmp('max_foc').setValue( mf ); + } else { + var zl = c / mf; + Ext.getCmp('zoom_val').setValue( zl ); + }; + }; + } + } + },{ + html: ' ' + },{ + html: 'Zoom Ratio' + },{ + xtype: 'slider', + id: 'zoom_val', + disabled: true, + minValue: 1.0, + maxValue: 40.0, + listeners:{ + change: function( a, c, b ){ + var mf = Ext.getCmp('min_foc').getValue(); + if( mf > 0 ){ + Ext.getCmp('max_foc').setValue( mf*c ); + Ext.getCmp('zoom_disp').update('

X '+ c + '

'); + }; + } + } + },{ + id: 'zoom_disp', + html: ' ' + }] + }] + },{ + title: 'GetLabel('_PTZ_TAB_');?>', + id: 'ptz_tab', + disabled: true, + items:[{ + layout: 'table', + layoutConfig: { + columns: 3 + }, + defaults: { + frame: false, + bodyStyle: 'padding:10px', + border: false + }, + items:[{ + width: 200, + html: 'GetLabel('__PTZ_CONTROL__');?>' + },{ + xtype: 'combo', + fieldLabel: 'GetLabel('__PTZ_CONTROL__');?>', + lazyRender: true, + id: 'ptz_proto', + mode: 'local', + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['type','type_txt'], + data: [ + [0,'GetLabel('_NO_PTZ_');?>'], + [1,'Sony VISCA'], + [2,'Pelco-D'], + [3,'OnVif'], + [4,'PSIA'], + [5,'GB/T28181'] + ] + }), + valueField: 'type', + displayField: 'type_txt', + listeners:{ + change: function( a, c, b ){ + if( c > 0 ){ + if( c != 3 ){ + Ext.getCmp('uart_id').enable(); + Ext.getCmp('prot_id').enable(); + } else { + Ext.getCmp('uart_id').disable(); + Ext.getCmp('prot_id').disable(); + }; + Ext.getCmp('pan_mode').enable(); + Ext.getCmp('tilt_mode').enable(); + Ext.getCmp('pan_ang').enable(); + Ext.getCmp('tilt_ang').enable(); + } else { + Ext.getCmp('uart_id').disable(); + Ext.getCmp('prot_id').disable(); + Ext.getCmp('pan_mode').disable(); + Ext.getCmp('tilt_mode').disable(); + Ext.getCmp('pan_ang').disable(); + Ext.getCmp('tilt_ang').disable(); + }; + } + } + },{ + html: ' ' + },{ + html: 'GetLabel('_UART_PORT_');?>' + },{ + xtype: 'combo', + fieldLabel: 'GetLabel('_UART_PORT_');?>', + lazyRender: true, + id: 'uart_id', + mode: 'local', + disabled: true, + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['uart','uart_txt'], + data: [Query( $QS ); + if( count( $RR ) ){ + $RE=array(); + foreach( $RR as $R ){ + $RE[] = "[ {$R['aux_id']}, '{$R['device']}']"; + }; + echo implode( ',', $RE ); + } else { + echo "[0, \"".$Labels->GetLabel('_NO_UARTS_DEF_')."\"]"; + }; + ?>] + }), + valueField: 'uart', + displayField: 'uart_txt' + },{ + html: ' ' + },{ + html: 'GetLabel('_CAM_PROTO_ID_');?>' + },{ + xtype: 'numberfield', + id: 'prot_id', + width: '95%', + disabled: true, + minValue: 0, + maxValue: 255 + },{ + html: ' ' + },{ + html: 'Pan Model' + },{ + xtype: 'combo', + fieldLabel: 'Pan Model', + lazyRender: true, + id: 'pan_mode', + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + disabled: true, + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: ['pm','pm_txt'], + data: [ + [0,'Regular'], + [1,'Reversed'] + ] + }), + valueField: 'pm', + displayField: 'pm_txt' + },{ + html: ' ' + },{ + html: 'Tottal Pan Angles' + },{ + xtype: 'numberfield', + id: 'pan_ang', + width: '95%', + disabled: true, + minValue: 0, + maxValue: 360 + },{ + html: ' ' + },{ + html: 'Tilt Model' + },{ + xtype: 'combo', + fieldLabel: 'Tilt Model', + lazyRender: true, + id: 'tilt_mode', + disabled: true, + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: ['tm','tm_txt'], + data: [ + [0,'Regular'], + [1,'Reversed'], + [2,'Shifted 90°'], + [3,'Rev-Shifted 90°'] + ] + }), + valueField: 'tm', + displayField: 'tm_txt' + },{ + html: ' ' + },{ + html: 'Tottal Tilt Angles' + },{ + xtype: 'numberfield', + id: 'tilt_ang', + width: '95%', + disabled: true, + minValue: 0, + maxValue: 180 + },{ + html: ' ' + }] + }] + }] + }], + bbar:[{ + text: 'GetLabel('_CANCEL_');?>', + handler: function(){ + //connectAnalCamDialog.hide(); + connectAnalCamDialog.close(); + connectAnalCamDialog = null; + } + },'->',{ + text: 'GetLabel('_ADD_CAMERA2SITE_');?>', + id: 'acm_btn', + handler: function(){ + var CLAB = Ext.getCmp('cam_label').getValue(); + var CPTZP = Ext.getCmp('ptz_proto').getValue(); + var CPTZU = Ext.getCmp('uart_id').getValue(); + var CPTZID = Ext.getCmp('prot_id').getValue(); + var CPANM = Ext.getCmp('pan_mode').getValue(); + var CTILTM = Ext.getCmp('tilt_mode').getValue(); + var CPANANG = Ext.getCmp('pan_ang').getValue(); + var CTILTANG = Ext.getCmp('tilt_ang').getValue(); + var CIMAGER = Ext.getCmp('sens_size').getValue(); + var CMINF = Ext.getCmp('min_foc').getValue(); + var CMAXF = Ext.getCmp('max_foc').getValue(); + var AllOK = true; + if( CLAB == '' ) { + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Provide Camera Name!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; + if( SelectedSource == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Select Image Source!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; + if( ( SelectedCamTYPE == 11 || SelectedCamTYPE == 13 ) && CPTZP == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Provide PTZ Protocol type!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; + if( ( CPTZP == 1 || CPTZP == 2 ) && CPTZU == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Provide UART Port!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; + if( ( CPTZP == 1 || CPTZP == 2 ) && CPTZID == 0 ){ + AllOK = false; + Ext.Msg.show({ + title:'Data Error!', + msg: 'Please Provide Camera ID!', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + return; + }; + if( AllOK ){ + Ext.Ajax.request({ + url: '/lib/controller/addNetworkNode.php', + params: { + SITEID: , + UID: , + SID: '', + CID: SelectedCam, + STREAM: SelectedSource, + LAB: CLAB, + UART: CPTZU, + PROTOID: CPTZID, + PANMODE: CPANM, + TILTMODE: CTILTM, + PANANG: CPANANG, + TILTANG: CTILTANG, + IMSIZE: CIMAGER, + FMIN: CMINF, + FMAX: CMAXF, + PTZ: CPTZP, + TYPE: SelectedCamTYPE + }, + success: function( response, opts ){ + reloadNetworkData(); + addAnalogCamDialog.close(); + addAnalogCamDialog = null; + connectAnalCamDialog.close(); + connectAnalCamDialog = null; + //loadSystemEditor(); + }, + failure: failureAJAXFunction + }); + }; + } + }] + }); + } else { + + }; + connectAnalCamDialog.show(); + if( SelectedCamTYPE == 11 ){ + Ext.getCmp('ptz_tab').enable(); + Ext.getCmp('on_zoom').enable(); + } else { + Ext.getCmp('ptz_tab').disable(); + Ext.getCmp('on_zoom').disable(); + }; }; function connectToSeleced(){ @@ -848,9 +1364,11 @@ function addIpCam(){ closeAction: 'hide', items:{ xtype: 'grid', + frame: false, + border: false, ds: cameraListStore, - cm: cameraListColModel, - sm: cameraListSelModel, + cm: IPCameraListColModel, + sm: IPCameraListSelModel, viewConfig: { forceFit: true }, @@ -860,7 +1378,7 @@ function addIpCam(){ addIpCamDialog.hide(); } },'->',{ - id: 'con_to_src', + id: 'con_to_ip_src', text: 'GetLabel('_CONNECT_2_SEL_');?>', disabled: ( SelectedCam == 0 ), handler: connectToSeleced @@ -869,23 +1387,25 @@ function addIpCam(){ }); }; addIpCamDialog.show(); - cameraListStore.load({params:{start:0, limit:50}}); + cameraListStore.load({params:{cam_sources:'ipv'}}); }; -var addAnalogCamDialog = null; + function addAnalogCam(){ if( addAnalogCamDialog == null ){ addAnalogCamDialog = new Ext.Window({ modal: true, - title: 'GetLabel('_DET_IP_CAMERA_LST_');?>', + title: 'GetLabel('_ANAL_SOURCES_LST_');?>', width: 800, height: 600, - layout: 'fit', + layout: 'fit', closeAction: 'hide', items:[{ xtype: 'grid', - ds: cameraListStore, - cm: cameraListColModel, - sm: cameraListSelModel, + frame: false, + border: false, + ds: cameraListStore, + cm: AnalogCameraListColModel, + sm: AnalogCameraListSelModel, viewConfig: { forceFit: true } @@ -893,17 +1413,93 @@ function addAnalogCam(){ bbar: [{ text: 'GetLabel('_CANCEL_');?>', handler: function(){ - addIpCamDialog.hide(); + addAnalogCamDialog.hide(); } },'->',{ - id: 'con_to_src', + id: 'cha_an_strim_set', + text: 'GetLabel('_SETTINGS_');?>', + disabled: ( SelectedSource == 0 ), + handler: function(){ + editAnalogStream( SelectedSource ); + } + },{ + id: 'con_to_anal_src', text: 'GetLabel('_CONNECT_2_SEL_');?>', - disabled: ( SelectedCam == 0 ), - handler: connectToSeleced + disabled: ( SelectedSource == 0 ), + handler: function(){ + //alert( 'Cam Type:'+SelectedCamTYPE ); + showAnalCamPropDialog(); + } }] }); }; addAnalogCamDialog.show(); + cameraListStore.load({params:{cam_sources:'anal'}}); +}; +var changer_locked = false; +function changeASS( stream, id ){ + if(changer_locked) return; + changer_locked = true; + var ll = Ext.getCmp( id ); + var name = ll.name; + var value = ll.getValue(); + Ext.Ajax.request({ + url: '/lib/controller/setAnalogStreamCtrl.php', + params: { + STREAM: stream, + PID: name, + VALUE: value, + UID: , + SID: '', + }, + success: function( response, opts ){ + changer_locked = false; + // If the response is JSON, you have to decode it + //var data = Ext.decode(response.responseText); + }, + failure: failureAJAXFunction + }); +}; + +var AnalogStreamEditor = null; + +function editAnalogStream( SelStream, live=0 ){ + if( AnalogStreamEditor == null ){ + AnalogStreamEditor = new Ext.Window({ + modal: ((live==0)?true:false), + title: 'Analog Input Settings', + width: 440, + height: 400, + layout: 'fit', + closeAction: 'hide', + buttonAlign:'center', + items:[{ + }], + bbar: ['->',{ + text: 'GetLabel('_CLOSE_');?>', + handler: function(){//discoverOnvifSources + AnalogStreamEditor.hide(); + } + }] + }); + }; + AnalogStreamEditor.show(); + Ext.Ajax.request({ + url: '/lib/controller/getAnalogStreamCtrl.php', + params: { + STREAM: SelStream, + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + AnalogStreamEditor.removeAll( true ); + AnalogStreamEditor.add( data ); + AnalogStreamEditor.doLayout(); + }, + failure: failureAJAXFunction + }); }; function addEthernet2Uart(){ diff --git a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js index 742b216..61c03cc 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_dashboard.js +++ b/lib/javascript/jsapi_dynamic/rgoose_dashboard.js @@ -3,6 +3,223 @@ +var serverToolBox = null; +var currentNodeID = 0; + + +//import * as THREE from 'three'; + +//let camera, scene, renderer; +var l3dMapOverlayTexture = new THREE.TextureLoader().load( '/lib/controller/data/assets/images/mask_3d.png' ); +var l3dMapOverlayMaterial = new THREE.MeshBasicMaterial( { map: l3dMapOverlayTexture, alphaTest: 0.7 } ); +var l3dMapOverlayGeometry = new THREE.SphereGeometry( 490, 60, 40 ); +// invert the geometry on the x-axis so that all of the faces point inward + l3dMapOverlayGeometry.scale( -1, 1, 1 ); +var l3dMapOverlayMesh = new THREE.Mesh( l3dMapOverlayGeometry, l3dMapOverlayMaterial ); + +function addl3dTarget( id, radius, az, el, color = 0xff0000 ){ + if( id > 0 ){ + var target = {}; + target.geometry = new THREE.BoxGeometry( 10, 10, 10 ); + //target.geometry = new THREE.OctahedronGeometry({ radius : 20 }); + //target.geometry.translate( x, y, z ); + + // Turn back into Cartesian coordinates + var fi = (Math.PI/2) - el; + var x = radius * Math.sin( fi) * Math.cos( az ); + var y = radius * Math.sin( fi ) * Math.sin( az ); + var z = radius * Math.cos( fi ); + + //alert( "Cords: "+x+" "+y+" "+z+" An:"+az+" "+el); + //target.geometry.position.set( x, y, z ); //translate( x, y, z ); + target.material = new THREE.MeshBasicMaterial( {color: color} ); + target.mesh = new THREE.Mesh( target.geometry, target.material ); + nodeTHREEviewers[id].scene.add( target.mesh ); + target.mesh.position.set( x, z, y ); + nodeTHREEviewers[id].targets.push( target ); + }; +}; + +function cleanup3DDraw( id ){ + if( typeof nodeTHREEviewers[id] !== 'undefined' ){ + if( typeof nodeTHREEviewers[id].targets !== 'undefined' ){ + for( var z=0; z < nodeTHREEviewers[id].targets.length; z++ ){ + nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].targets[z].mesh ); + delete nodeTHREEviewers[id].targets[z].mesh; + delete nodeTHREEviewers[id].targets[z].material; + delete nodeTHREEviewers[id].targets[z].geometry; + delete nodeTHREEviewers[id].targets[z]; + }; + nodeTHREEviewers[id].targets = []; + //nodeTHREEviewers[id].renderer.render( nodeTHREEviewers[id].scene, nodeTHREEviewers[id].camera ); + }; + }; +}; + +function Draw3DTargets( k, b ){ + cleanup3DDraw( k ); + for( var z = 0; z < b.length; z++ ){ + var az = b[z].az * ( Math.PI/180.0 ); + var el = b[z].el * ( Math.PI/180.0 ); + addl3dTarget( k, b[z].range, az, el, b[z].color ); + }; +}; + +let isUserInteracting = false, onPointerDownMouseX = 0, onPointerDownMouseY = 0, + lon = 0, onPointerDownLon = 0, + lat = 0, onPointerDownLat = 0, + phi = 0, theta = 0; + + function onWindowResize() { + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + + renderer.setSize( window.innerWidth, window.innerHeight ); + + }; + + function onPointerDown( event ) { + + if ( event.isPrimary === false ) return; + + isUserInteracting = true; + + onPointerDownMouseX = event.clientX; + onPointerDownMouseY = event.clientY; + + onPointerDownLon = lon; + onPointerDownLat = lat; + + document.addEventListener( 'pointermove', onPointerMove ); + document.addEventListener( 'pointerup', onPointerUp ); + + }; + + function onPointerMove( event ) { + + if ( event.isPrimary === false ) return; + + lon = ( onPointerDownMouseX - event.clientX ) * 0.1 + onPointerDownLon; + lat = ( event.clientY - onPointerDownMouseY ) * 0.1 + onPointerDownLat; + + }; + + function onPointerUp() { + + if ( event.isPrimary === false ) return; + + isUserInteracting = false; + + document.removeEventListener( 'pointermove', onPointerMove ); + document.removeEventListener( 'pointerup', onPointerUp ); + + }; + + function onDocumentMouseWheel( event ) { + var id = event.currentTarget.myVID; + if( id > 0 ){ + const fov = nodeTHREEviewers[id].camera.fov + event.deltaY * 0.05; + nodeTHREEviewers[id].camera.fov = THREE.MathUtils.clamp( fov, 10, 75 ); + nodeTHREEviewers[id].camera.updateProjectionMatrix(); + }; + }; + function reload3dTexture( id ){ + if( typeof nodeTHREEviewers[id] !== 'undefined' ){ + stopAnimation(); + //while( nodeTHREEviewers[id].scene.children.length > 0){ + // nodeTHREEviewers[id].scene.remove(nodeTHREEviewers[id].scene.children[0]); + //}; + nodeTHREEviewers[id].scene.remove( nodeTHREEviewers[id].mesh ); + //nodeTHREEviewers[id].mesh.geometry.dispose(); + //nodeTHREEviewers[id].mesh.material.dispose(); + delete nodeTHREEviewers[id].mesh; + delete nodeTHREEviewers[id].material; + delete nodeTHREEviewers[id].texture; + delete nodeTHREEviewers[id].geometry; + + nodeTHREEviewers[id].geometry = new THREE.SphereGeometry( 500, 60, 40 ); + nodeTHREEviewers[id].geometry.scale( -1, 1, 1 ); + nodeTHREEviewers[id].texture = new THREE.TextureLoader().load( '/lib/controller/getDeviceDraw.php?NID='+id ); + nodeTHREEviewers[id].material = new THREE.MeshBasicMaterial( { map: nodeTHREEviewers[id].texture } ); + nodeTHREEviewers[id].mesh = new THREE.Mesh( nodeTHREEviewers[id].geometry, nodeTHREEviewers[id].material ); + + nodeTHREEviewers[id].scene.add( nodeTHREEviewers[id].mesh ); + animate(); + //nodeTHREEviewers[id].material.map.needsUpdate = true; + //nodeTHREEviewers[id].material.needsUpdate = true + //alert( ' reloadded ' ); + }; + }; + function stopAnimation(){ + if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); + }; + function animate( ) { + if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); + nodeTHREEanimationId = requestAnimationFrame( animate ); + nodeTHREEviewers.forEach( function(element, index, array){ + if ( isUserInteracting === false ) { + + lon += 0.5; + + } + + lat = Math.max( - 85, Math.min( 85, lat ) ); + phi = THREE.MathUtils.degToRad( 90 - lat ); + theta = THREE.MathUtils.degToRad( lon ); + + const x = 500 * Math.sin( phi ) * Math.cos( theta ); + const y = 500 * Math.cos( phi ); + const z = 500 * Math.sin( phi ) * Math.sin( theta ); + + element.camera.lookAt( x, y, z ); + + element.renderer.render( element.scene, element.camera ); + }); + //update( id ); + }; + function animateTargets(){ + if( nodeTHREEanimationId > 0 ) cancelAnimationFrame( nodeTHREEanimationId ); + nodeTHREEanimationId = requestAnimationFrame( animateTargets ); + nodeTHREEviewers.forEach( function(element, index, array){ + if ( isUserInteracting === false ) { + + if( element.targetShowCopunter ){ + element.targetShowCopunter--; + } else { + element.camera.lookAt( element.targets[element.targetIndex].mesh.position ); + element.targetShowCopunter = 100; + element.renderer.render( element.scene, element.camera ); + element.targetIndex++; + if( element.targetIndex == element.targets.length ) element.targetIndex = 0; + }; + }; + }); + }; + function update() { + + if ( isUserInteracting === false ) { + + lon += 0.5; + + } + + lat = Math.max( - 85, Math.min( 85, lat ) ); + phi = THREE.MathUtils.degToRad( 90 - lat ); + theta = THREE.MathUtils.degToRad( lon ); + + const x = 500 * Math.sin( phi ) * Math.cos( theta ); + const y = 500 * Math.cos( phi ); + const z = 500 * Math.sin( phi ) * Math.sin( theta ); + + camera.lookAt( x, y, z ); + + renderer.render( scene, camera ); + + }; + + + function Pie(cx, cy, radius, data) { var decimals = 4; @@ -222,7 +439,7 @@ function updateDashBoardItemLayout( id, x, y ){ var drawZoomLevels = Array(); -function cleanupDraw( a ){ +function cleanup2DDraw( a ){ var canvas = document.getElementById('targ_canvas_'+a ); var ctx = canvas.getContext('2d'); var img = document.getElementById('draw_img_'+a ); @@ -231,7 +448,7 @@ function cleanupDraw( a ){ img.style='display: none;'; }; -function DrawTargets( k, b ){ +function Draw2DTargets( k, b ){ var canvas = document.getElementById('targ_canvas_'+k ); var ctx = canvas.getContext('2d'); var img = document.getElementById('draw_img_'+k ); @@ -341,12 +558,14 @@ function fetchSiteStatus(){ params: { SITE: , LNID: lastNotificationID, - SPID: ServerPID, + SPID: StatusTS, + LOAT: LoadTS, UID: , SID: '' }, success: function( response, opts ){ var data = Ext.decode(response.responseText); + StatusTS = data.CTS; if( data.nodes.length > 0 ){ for( i=0; i < data.nodes.length; i++ ){ if( data.nodes[i].type == 0 ){ @@ -361,13 +580,25 @@ function fetchSiteStatus(){ setDonatStatus( '2' , -1 ); }; }; + // Sesors + if( data.nodes[i].type > 0 && data.nodes[i].type < 7 ){ + if( data.nodes[i].reload_draw ){ + reload3dTexture( data.nodes[i].id ); + LoadTS = StatusTS; + }; + }; + // Cameras if( data.nodes[i].type > 9 && data.nodes[i].type < 14 ){ var iel = document.getElementById('img-'+data.nodes[i].id ); - if( !data.nodes[i].valid ){ - if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png"; - } else { - if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src; - };//else { + if( iel != null ){ + if( !data.nodes[i].valid ){ + if( iel.src != "/style/assets/no-signal.png" ) iel.src = "/style/assets/no-signal.png"; + } else { + if( data.nodes[i].src != iel.src ) iel.src = data.nodes[i].src; + }; + + }; + //else { //https://man7.org/linux/man-pages/man2/getrusage.2.html //https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decode //https://stackoverflow.com/questions/13465073/how-to-catch-an-exception-from-image-onload @@ -392,33 +623,184 @@ function fetchSiteStatus(){ }; var tt = Ext.getCmp('status_'+data.nodes[i].id ); if( tt != undefined ){ - switch( data.nodes[i].status ){ - case 0:{ - cleanupDraw( data.nodes[i].id ); - tt.update('
"; + echo "{$R_name}
{$R_dev}
{$R_nfo}
Offline
'); - break; + if( data.nodes[i].type == 3 ){ + if( data.nodes[i].status == 4 ){ + Draw2DTargets( data.nodes[i].id, data.nodes[i].targets ); + } else { + cleanup2DDraw( data.nodes[i].id ); }; - case 1:{ - cleanupDraw( data.nodes[i].id ); - tt.update('
Online
'); - break; + }; + if( data.nodes[i].type == 5 ){//addl3dTarget( id, radius, az, el, color = 0xff0000 ) + if( data.nodes[i].status == 4 ){ + //DrawTargets( data.nodes[i].id, data.nodes[i].targets ); + //addl3dTarget( data.nodes[i].id, data.nodes[i].targets[0].digital, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el ); + //addl3dTarget( data.nodes[i].id, 150, data.nodes[i].targets[0].az, data.nodes[i].targets[0].el ); + Draw3DTargets( data.nodes[i].id, data.nodes[i].targets ); + animateTargets(); + } else { + cleanup3DDraw( data.nodes[i].id ); + animate(); }; - case 2:{ - cleanupDraw( data.nodes[i].id ); - tt.update('
Initializing
'); - break; + var ca = document.getElementById( 'status_canvas_' + data.nodes[i].id ); + var ctx = ca.getContext('2d'); + //if( stat_present ); + ca.style='display: block;'; + ctx.font = "10px Arial"; + ctx.fillStyle = "rgba(255, 255, 255, 255)"; + ctx.fillText( "Master:", 5, 8 ); + ctx.fillText( "Slave:", 5, 24 ); + //var cc = 255 - i ;//* ( 255 / 33 ); + //ctx.fillStyle = "#" + cc.toString(16) + "0000"; + //ctx.fillStyle = "rgba(255, 0, 0, 100)";//+((b.length - i)/ b.length )+")"; + if( data.nodes[i].master_present ){ + ctx.fillStyle = "rgba(0, 255, 0, 255)"; + } else { + ctx.fillStyle = "rgba(128, 0, 0, 255)"; }; - case 3:{ - cleanupDraw( data.nodes[i].id ); - tt.update('
Trouble
'); - break; + ctx.fillRect( 43, 1, 8, 8 ); + if( data.nodes[i].stat_present ){ + ctx.strokeStyle = "#FFFF00"; + ctx.strokeRect( 43, 1, 8, 8 ); + ctx.beginPath(); + ctx.moveTo( 51, 5 ); + ctx.lineTo( 56, 5 ); + ctx.lineTo( 56, 2 ); + ctx.lineTo( 103, 2 ); + ctx.lineTo( 103, 5 ); + ctx.moveTo( 63, 5 ); + ctx.lineTo( 143, 5 ); + ctx.stroke(); + for( z=0; z < 8; z++ ){ + //ctx.strokeStyle = "#FFFF00"; + //ctx.fillStyle = "rgba(0, 255, 0, 255)"; + ctx.fillStyle = "rgba(20, 20, 20, 255)"; + h = 19 - ( 19 * data.nodes[i].runtime.mp[z] ); + ha = 19 - h; + ctx.fillRect( 64 + z*10, 7, 2, h ); + if( ha > 0 ) { + if( data.nodes[i].runtime.mp[z] > 0.8 ){ + ctx.fillStyle = "rgba(0, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.mp[z] > 0.5 ){ + ctx.fillStyle = "rgba( 255, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.mp[z] > 0.3 ){ + ctx.fillStyle = "rgba( 255, 128, 0, 255)"; + } else { + ctx.fillStyle = "rgba( 255, 0, 0, 255)"; + }; + ctx.fillRect( 64 + z*10, 7+h, 2, ha ); + }; + ctx.fillStyle = "rgba(20, 20, 20, 255)"; + h = 19 - ( 19 * data.nodes[i].runtime.gp[z] ); + ha = 19 - h; + ctx.fillRect( 67 + z*10, 7, 2, h ); + if( ha > 0 ) { + if( data.nodes[i].runtime.gp[z] > 0.8 ){ + ctx.fillStyle = "rgba(0, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.gp[z] > 0.5 ){ + ctx.fillStyle = "rgba( 255, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.gp[z] > 0.3 ){ + ctx.fillStyle = "rgba( 255, 128, 0, 255)"; + } else { + ctx.fillStyle = "rgba( 255, 0, 0, 255)"; + }; + ctx.fillRect( 67 + z*10, 7+h, 2, ha ); + }; + ctx.fillStyle = "rgba(20, 20, 20, 255)"; + h = 19 - ( 19 * data.nodes[i].runtime.wp[z] ); + ha = 19 - h; + ctx.fillRect( 70 + z*10, 7, 2, h ); + if( ha > 0 ){ + if( data.nodes[i].runtime.wp[z] > 0.8 ){ + ctx.fillStyle = "rgba(0, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.wp[z] > 0.5 ){ + ctx.fillStyle = "rgba( 255, 255, 0, 255)"; + } else if ( data.nodes[i].runtime.wp[z] > 0.3 ){ + ctx.fillStyle = "rgba( 255, 128, 0, 255)"; + } else { + ctx.fillStyle = "rgba( 255, 0, 0, 255)"; + }; + ctx.fillRect( 70 + z*10, 7+h, 2, ha ); + }; + }; + //ffmpeg -f v4l2 -framerate -thread_queue_size 512 -i -f alsa -thread_queue_size 512 -i -t -c:v h264 -c:a aac -pix_fmt yuv420p + } else { + ctx.strokeStyle = "#808080"; + ctx.strokeRect( 43, 1, 8, 8 ); + ctx.beginPath(); + ctx.moveTo( 51, 5 ); + ctx.lineTo( 56, 5 ); + ctx.lineTo( 56, 2 ); + ctx.lineTo( 103, 2 ); + ctx.lineTo( 103, 5 ); + ctx.moveTo( 63, 5 ); + ctx.lineTo( 143, 5 ); + ctx.stroke(); + ctx.fillStyle = "rgba( 128, 0, 0, 255)"; + for( z=0; z < 8; z++ ){ + ctx.fillRect( 64 + z*10, 7, 2, 19 ); + ctx.fillRect( 67 + z*10, 7, 2, 19 ); + ctx.fillRect( 70 + z*10, 7, 2, 19 ); + //https://www.ebay.com/itm/304440983138 + }; }; - case 4:{ - DrawTargets( data.nodes[i].id, data.nodes[i].targets ); - tt.update('
Alarm
'); - break; + if( data.nodes[i].slave_present ){ + ctx.strokeStyle = "#FFFF00"; + ctx.fillStyle = "rgba(0, 255, 0, 255)"; + } else { + ctx.strokeStyle = "#808080"; + ctx.fillStyle = "rgba(128, 0, 0, 255)"; }; + ctx.fillRect( 43, 17, 8, 8 ); + ctx.strokeRect( 43, 17, 8, 8 ); + ctx.beginPath(); + ctx.moveTo( 51, 21 ); + ctx.lineTo( 56, 21 ); + ctx.lineTo( 56, 31 ); + ctx.lineTo( 187, 31 ); + ctx.lineTo( 187, 28 ); + ctx.moveTo( 147, 28 ); + ctx.lineTo( 227, 28 ); + ctx.stroke(); + for( z=8; z < 16; z++ ){ + //ctx.strokeStyle = "#FFFF00"; + //ctx.fillStyle = "rgba(0, 255, 0, 255)"; + ctx.fillRect( 68 + z*10, 7, 2, 19 ); + ctx.fillRect( 71 + z*10, 7, 2, 19 ); + ctx.fillRect( 74 + z*10, 7, 2, 19 ); + //ctx.strokeRect( 43, 1, 8, 8 ); + }; + }; + if( typeof nodeDashboardStatuses[i] === 'undefined' || nodeDashboardStatuses[i] != data.nodes[i].status ){ + nodeDashboardStatuses[i] = data.nodes[i].status; + switch( data.nodes[i].status ){ + case 0:{ + if( data.nodes[i].type == 3 ) cleanupDraw( data.nodes[i].id ); + tt.update('
Offline
'); + break; + }; + case 1:{ + if( data.nodes[i].type == 3 ) cleanupDraw( data.nodes[i].id ); + tt.update('
Online
'); + break; + }; + case 2:{ + if( data.nodes[i].type == 3 ) cleanupDraw( data.nodes[i].id ); + tt.update('
Initializing
'); + break; + }; + case 3:{ + if( data.nodes[i].type == 3 ) cleanupDraw( data.nodes[i].id ); + tt.update('
Trouble
'); + break; + }; + case 4:{ + if( data.nodes[i].type == 3 ) DrawTargets( data.nodes[i].id, data.nodes[i].targets ); + tt.update('
Alarm
'); + break; + }; + + }; }; }; }; @@ -496,7 +878,7 @@ function loadDashBoard(){ tlInterval = null; timelineObj = null; }; - + setUserContent( 0 ); Ext.Ajax.request({ url: '/lib/controller/getDashBoardItems.php', params: { @@ -545,8 +927,8 @@ function loadDashBoard(){ }); }; -var serverToolBox = null; function showServerToolBox( ServerNodeId ){ + currentNodeID = ServerNodeId; if( serverToolBox == null ){ serverToolBox = new Ext.Window({ title: 'GetLabel('_SERV_CTLPANEL_SHRT_');?>', @@ -561,7 +943,21 @@ function showServerToolBox( ServerNodeId ){ textAlign: 'left', iconCls: 'server_btn_restart', scale: 'large', - iconAlign: 'left' + iconAlign: 'left', + handler: function(){ + doDeviceOperation( currentNodeID, 250 ); + } + },{ + xtype: 'button', + text: 'Initialize Hardware', + width: '100%', + textAlign: 'left', + iconCls: 'server_btn_hwinit', + scale: 'large', + iconAlign: 'left', + handler: function(){ + doDeviceOperation( currentNodeID, 251 ); + } },{ xtype: 'button', text: 'Clear Site', @@ -578,7 +974,8 @@ function showServerToolBox( ServerNodeId ){ var detectionProfileWindow = null; var deviceCtrlNode = ''; -function showDetectionProfile( NodeID ){ +function showSensorToolBox( NodeID ){ + currentNodeID = NodeID; deviceCtrlNode = NodeID + ':0'; Data['access']>4 ) $ColSpan = 4; else $ColSpan = 3; ?> if( detectionProfileWindow == null ){ @@ -591,6 +988,10 @@ function showDetectionProfile( NodeID ){ items:[] }); }; + detectionProfileWindow.show(); + var myMask = new Ext.LoadMask( detectionProfileWindow.getEl(), {msg:"Please wait..."}); + myMask.show(); + Ext.Ajax.request({ url: '/lib/controller/getDetectionProfile.php', params: { @@ -601,8 +1002,14 @@ function showDetectionProfile( NodeID ){ }, success: function( response, opts ){ var data = Ext.decode( response.responseText ); + myMask.hide(); detectionProfileWindow.setTitle( '['+data.name + '] GetLabel('_DEV_CTLPANEL_SHRT_');?>'); detectionProfileWindow.removeAll( true ); + //detectionProfileWindow.setSize( data.width, data.height ); + if( data.additional !== 'undefined' ){ + var addi = Ext.decode( data.additional ); + detectionProfileWindow.add( addi ); + }; if( data.data_status == 3 ){ detectionProfileWindow.add({ xtype: 'panel', @@ -754,7 +1161,8 @@ function showDetectionProfile( NodeID ){ doDeviceOperation( deviceCtrlNode, 1 ); } }); - detectionProfileWindow.show(); + detectionProfileWindow.doLayout(); + //detectionProfileWindow.show(); }, failure: failureAJAXFunction }); diff --git a/lib/javascript/jsapi_dynamic/rgoose_devices_module.js b/lib/javascript/jsapi_dynamic/rgoose_devices.js similarity index 52% rename from lib/javascript/jsapi_dynamic/rgoose_devices_module.js rename to lib/javascript/jsapi_dynamic/rgoose_devices.js index 2b04f48..c3d9bdf 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_devices_module.js +++ b/lib/javascript/jsapi_dynamic/rgoose_devices.js @@ -1,5 +1,243 @@ // + +var UartListStore = new Ext.data.JsonStore({ + root: 'ports', + totalProperty: 'totalCount', + idProperty: 'uart_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'uart_id', + type: 'int' + },{ + name: 'uart_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listUarts.php' + }) +}); + +var ServerListStore = new Ext.data.JsonStore({ + root: 'servers', + totalProperty: 'totalCount', + idProperty: 'server_id', + remoteSort: false, + baseParams: { + UID: 'Data['id'];?>', + SID: '', + SITE: + }, + fields: [{ + name: 'server_id', + type: 'int' + },{ + name: 'server_name', + type: 'string' + }], + proxy : new Ext.data.HttpProxy({ + method: 'POST', + prettyUrls: false, + url: '/lib/controller/listServers.php' + }) +}); + +function loadSettingsLidar3D( NodeID, Master ){ + SelectedNodeID = NodeID; + Ext.Ajax.request({ + url: '/lib/controller/getSettingsLidsr3D.php', + params: { + NID: NodeID, + MST: ((Master)?1:0), + UID: , + SID: '', + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + Ext.getCmp('setting_master_ip').setValue( data.ip_address ); + Ext.getCmp('setting_master_port').setValue( data.port ); + Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address ); + Ext.getCmp('setting_slave_port').setValue( data.aux_port ); + Ext.getCmp('setting_lat').setValue( data.lat ); + Ext.getCmp('setting_lon').setValue( data.lon ); + Ext.getCmp('setting_alt').setValue( data.alt ); + Ext.getCmp('setting_roll').setValue( data.roll ); + Ext.getCmp('setting_pitch').setValue( data.pitch ); + Ext.getCmp('setting_yaw').setValue( data.yaw ); + }, + failure: failureAJAXFunction + }); +}; + +function saveSettingsLidar3D( ){ + if( SelectedNodeID == 0 ) return; + t1 = Ext.getCmp('setting_master_ip').getValue(); + t2 = Ext.getCmp('setting_master_port').getValue(); + t3 = Ext.getCmp('setting_slave_ip').getValue(); + t4 = Ext.getCmp('setting_slave_port').getValue(); + t5 = Ext.getCmp('setting_lat').getValue(); + t6 = Ext.getCmp('setting_lon').getValue(); + t7 = Ext.getCmp('setting_alt').getValue(); + t8 = Ext.getCmp('setting_roll').getValue(); + t9 = Ext.getCmp('setting_pitch').getValue(); + t10 = Ext.getCmp('setting_yaw').getValue(); + Ext.Ajax.request({ + url: '/lib/controller/setSettingsLidsr3D.php', + params: { + NID: SelectedNodeID, + UID: , + SID: '', + MIP: t1, + MPP: t2, + SIP: t3, + SPP: t4, + LAT: t5, + LON: t6, + ALT: t7, + ROL: t8, + PCH: t9, + YAW: t10 + }, + success: function( response, opts ){ + // If the response is JSON, you have to decode it + var data = Ext.decode(response.responseText); + if( data.success == true ) { + Ext.Msg.show({ + title:'Info Message', + msg: 'Settings are sucessfully saved.', + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.INFO //QUESTION + }); + } else { + Ext.Msg.show({ + title:'Error Message', + msg: data['error'], + buttons: Ext.Msg.OK,//YESNOCANCEL, + fn: function(){ + SettingsLidar3D.hide(); + }, + //animEl: 'elId', + icon: Ext.MessageBox.ERROR //QUESTION + }); + }; + }, + failure: failureAJAXFunction + }); +}; + + +function editSettingsLidar3D( NodeID, Master ){ + if( SettingsLidar3D == null ){ + SettingsLidar3D = new Ext.Window({ + modal: true, + title: 'GetLabel("_EDIT_LRF3D_SETTINGS_");?>', + width: 773, + height: 600, + layout: 'fit', + closeAction: 'hide', + listeners:{ + beforehide : function(){ + Ext.getCmp('connectstarterbutton').toggle( false, false ); + } + }, + items:[{ + layout: 'table', + border: false, + defaults: { + // applied to each contained panel + bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;' + }, + layoutConfig: { + // The total column count must be specified here + columns: 4 + }, + items: [{ + border: false, + html: 'Master IP Address:' + },{ + xtype: 'textfield', + id: 'setting_master_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_master_port', + width: '30%' + },{ + border: false, + html: 'Slave IP Address:' + },{ + xtype: 'textfield', + id: 'setting_slave_ip', + width: '70%' + },{ + border: false, + html: 'Port:' + },{ + xtype: 'textfield', + id: 'setting_slave_port', + width: '30%' + },{ + border: false, + html: 'Position Lat/Lon/Alt:' + },{ + xtype: 'textfield', + id: 'setting_lat', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_lon', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_alt', + width: '30%' + },{ + border: false, + html: 'Orientation Roll/Pitch/Yaw:' + },{ + xtype: 'textfield', + id: 'setting_roll', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_pitch', + width: '30%' + },{ + xtype: 'textfield', + id: 'setting_yaw', + width: '30%' + }] + }], + bbar: [{ + text: 'GetLabel("_CANCEL_");?>', + handler: function(){ + SettingsLidar3D.hide(); + } + },{ + text: 'GetLabel("_SAVE_");?>', + handler: SaveSettingsLidar3D + }] + }); + }; + SettingsLidar3D.show(); + loadSettingsLidar3D( NodeID, Master ); +}; + var devicesStore = new Ext.data.JsonStore({ root: 'nodes', totalProperty: 'totalCount', @@ -40,17 +278,37 @@ var LRF2D2_st_win = null; var LRF16D3_st_win = null; -function doDeviceOperation( NodeID, OpCode ){ +function doDeviceOperation( NodeID, OpCode, Param='' ){ Ext.Ajax.request({ url: '/lib/controller/doDeviceOperation.php', params: { NID: NodeID, UID: 'Data['id'];?>', CMD: OpCode, - SID: '' + SID: '', + PARAM: Param }, success: function( response, opts ){ - + var data = Ext.decode(response.responseText); + if( !data.success ){ + Ext.Msg.show({ + title:'Node Command Status', + msg: data.msg, + buttons: Ext.Msg.OK, + //fn: processResult, + //animEl: 'upddiBTN', + icon: Ext.MessageBox.ERROR + }); + } else { + Ext.Msg.show({ + title:'Node Command Status', + msg: data.query, + buttons: Ext.Msg.OK, + //fn: processResult, + //animEl: 'upddiBTN', + icon: Ext.MessageBox.INFO + }); + }; }, failure: failureAJAXFunction }); @@ -515,6 +773,25 @@ function resolveDeviceMistmatch( NodeID ){ }, html: '
GetLabel('_DEV_MISTMATT1_');?>
', height: 30 + },{ + xtype: 'button', + width: '100%', + text: 'It is Newly Connected Device', + handler: function(){ + Ext.Ajax.request({ + url: '/lib/controller/validateNode.php', + params: { + NID: currentResolveDeviceNode, + UID: 'Data['id'];?>', + SID: '', + MET: 1 + }, + success: function( response, opts ){ + ResolveDeviceNodeWin.hide(); + }, + failure: failureAJAXFunction + }); + } },{ xtype: 'button', width: '100%', @@ -847,6 +1124,381 @@ function startAdvancedDeviceDetection( NodeID ){ loadAdvancedDeviceDetectionSettings(); }; +var maskEditorDiv = null; +var MEPanel = null; +function handleFSMaskEditorClose( event ){ + if ( document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement ){ + } else { + MEPanel.destroy(); + maskEditorDiv.remove(); + maskEditorDiv = null; + MEPanel = null; + document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function hideMaskEditor(){ + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + if( document.exitFullscreen ){ + document.exitFullscreen(); + }else if( document.mozCancelFullScreen ){ + document.mozCancelFullScreen(); + }else if( document.webkitExitFullscreen ){ + document.webkitExitFullscreen(); + }else if( document.msExitFullscreen ){ + document.msExitFullscreen(); + }; + // Removal Done by event! + //maskEditorDiv.remove(); + //maskEditorDiv = null; + //document.removeEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; +var values = { + paths: 50, + minPoints: 5, + maxPoints: 15, + minRadius: 30, + maxRadius: 90 +}; + +var hitOptions = { + segments: true, + stroke: true, + fill: true, + tolerance: 10 +}; + +var polycolors = new Array(); +var polyindex = 0; +var poligones = new Array(); + +var segment = null; +var path = null; +var MaskProject = null; +var MaskEditorMode = 0; + +function onMouseDown(event) { + segment = path = null; + var hitResult = MaskProject.hitTest( event.point, hitOptions ); + if (!hitResult) return; + + if( event.modifiers.shift ){ + if (hitResult.type == 'segment') { + hitResult.segment.remove(); + }; + return; + }; + if( hitResult ){ + path = hitResult.item; + if( hitResult.type == 'segment' ){ + segment = hitResult.segment; + path.fullySelected = false; + segment.selected = true; + } else if( hitResult.type == 'stroke' ){ + var location = hitResult.location; + segment = path.insert(location.index + 1, event.point); + //path.smooth(); + path.fullySelected = false; + segment.selected = true; + } else if ( hitResult.type == 'fill' ){ + path.fullySelected = true; + }; + } + //movePath = ; + //if( movePath ) MaskProject.activeLayer.addChild(hitResult.item); +} + +function onMouseMove(event) { + MaskProject.activeLayer.selected = false; + if( event.item ) { + //event.item.selected = true; + event.item.fullySelected = true; + }; +} +function onMouseDrag(event) { + if( segment ){ + //segment.point += event.delta; + segment.point = event.point; + //path.smooth(); + }; + //else if (path) { + // path.position += event.delta; + //} +} +var absDrawMapSizes = [[0,0],[2304,288]]; +var deviceMapScaling = 1.0; +var deviceMapTopShift = 100; +var deviceMapLeftShift = 100; +var cMapImageWidth = 0; +var cMapImageHeight = 0; +var cMapCanvasWidth = 0; +var cMapCanvasHeight = 0; +function showMaskEditor( fromDevTool, DevType, NodeID ){ + //alert( "DevType: "+DevType + " Dev Map size: "+ absDrawMapSizes[DevType][0]+"x"+absDrawMapSizes[DevType][1] ); + deviceMapScaling = ( window.screen.height * window.devicePixelRatio - 130 - ( deviceMapTopShift * 2 )) / absDrawMapSizes[DevType][1]; + cMapImageHeight = deviceMapScaling * absDrawMapSizes[DevType][1]; + cMapImageWidth = deviceMapScaling * absDrawMapSizes[DevType][0]; + cMapCanvasWidth = cMapImageWidth + (deviceMapLeftShift * 2); + cMapCanvasHeight = cMapImageHeight + (deviceMapTopShift * 2); + if( fromDevTool ){ + detectionProfileWindow.hide(); + }; + if( + document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement + ){ + //fs mode allready + hideMaskEditor(); + }else{ + if( maskEditorDiv == null ){ + maskEditorDiv = document.createElement("div"); + maskEditorDiv.style.height="200px"; + maskEditorDiv.style.width="200px"; + //maskEditorDiv.style.backgroundImage = "url('your_image.png')"; + //append div as a child to body + document.body.appendChild( maskEditorDiv ); + //var elem = document.createElement("img"); 'getDeviceMap.php?NID='+NodeID + //elem.setAttribute("src", "/lib/controller/data/device_draws/75c85fec4be204fc0bc0452f53b5a3df_map.png"); + //elem.setAttribute("height", "80%"); + //elem.setAttribute("width", "130"); + //maskEditorDiv.appendChild( elem ); + //alert( window.screen.width * window.devicePixelRatio + "x" + window.screen.height * window.devicePixelRatio); + if( MEPanel == null ){ + var ww = window.screen.width * window.devicePixelRatio; + var hh = window.screen.height * window.devicePixelRatio; + MEPanel = new Ext.Panel( { + title: 'Mask Editor', + renderTo: maskEditorDiv, + width: ww, + height: hh, + frame: true, + autoScroll: true, + items:[{ + xtype: 'panel', + width: cMapCanvasWidth, + html: '
' + }], + tbar:[{ + text:'New Polygone', + id: 'me_b_newp', + enableToggle: true, + toggleGroup: 'me_topbar_grp', + handler: function( btn ){ + if( btn.pressed ) setMaskEditorMode( 0 ); + } + },{ + text:'Delete Polygone', + id: 'me_b_delp', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + },{ + text:'Delete Point', + id: 'me_b_delpo', + enableToggle: true, + toggleGroup: 'me_topbar_grp' + },{ + text:'Clear Mask', + id: 'me_b_delm', + handler: function(){ + if( MaskProject!= null ){ + alert( 'ClearMask' ); + }; + } + }], + buttons:[{ + text: 'Cancel', + handler: function(){ + hideMaskEditor(); + } + },{ + text:'Save Mask and Close', + handler: function(){ + var serial = MaskProject.exportJSON(); + Ext.Ajax.request({ + url: '/lib/controller/uploadDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: 0, + LID: 0, + MDTA: serial, + MIH: cMapImageHeight, + //MSF: deviceMapScaling, + MSHX: deviceMapLeftShift, + MSHY: deviceMapTopShift + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + hideMaskEditor(); + }, + failure: failureAJAXFunction + }); + } + }] + }); + }; + MEPanel.doLayout(); + loadDeviceMask( NodeID ); + }; + //maskEditorDiv = $('#container').get(0); + //var maskEditorDiv = document.getElementById( id ); //Ext.getCmp( id ); + if( maskEditorDiv.requestFullscreen ){ + maskEditorDiv.requestFullscreen(); + }else if( maskEditorDiv.mozRequestFullScreen ){ + maskEditorDiv.mozRequestFullScreen(); + }else if( maskEditorDiv.webkitRequestFullscreen ){ + maskEditorDiv.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + }else if( maskEditorDiv.msRequestFullscreen ){ + maskEditorDiv.msRequestFullscreen(); + }; + document.addEventListener( 'fullscreenchange', handleFSMaskEditorClose ); + }; +}; + +function setMaskEditorMode( nM ){ + switch( nM ){ + case 0:{ + var MEP = Ext.getCmp('me_b_newp'); + if( !MEP.pressed ) MEP.toggle( true ); + var caca = document.getElementById('mask_canvas'); + caca.style.cursor = 'crosshair'; + break; + }; + case 1:{ + var MEP = Ext.getCmp('me_b_newp'); + if( !MEP.pressed ) MEP.toggle( false ); + MEP = Ext.getCmp('me_b_delp'); + if( !MEP.pressed ) MEP.toggle( false ); + MEP = Ext.getCmp('me_b_delpo'); + if( !MEP.pressed ) MEP.toggle( false ); + if( MaskProject!= null ){ + if( MaskProject.isEmpty() ){ + MEP = Ext.getCmp('me_b_delp'); + MEP.disable(); + MEP = Ext.getCmp('me_b_delpo'); + MEP.disable(); + MEP = Ext.getCmp('me_b_delm'); + MEP.disable(); + setMaskEditorMode( 0 ); + } else { + MEP = Ext.getCmp('me_b_delp'); + MEP.enable(); + MEP = Ext.getCmp('me_b_delpo'); + MEP.enable(); + MEP = Ext.getCmp('me_b_delm'); + MEP.enable(); + }; + }; + var caca = document.getElementById('mask_canvas'); + caca.style.cursor = 'default'; + break; + }; + case 2:{ + var MEP = Ext.getCmp('me_b_delp'); + if( !MEP.pressed ) MEP.toggle( true ); + break; + }; + case 3:{ + var MEP = Ext.getCmp('me_b_delpo'); + if( !MEP.pressed ) MEP.toggle( true ); + break; + }; + }; + MaskEditorMode = nM; +}; + +function loadDeviceMask( NodeID, LrfID = 0, LayerID = 0 ){ + Ext.Ajax.request({ + url: '/lib/controller/getDeviceMask.php', + params: { + NID: NodeID, + UID: 'Data['id'];?>', + SID: '', + MID: LayerID, + LID: LrfID + }, + success: function( response, opts ){ + var data = Ext.decode(response.responseText); + var canvas = document.getElementById('mask_canvas');// Create an empty project and a view for the canvas: + //paper.setup( canvas ); + paper.settings.handleSize = 10; + MaskProject = new paper.Project( canvas ); + if( data.length > 0 ){ + for( i = 0; i < data.length; i++ ){ + var path = new paper.Path(); + path.strokeColor = 'black'; + //var lightness = (Math.random() - 0.5) * 0.4 + 0.4; + //var hue = Math.random() * 360; + //path.fillColor = { hue: hue, saturation: 1, lightness: lightness }; + path.fillColor = data[i].colour; + path.closed = true; + path.opacity = 0.5; + //path.onMouseMove = onMouseMove; + path.onMouseDown = onMouseDown; + path.onMouseDrag = onMouseDrag; + //path.onMouseUp = function( event ){ + // path.add(event.point); + //} + if( data[i].points.length > 2 ){ + var tX = data[i].points[0][0] * deviceMapScaling + deviceMapLeftShift; + var tY = data[i].points[0][1] * deviceMapScaling + deviceMapTopShift; + path.moveTo( [tX,tY] ); + for(k = 1; k < data[i].points.length; k++ ){ + tX = data[i].points[k][0] * deviceMapScaling + deviceMapLeftShift; + tY = data[i].points[k][1] * deviceMapScaling + deviceMapTopShift; + path.lineTo( [tX,tY] ); + }; + path.fullySelected = true; + paper.view.draw(); + }; + poligones.push(path); + }; + }; + setMaskEditorMode( 1 ); // Observer + canvas.addEventListener( 'mousemove', onMaskMouseMove ); + canvas.addEventListener( 'mousedown', onMaskMouseDown ); + canvas.addEventListener( 'mouseup', onMaskMouseUp ); + canvas.addEventListener( 'mousedrag', onMaskMouseMove ); + }, + failure: failureAJAXFunction + }); +}; + +function onMaskMouseDown( evt ){ + if( MaskEditorMode == 0 ){ + path = new paper.Path(); + path.strokeColor = 'black'; + path.closed = true; + path.opacity = 0.5; + path.moveTo( [ evt.clientX, evt.clientY ] ); + setMaskEditorMode( 4 ); + }; +}; + +function onMaskMouseUp( evt ){ + if( MaskEditorMode == 4 ){ + path.lineTo( [ evt.clientX, evt.clientY ] ); + setMaskEditorMode( 1 ); + }; +}; + +function onMaskMouseMove( event ){ + if( MaskEditorMode == 4 ){ + paper.view.draw(); + }; +}; diff --git a/lib/javascript/jsapi_dynamic/rgoose_main.js b/lib/javascript/jsapi_dynamic/rgoose_main.js index 62cde60..8d130ad 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_main.js +++ b/lib/javascript/jsapi_dynamic/rgoose_main.js @@ -3,12 +3,17 @@ var winW = Data['width']);?>; var winH = Data['height']);?>; +var initView = Data['last_content_view']);?>; var PanelH = winH-90; var SelectedSite = ; var SettingsLidar3D = null; var SelectedNodeID = 0; -var ServerPID = -1; +var StatusTS = -1; +var LoadTS = ; var SoundEnable = Data['sound_enable']);?>; +var nodeDashboardStatuses = new Array(); +var nodeTHREEviewers = new Array(); +var nodeTHREEanimationId = 0; var sndBeep = new Howl({ src: [ @@ -75,7 +80,6 @@ function updateUserScreenResolution( x, y ){ Ext.Ajax.request({ url: '/lib/controller/updateUserSettings.php', params: { - SAID: SelectedSite, UID: , SID: '', SSS: 15, @@ -86,22 +90,45 @@ function updateUserScreenResolution( x, y ){ doRefresh(); }, failure: failureAJAXFunction - }); + }); }; -function removeAllFromSite(){ +function setUserContent( c_id ){ Ext.Ajax.request({ - url: '/lib/controller/resetAllSettings.php', + url: '/lib/controller/updateUserSettings.php', params: { - SAID: SelectedSite, UID: , - SID: '' - }, - success: function( response, opts ){ - doRefresh(); + SID: '', + SSS: 26, + CID: c_id }, failure: failureAJAXFunction - }); + }); +}; + +function removeAllFromSite(){ + Ext.Msg.show({ + title:'GetLabel('_CLEAR_SITE_');?>', + msg: 'GetLabel('_SITE_DEL_ALL_ABO_');?>', + buttons: Ext.Msg.YESNO, + icon: Ext.MessageBox.WARNING, + fn: function(btn, text){ + if (btn == 'yes'){ + Ext.Ajax.request({ + url: '/lib/controller/resetAllSettings.php', + params: { + SAID: SelectedSite, + UID: , + SID: '' + }, + success: function( response, opts ){ + doRefresh(); + }, + failure: failureAJAXFunction + }); + }; + } + }); }; function doCheckWindowSize(){ @@ -160,7 +187,8 @@ Ext.onReady(function(){ margins: '5 0 5 5', cmargins:'5 5 5 5', layoutConfig:{ - animate:true + animate: true//, + //activeOnTop: true }, items: [{ title: 'GetLabel('_DASHBOARD_');?>', @@ -168,11 +196,13 @@ Ext.onReady(function(){ height: 120, pack: 'center', align : 'strech', + collapsed: Data['last_content_view']<2)?'false':'true';?>, items:[{ xtype: 'button', width: '100%', id:'go_home', text: 'GetLabel('_GO_HOME_');?>', + toggled: (initView == 0 ), handler: function( b, e ){ loadDashBoard(); } @@ -197,6 +227,7 @@ Ext.onReady(function(){ height: 120, pack: 'center', align : 'strech', + collapsed: Data['last_content_view']>1)?'false':'true';?>, items:[{ xtype: 'button', width: '100%', diff --git a/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js b/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js index dc95383..0787c8d 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js +++ b/lib/javascript/jsapi_dynamic/rgoose_sysmap_editor.js @@ -3,7 +3,6 @@ var resourceInfoWindow = null; - function showResourceInfo( rid ){ Ext.Ajax.request({ url: '/lib/controller/getResourceInfo.php', @@ -13,7 +12,6 @@ function showResourceInfo( rid ){ SID: '', }, success: function( response, opts ){ - // If the response is JSON, you have to decode it var data = Ext.decode(response.responseText); if( resourceInfoWindow == null ){ resourceInfoWindow = new Ext.Window({ @@ -25,7 +23,10 @@ function showResourceInfo( rid ){ closeAction: 'hide', items: [], buttons:[{ - text: `close` + text: `close`, + handler: function(){ + resourceInfoWindow.hide(); + } }] }); }; @@ -37,231 +38,317 @@ function showResourceInfo( rid ){ }); }; -function loadSettingsLidar3D( NodeID, Master ){ - SelectedNodeID = NodeID; +var settingsWindow = null; +function showSettings( nid ){ Ext.Ajax.request({ - url: '/lib/controller/getSettingsLidsr3D.php', + url: '/lib/controller/getNodeSettings.php', params: { - NID: NodeID, - MST: ((Master)?1:0), + NID: nid, UID: , SID: '', }, success: function( response, opts ){ - // If the response is JSON, you have to decode it - var data = Ext.decode(response.responseText); - Ext.getCmp('setting_master_ip').setValue( data.ip_address ); - Ext.getCmp('setting_master_port').setValue( data.port ); - Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address ); - Ext.getCmp('setting_slave_port').setValue( data.aux_port ); - Ext.getCmp('setting_lat').setValue( data.lat ); - Ext.getCmp('setting_lon').setValue( data.lon ); - Ext.getCmp('setting_alt').setValue( data.alt ); - Ext.getCmp('setting_roll').setValue( data.roll ); - Ext.getCmp('setting_pitch').setValue( data.pitch ); - Ext.getCmp('setting_yaw').setValue( data.yaw ); + var data = Ext.decode( response.responseText ); + if( settingsWindow == null ){ + settingsWindow = new Ext.Window({ + title: 'Settings', + modal: true, + width: 800, + height: 400, + layout: 'fit', + closeAction: 'hide', + items: [], + buttons:[{ + text: `close`, + handler: function(){ + settingsWindow.hide(); + } + }] + }); + }; + settingsWindow.removeAll( true ); + settingsWindow.add( data ); + settingsWindow.show(); }, failure: failureAJAXFunction }); }; -function SaveSettingsLidar3D( ){ - if( SelectedNodeID == 0 ) return; - t1 = Ext.getCmp('setting_master_ip').getValue(); - t2 = Ext.getCmp('setting_master_port').getValue(); - t3 = Ext.getCmp('setting_slave_ip').getValue(); - t4 = Ext.getCmp('setting_slave_port').getValue(); - t5 = Ext.getCmp('setting_lat').getValue(); - t6 = Ext.getCmp('setting_lon').getValue(); - t7 = Ext.getCmp('setting_alt').getValue(); - t8 = Ext.getCmp('setting_roll').getValue(); - t9 = Ext.getCmp('setting_pitch').getValue(); - t10 = Ext.getCmp('setting_yaw').getValue(); - Ext.Ajax.request({ - url: '/lib/controller/setSettingsLidsr3D.php', +function reloadNetworkData(){ + Ext.Ajax.request({ + url: '/lib/controller/getNetwork.php', params: { - NID: SelectedNodeID, + NID: SelectedSite, UID: , SID: '', - MIP: t1, - MPP: t2, - SIP: t3, - SPP: t4, - LAT: t5, - LON: t6, - ALT: t7, - ROL: t8, - PCH: t9, - YAW: t10 }, success: function( response, opts ){ - // If the response is JSON, you have to decode it var data = Ext.decode(response.responseText); - if( data.success == true ) { - Ext.Msg.show({ - title:'Info Message', - msg: 'Settings are sucessfully saved.', - buttons: Ext.Msg.OK,//YESNOCANCEL, - fn: function(){ - SettingsLidar3D.hide(); - }, - //animEl: 'elId', - icon: Ext.MessageBox.INFO //QUESTION - }); - } else { - Ext.Msg.show({ - title:'Error Message', - msg: data['error'], - buttons: Ext.Msg.OK,//YESNOCANCEL, - fn: function(){ - SettingsLidar3D.hide(); - }, - //animEl: 'elId', - icon: Ext.MessageBox.ERROR //QUESTION - }); - }; + netwodkData.nodes = new vis.DataSet( data.nodes ); + netwodkData.edges = new vis.DataSet( data.edges ); + networkObj.setData( netwodkData ); + networkObj.redraw(); }, failure: failureAJAXFunction }); }; +function createNode( STYPE ){ + Ext.Ajax.request({ + url: '/lib/controller/addNetworkNode.php', + params: { + NID: , + UID: , + SID: '', + TYPE: STYPE + }, + success: function( response, opts ){ + reloadNetworkData( ); + }, + failure: failureAJAXFunction + }); +}; -function editSettingsLidar3D( NodeID, Master ){ - if( SettingsLidar3D == null ){ - SettingsLidar3D = new Ext.Window({ +var addPLS200_window = null; +function addSensor_PLS200(){ + if( addPLS200_window == null ){ + addPLS200_window = new Ext.Window({ modal: true, - title: 'GetLabel("_EDIT_LRF3D_SETTINGS_");?>', - width: 773, - height: 600, + title: 'GetLabel("_DLG_ADD_PLS200_");?>', + width: 400, + height: 400, layout: 'fit', closeAction: 'hide', - listeners:{ - beforehide : function(){ - Ext.getCmp('connectstarterbutton').toggle( false, false ); - } - }, items:[{ - layout: 'table', + xtype: 'form', + frame: false, border: false, - defaults: { - // applied to each contained panel - bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;' - }, - layoutConfig: { - // The total column count must be specified here - columns: 4 - }, - items: [{ + hideLabels: false, + labelAlign: 'right', // or 'right' or 'top' + //labelSeparator: '>>', // takes precedence over layoutConfig value + labelWidth: 160, // defaults to 100 + labelPad: 8, // defaults to 5, must specify labelWidth to be honored + items:[{ + xtype:'panel', + frame: false, border: false, - html: 'Master IP Address:' - },{ - xtype: 'textfield', - id: 'setting_master_ip', - width: '70%' + html: '
', + height: '200px' },{ + html: ' ', + frame: false, border: false, - html: 'Port:' },{ + fieldLabel: 'GetLabel('_DEVICE_NAME_');?>', xtype: 'textfield', - id: 'setting_master_port', - width: '30%' + width: 200, + id: 'p200_dev_name', + allowBlank: false },{ - border: false, - html: 'Slave IP Address:' + xtype: 'combo', + fieldLabel: 'GetLabel('_SENSOR_MAX_RANGE_');?>', + lazyRender: true, + id: 'p200_range', + width: 200, + mode: 'local', + disabled: false, + forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true, + store: new Ext.data.ArrayStore({ + fields: ['range','range_txt'], + data: [[35,'35'],[60,'60']] + }), + valueField: 'range', + displayField: 'range_txt' },{ - xtype: 'textfield', - id: 'setting_slave_ip', - width: '70%' + xtype: 'combo', + fieldLabel: 'GetLabel('_UART_PORT_');?>', + lazyRender: true, + id: 'p200_uart_id', + width: 200, + disabled: false, + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: UartListStore, + valueField: 'uart_id', + displayField: 'uart_name' },{ - border: false, - html: 'Port:' + fieldLabel: 'GetLabel('_PROTO_DEVICE_ID_');?>', + xtype: 'numberfield', + id: 'p200_dev_id', + width: 200, + allowBlank: false, + allowNegative: false, + minValue: 0, + maxValue: 255 + }], + bbar:[ '->',{ + text: 'GetLabel('_CANCEL_');?>', + handler: function(){ + addPLS200_window.hide(); + } },{ - xtype: 'textfield', - id: 'setting_slave_port', - width: '30%' + text: 'GetLabel('_ADD_');?>', + handler: function(){ + var uart_id_val = Ext.getCmp('p200_uart_id').getValue(); + var dev_id_val = Ext.getCmp('p200_dev_id').getValue(); + var sname = Ext.getCmp('p200_dev_name').getValue(); + var range = parseInt( Ext.getCmp('p200_range').getValue()); + if( sname != '' && uart_id_val != '' && range > 0 ){ + var uart_id = parseInt( uart_id_val ); + var dev_id = parseInt( dev_id_val ); + Ext.Ajax.request({ + url: '/lib/controller/addNetworkNode.php', + params: { + SITEID: , + UID: , + SID: '', + TYPE: 3, + SNAME: sname, + RANGE: range, + UART: uart_id, + DEVID: dev_id + }, + success: function( response, opts ){ + addPLS200_window.hide(); + // If the response is JSON, you have to decode it + reloadNetworkData( ); + }, + failure: failureAJAXFunction + }); + } else { + playSound(); + Ext.Msg.show({ + title:'GetLabel('_WRO_VALUES_');?>', + msg: 'GetLabel('_WRO_VAL_MSG_');?>', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + }; + } + }] + }] + }); + }; + addPLS200_window.show(); +}; + +var add3D_window = null; +function addSensor_3D(){ + if( add3D_window == null ){ + add3D_window = new Ext.Window({ + modal: true, + title: 'GetLabel("_DLG_ADD_3DSENS_");?>', + width: 400, + height: 400, + layout: 'fit', + closeAction: 'hide', + items:[{ + xtype: 'form', + frame: false, + border: false, + hideLabels: false, + labelAlign: 'right', // or 'right' or 'top' + //labelSeparator: '>>', // takes precedence over layoutConfig value + labelWidth: 160, // defaults to 100 + labelPad: 8, // defaults to 5, must specify labelWidth to be honored + items:[{ + xtype:'panel', + frame: false, + border: false, + html: '
', + height: '200px' },{ + html: ' ', + frame: false, border: false, - html: 'Position Lat/Lon/Alt:' },{ + fieldLabel: 'GetLabel('_DEVICE_NAME_');?>', xtype: 'textfield', - id: 'setting_lat', - width: '30%' + width: 200, + id: 's3d_dev_name', + allowBlank: false },{ - xtype: 'textfield', - id: 'setting_lon', - width: '30%' + xtype: 'combo', + fieldLabel: 'GetLabel('_SEVER_NODE_');?>', + lazyRender: true, + id: 's3d_server', + width: 200, + disabled: false, + forceSelection: true, + triggerAction: 'all', + editable: false, + disableKeyFilter: true, + store: ServerListStore, + valueField: 'server_id', + displayField: 'server_name' },{ + fieldLabel: 'GetLabel('_DEVICE_IP_');?>', xtype: 'textfield', - id: 'setting_alt', - width: '30%' + id: 's3d_dev_addr', + width: 200, + allowBlank: false },{ - border: false, - html: 'Orientation Roll/Pitch/Yaw:' - },{ - xtype: 'textfield', - id: 'setting_roll', - width: '30%' - },{ - xtype: 'textfield', - id: 'setting_pitch', - width: '30%' + fieldLabel: 'GetLabel('_DEVICE_PORT_');?>', + xtype: 'numberfield', + id: 's3d_dev_port', + width: 200, + allowBlank: false, + allowNegative: false, + value: 2222, + minValue: 1000, + maxValue: 65535 + }], + bbar:[ '->',{ + text: 'GetLabel('_CANCEL_');?>', + handler: function(){ + add3D_window.hide(); + } },{ - xtype: 'textfield', - id: 'setting_yaw', - width: '30%' + text: 'GetLabel('_ADD_');?>', + handler: function(){ + var dev_addr = Ext.getCmp('s3d_dev_addr').getValue(); + var dev_port = parseInt( Ext.getCmp('s3d_dev_port').getValue() ); + var dev_server = parseInt( Ext.getCmp('s3d_server').getValue() ); + var dev_name = Ext.getCmp('s3d_dev_name').getValue(); + if( dev_name != '' && dev_addr != '' && dev_port > 0 && dev_server > 0 ){ + Ext.Ajax.request({ + url: '/lib/controller/addNetworkNode.php', + params: { + SITEID: , + UID: , + SID: '', + TYPE: 5, + SNAME: dev_name, + PORT: dev_port, + ADDR: dev_addr, + SERVER: dev_server + }, + success: function( response, opts ){ + add3D_window.hide(); + // If the response is JSON, you have to decode it + reloadNetworkData( ); + }, + failure: failureAJAXFunction + }); + } else { + playSound(); + Ext.Msg.show({ + title:'GetLabel('_WRO_VALUES_');?>', + msg: 'GetLabel('_WRO_VAL_MSG_');?>', + buttons: Ext.Msg.OK, + icon: Ext.MessageBox.INFO + }); + }; + } }] - }], - bbar: [{ - text: 'GetLabel("_CANCEL_");?>', - handler: function(){ - SettingsLidar3D.hide(); - } - },{ - text: 'GetLabel("_SAVE_");?>', - handler: SaveSettingsLidar3D }] }); }; - SettingsLidar3D.show(); - loadSettingsLidar3D( NodeID, Master ); -}; - -function reloadNetworkData(){ - Ext.Ajax.request({ - url: '/lib/controller/getNetwork.php', - params: { - NID: SelectedSite,//, - UID: , - SID: '', - }, - success: function( response, opts ){ - // If the response is JSON, you have to decode it - var data = Ext.decode(response.responseText); - netwodkData.nodes = new vis.DataSet( data.nodes ); - netwodkData.edges = new vis.DataSet( data.edges ); - networkObj.setData( netwodkData ); - networkObj.redraw(); - }, - failure: failureAJAXFunction - }); -}; - -function createNode( STYPE ){ - Ext.Ajax.request({ - url: '/lib/controller/addNetworkNode.php', - params: { - NID: , - UID: , - SID: '', - TYPE: STYPE - }, - success: function( response, opts ){ - // If the response is JSON, you have to decode it - reloadNetworkData( ); - }, - failure: failureAJAXFunction - }); + add3D_window.show(); }; + function loadNodeSockets( NID, store ){ Ext.Ajax.request({ @@ -372,7 +459,6 @@ function createConnection( SID, EID, CTY ){ }; function loadNodeProperties( NodeID ){ - //alert( 'Node: ' + NodeID ); SelectedNodeID = NodeID; Ext.Ajax.request({ url: '/lib/controller/getNetworkNodeProps.php', @@ -382,27 +468,6 @@ function loadNodeProperties( NodeID ){ SID: '', NODE: NodeID }, - success: function( response, opts ){ - // If the response is JSON, you have to decode it - var data = Ext.decode(response.responseText); - var tPanel = Ext.getCmp('prop_content'); - tPanel.remove(0); - tPanel.add( data ); - tPanel.doLayout(); - }, - failure: failureAJAXFunction - }); -}; - -function loadServerProperties( NodeID ){ - Ext.Ajax.request({ - url: '/lib/controller/getNetworkServerProps.php', - params: { - NID: , - UID: , - SID: '', - NODE: NodeID - }, success: function( response, opts ){ var data = Ext.decode(response.responseText); var tPanel = Ext.getCmp('prop_content'); @@ -446,7 +511,7 @@ function module_prop_FlyHunter( module_id ){ id: 0, fields: ['myId', 'displayText' ], data: [ Query( $QS ); if( count( $RR ) ){ $RE=array(); @@ -524,6 +589,7 @@ function loadSystemEditor(){ tlInterval = null; timelineObj = null; }; + setUserContent( 2 ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll( true ); Ext.getCmp('main_content').setTitle( 'GetLabel('_SYS_MAP_');?>' ); @@ -531,30 +597,30 @@ function loadSystemEditor(){ columnWidth: 0.83, frame: false, border: false, - items: [{ - xtype: 'panel', + items: [{ + xtype: 'panel', layout: 'fit', - layoutConfig: { - align : 'stretch', - pack : 'start' - //padding:'5', - //align:'middle' - }, - height: PanelH-5, - flex: 1, - frame: false, - border: false, - items:{ - id: 'sys_map' - }, - tbar: [{ + layoutConfig: { + align : 'stretch', + pack : 'start' + //padding:'5', + //align:'middle' + }, + height: PanelH-5, + flex: 1, + frame: false, + border: false, + items:{ + id: 'sys_map' + }, + tbar: [{ xtype: 'splitbutton', text: 'GetLabel('_SMM_ADD_LSEN_');?>', split: true, enableToggle : undefined, menu : { items: [{ - text:'ALS', + text:'ALS', icon: '/style/assets/!cid_ii_jvmzuzrq10.png', handler: function(){ createNode( 1 ); @@ -569,19 +635,20 @@ function loadSystemEditor(){ text:'PLS-200', icon: '/style/assets/!cid_ii_jvmzuzql4.png', handler: function(){ - createNode( 3 ); + //createNode( 3 ); + addSensor_PLS200(); } },{ text:'PLS-360', icon: '/style/assets/!cid_ii_jvmzuzr87.png', handler: function(){ - createNode( 4 ); + //createNode( 4 ); } },{ text:'3DLIDAR', icon: '/style/assets/unnamed34.png', handler: function(){ - createNode( 5 ); + addSensor_3D(); } }] } @@ -592,16 +659,24 @@ function loadSystemEditor(){ enableToggle : true, menu : { items: [{ + text:'Argus Event Server', + icon: '/style/assets/0_node.png', + handler: function(){ + addServer(); + } + },{ text:'Static Analog Camera', icon: '/style/assets/11_node.png', handler: function(){ SelectedCamTYPE = 10; + addAnalogCam(); } },{ text:'PTZ Analog Camera', icon: '/style/assets/12_node.png', handler: function(){ SelectedCamTYPE = 11; + addAnalogCam(); } },{ text:'Static IP Camera', @@ -671,21 +746,22 @@ function loadSystemEditor(){ }] }); tPanel.add({ - title: 'GetLabel('_PROPERTIES_');?>', - xtype: 'panel', - flex: 1, - height: 700, - //width: 210, - columnWidth: 0.17, - layout: 'fit', - //frame: true, - id: 'prop_content', - // border: true - items:{ - html: 'Select Item From Map' - } + title: 'GetLabel('_PROPERTIES_');?>', + xtype: 'panel', + flex: 1, + height: PanelH-5, + //width: 210, + columnWidth: 0.17, + layout: 'fit', + frame: false, + id: 'prop_content', + border: false, + items:{ + html: 'GetLabel('_MSG_SELITEMFROMMAP_');?>' + } }); tPanel.doLayout(); + Ext.Ajax.request({ url: '/lib/controller/getNetwork.php', params: { @@ -704,11 +780,7 @@ function loadSystemEditor(){ //if(!connectionAddMode){ if( !InComponentRemoveMode ){ if( params.nodes.length > 0 ){ - if( netwodkData.nodes.get(params.nodes[0]).role == 'server' ){ - loadServerProperties( params.nodes[0] ); - } else { - loadNodeProperties( params.nodes[0] ); - }; + loadNodeProperties( params.nodes[0] ); } else if( params.edges.length > 0 ){ selectedConnection = netwodkData.edges.get(params.edges[0]); loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to ); diff --git a/lib/javascript/jsapi_dynamic/rgoose_timeline.js b/lib/javascript/jsapi_dynamic/rgoose_timeline.js index 454e7b4..01c3280 100644 --- a/lib/javascript/jsapi_dynamic/rgoose_timeline.js +++ b/lib/javascript/jsapi_dynamic/rgoose_timeline.js @@ -70,8 +70,29 @@ var eventsListStore = new Ext.data.JsonStore({ }); var SelectedEvent = 0; - - +var EventPanelWindow = null; +function showEventPanel(){ + if( EventPanelWindow == null ){ + EventPanelWindow = new Ext.Window({ + modal: true, + title: 'GetLabel("_EVENT_VIEWER_");?>', + width: winW*0.66, + height: winH*0.66, + layout: 'fit', + closeAction: 'hide', + items:[{ + title: 'Cameras', + html:'koko', + autoScroll: true, + height: 320 + },{ + html: 'koko22', + height: 320 + }] + }); + }; + EventPanelWindow .show(); +}; function ModeRenderer(val){ var p1, p2, p3; @@ -352,6 +373,7 @@ function loadTimeLine(){ tlInterval = null; timelineObj = null; }; + setUserContent( 1 ); var tPanel = Ext.getCmp('main_portal'); tPanel.removeAll( true ); Ext.getCmp('main_content').setTitle( 'Full Events Log' ); @@ -385,7 +407,7 @@ function loadTimeLine(){ text: 'Fit Events', disabled: tlMonitoring, handler: function(){ - timelineObj.fit(); + showEventPanel(); } },{ id: 'gtn', @@ -558,6 +580,7 @@ function loadOnlineMonitoring(devID){ tlInterval = null; timelineObj = null; }; + tPanel.remove(0); tPanel.add({ html: 'Device Monitoring '+devID diff --git a/lib/javascript/paper/docs/assets/css/docs.css b/lib/javascript/paper/docs/assets/css/docs.css new file mode 100644 index 0000000..7cbe28c --- /dev/null +++ b/lib/javascript/paper/docs/assets/css/docs.css @@ -0,0 +1,414 @@ +@charset "UTF-8"; +form, +img, +ul, +ol, +table, +td, +article, +figure, +figcaption { + margin: 0; + padding: 0; + border: 0; } + +a { + outline: none; + border: 0; } + +ul, +ol { + list-style: none outside none; } + +table { + border-spacing: 0; } + +td { + vertical-align: top; } + +html { + -webkit-text-size-adjust: none; } + +/* Content Styles */ +article { + /* Text Content */ } + article, + article a { + color: #333333; } + article a { + border-bottom: 1px solid; } + article a:hover, + article a:hover em { + background: #e5e5e5; } + article em { + font-style: normal; + background: #efefef; } + article p, + article ul, + article ol { + margin: 0 8px 16px 0; } + article p.small, + article ul.small, + article ol.small { + margin-bottom: 8px; } + article figure, + article .CodeMirror, + article .paperscript { + margin-bottom: 16px; } + article ul, + article ol { + padding: 0; + list-style: none outside none; } + article ul ul, + article ul ol, + article ol ul, + article ol ol { + margin-bottom: 0; } + article ul > li { + margin-left: 1em; + position: relative; } + article ul > li:before { + content: '–'; + position: absolute; + left: -1em; } + article ol { + counter-reset: item; } + article ol > li { + margin-left: 1.5em; + position: relative; } + article ol > li:before { + position: absolute; + left: -1.5em; + content: counter(item,upper-latin) ") "; + counter-increment: item; } + +section { + clear: both; + margin: 0 0 16px; + padding: 0; } + +.column { + width: 260px; + float: left; } + .column + .column { + margin-left: 16px; } + +.row { + clear: both; } + +.donation { + padding-bottom: 16px; } + .donation input, + .donation select { + margin-right: 0.35em; } + +.reference h1, +.reference h2, +.reference h3, +.reference h4 { + font-size: 13px; + font-weight: normal; + margin: 0; } +.reference h1, +.reference h2, +.reference h3 { + height: 18px; + border-bottom: 1px solid; + margin-bottom: 16px; } +.reference h2 a { + font-weight: bold; } +.reference h3 { + margin-top: 16px; + border-bottom-style: dotted; } +.reference h4 { + font-weight: bold; } + .reference h4 .description { + font-weight: normal; } + .reference h4 .description:before { + content: ' — '; } + .reference h4 + ul, .reference h4 + pre, .reference h4 + .paperscript { + margin-top: 8px; + margin-bottom: 16px; } +.reference a tt { + line-height: 17px; } +.reference ul, +.reference p { + margin-bottom: 16px; } +.reference hr { + border: none; + border-bottom: 1px dotted; } +.reference .reference-list ul, +.reference .reference-inherited ul { + margin-left: 16px; } +.reference .reference-inherited ul li { + text-indent: -30px; + padding-left: 30px; } +.reference ul.reference-classes { + padding-bottom: 4px; } + .reference ul.reference-classes li { + margin: 0; + text-indent: 0; } + .reference ul.reference-classes ul { + margin: 0 0 10px 10px; } + .reference ul.reference-classes h2, + .reference ul.reference-classes h3, + .reference ul.reference-classes hr { + margin: 10px 0 10px 0; } + .reference ul.reference-classes .first h2 { + margin-top: 0; } + * html .reference ul.reference-classes img { + margin-top: 5px; } +.reference ul.member-list li { + margin-left: 2em; + margin-bottom: 8px; + text-indent: -2em; } + .reference ul.member-list li:before { + display: none; } +.reference .reference-members { + margin-bottom: 16px; } +.reference .member-group-text { + margin-bottom: 16px; } +.reference .member-description { + border: 1px solid #999; + border-top: 0; + margin: 16px 0 16px 0; } +.reference .member-header { + border-top: 1px solid #999; + padding: 10px; + *zoom: 1; } + .reference .member-header .member-link { + float: left; } + .reference .member-header .member-close { + float: right; } + .reference .member-header:before, .reference .member-header:after { + content: " "; + display: table; } + .reference .member-header:after { + clear: both; } +.reference .member-text { + border-top: 1px dashed #999; + padding: 10px 10px 0 10px; + margin-bottom: -6px; } + .reference .member-text ul ul, + .reference .member-text ul ol, + .reference .member-text ol ul, + .reference .member-text ol ol, + .reference .member-text ul p, + .reference .member-text ol p { + margin-bottom: 8px; } +.reference .member-link { + text-indent: -30px; + padding-left: 30px; } + +body, +select, +input, +textarea { + font-family: "Lucida Grande", Geneva, Verdana, Arial, sans-serif; } + +tt, +pre, +.CodeMirror { + font-family: Menlo, Consolas, "Vera Mono", monospace; + font-size: 12px; + line-height: 17px; } + +body { + background: #fff; + margin: 16px; + font-size: 13px; + line-height: 20px; + color: #333333; + max-width: 540px; } + +select, +input, +textarea { + font-size: 11px; + margin: 0; + color: #000; } + +a { + color: #333333; + text-decoration: none; + border-bottom: 1px solid #333333; } + a:hover { + background: #e5e5e5; } + +img { + border: 0; } + +p { + margin: 0 0 16px 0; } + +ul, +ol { + padding: 0; + margin: 0 0 16px 0; + list-style: none; } + +.clear { + clear: both; } + +.hidden { + display: none; } + +.reference-index, +.reference-index a { + color: #009dec; + border-bottom: 0px; } +.reference-index a:hover { + background: #e3f4fc; } +.reference-index h2, +.reference-index h3, +.reference-index hr { + border-color: #009dec; } + +.reference h1 { + font-size: 18px; + font-weight: normal; + line-height: 24px; + border: none; } + .reference h1 .version { + font-size: 10px; + line-height: 16px; + vertical-align: top; + margin-left: 0.35em; } + +.footer { + margin-top: 16px; } + +.CodeMirror pre { + margin: 0; + padding: 0; + background: transparent; } +.paperscript .CodeMirror { + height: 100%; } + +.CodeMirror-scroll { + min-height: 100%; + overflow: auto; } + +.CodeMirror-gutter { + position: absolute; + left: 0; + top: 0; + min-width: 30px; + height: 100%; + background-color: #f4f4f4; + border-right: 1px solid #999; } + +.CodeMirror-gutter-text { + color: #aaa; + text-align: right; + padding: 2px 8px 2px 8px; } + .CodeMirror-gutter-text pre { + font-size: 10px; } + +.CodeMirror-lines { + background: #ffffff; + padding: 2px 0 2px 8px; } + .CodeMirror-lines pre.highlight { + background-color: #edf5fc; } + +.CodeMirror-cursor { + z-index: 10; + position: absolute; + visibility: hidden; + border-left: 1px solid #7c7c7c !important; + height: 17px; } + +.CodeMirror-selected { + background: #ccc !important; + color: HighlightText !important; + padding: 2px 0 2px 0; } + +.CodeMirror-focused .CodeMirror-cursor { + visibility: visible; } +.CodeMirror-focused .CodeMirror-selected { + background: Highlight !important; } + +.CodeMirror-matchingbracket { + background: #e3fc8d !important; } + +.CodeMirror-nonmatchingbracket { + color: #d62a28 !important; } + +/* JavaScript & HTML Modes */ +span.cm-keyword { + color: #ff7800; } +span.cm-atom, span.cm-number { + color: #3b5bb5; } +span.cm-def, span.cm-variable-2, span.cm-variable-3 { + color: #3a4a64; } +span.cm-variable { + color: #000; } +span.cm-property { + color: #000; } +span.cm-operator { + color: #000; } +span.cm-comment { + color: #8c868f; } +span.cm-string { + color: #409b1c; } +span.cm-meta { + color: #555; } +span.cm-error { + color: #f30; } +span.cm-qualifier { + color: #555; } +span.cm-builtin { + color: #30a; } +span.cm-bracket { + color: #cc7; } +span.cm-tag { + font-weight: bold; + color: #3b5bb5; } +span.cm-attribute { + font-style: italic; + color: #3b5bb5; } + +.paperscript { + position: relative; } + .paperscript .buttons { + position: absolute; + right: 0; + z-index: 1; } + .paperscript .button, + .paperscript .explain { + float: right; + display: none; + font-size: 12px; + line-height: 16px; + padding: 2px 6px; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + margin: 8px 8px 0 0; } + .paperscript .button { + background: #eee; } + .paperscript .explain { + background: #e3f4fc; } + .paperscript .explain, .paperscript:hover .button { + display: inline-block; } + .paperscript .button:hover { + background: #ddd; + cursor: pointer; } + .paperscript .tools { + display: inline; } + .paperscript .source { + overflow: auto; + border: 1px solid #999; } + .paperscript .CodeMirror { + margin: 0 !important; } + .paperscript .CodeMirror-gutter-text, + .paperscript .CodeMirror-lines { + padding-top: 8px; + padding-bottom: 8px; } + .paperscript .canvas { + line-height: 0; } + .paperscript .canvas.border canvas { + border: 1px solid #999; } + .paperscript.split .canvas { + border: 1px solid #999; + border-top: 0; } diff --git a/lib/javascript/paper/docs/assets/js/codemirror.js b/lib/javascript/paper/docs/assets/js/codemirror.js new file mode 100644 index 0000000..18d2dda --- /dev/null +++ b/lib/javascript/paper/docs/assets/js/codemirror.js @@ -0,0 +1,4 @@ +window.CodeMirror=function(){"use strict";function CodeMirror(place,givenOptions){var options={},defaults=CodeMirror.defaults;for(var opt in defaults)if(defaults.hasOwnProperty(opt))options[opt]=(givenOptions&&givenOptions.hasOwnProperty(opt)?givenOptions:defaults)[opt];var input=elt("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em");input.setAttribute("wrap","off");input.setAttribute("autocorrect","off");input.setAttribute("autocapitalize","off");var inputDiv=elt("div",[input],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");var scrollbarInner=elt("div",null,"CodeMirror-scrollbar-inner");var scrollbar=elt("div",[scrollbarInner],"CodeMirror-scrollbar");var lineDiv=elt("div"),selectionDiv=elt("div",null,null,"position: relative; z-index: -1");var cursor=elt("pre"," ","CodeMirror-cursor"),widthForcer=elt("pre"," ","CodeMirror-cursor","visibility: hidden");var measure=elt("div",null,null,"position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden;");var lineSpace=elt("div",[measure,cursor,widthForcer,selectionDiv,lineDiv],null,"position: relative; z-index: 0");var gutterText=elt("div",null,"CodeMirror-gutter-text"),gutter=elt("div",[gutterText],"CodeMirror-gutter");var mover=elt("div",[gutter,elt("div",[lineSpace],"CodeMirror-lines")],null,"position: relative");var sizer=elt("div",[mover],null,"position: relative");var scroller=elt("div",[sizer],"CodeMirror-scroll");scroller.setAttribute("tabIndex","-1");var wrapper=elt("div",[inputDiv,scrollbar,scroller],"CodeMirror"+(options.lineWrapping?" CodeMirror-wrap":""));if(place.appendChild)place.appendChild(wrapper);else place(wrapper);themeChanged();keyMapChanged();if(ios)input.style.width="0px";if(!webkit)scroller.draggable=true;lineSpace.style.outline="none";if(options.tabindex!=null)input.tabIndex=options.tabindex;if(options.autofocus)focusInput();if(!options.gutter&&!options.lineNumbers)gutter.style.display="none";if(khtml)inputDiv.style.height="1px",inputDiv.style.position="absolute";if(mac_geLion){scrollbar.style.zIndex=-2;scrollbar.style.visibility="hidden"}else if(ie_lt8)scrollbar.style.minWidth="18px";var poll=new Delayed,highlight=new Delayed,blinker;var mode,doc=new BranchChunk([new LeafChunk([new Line("")])]),frontier=0,focused;loadMode();var sel={from:{line:0,ch:0},to:{line:0,ch:0},inverted:false};var shiftSelecting,lastClick,lastDoubleClick,lastScrollTop=0,draggingText,overwrite=false,suppressEdits=false,pasteIncoming=false;var updateInput,userSelChange,changes,textChanged,selectionChanged,gutterDirty,callbacks;var displayOffset=0,showingFrom=0,showingTo=0,lastSizeC=0;var bracketHighlighted;var maxLine=getLine(0),updateMaxLine=false,maxLineChanged=true;var pollingFast=false;var goalColumn=null;operation(function(){setValue(options.value||"");updateInput=false})();var history=new History;connect(scroller,"mousedown",operation(onMouseDown));connect(scroller,"dblclick",operation(onDoubleClick));connect(lineSpace,"selectstart",e_preventDefault);if(!gecko)connect(scroller,"contextmenu",onContextMenu);connect(scroller,"scroll",onScrollMain);connect(scrollbar,"scroll",onScrollBar);connect(scrollbar,"mousedown",function(){if(focused)setTimeout(focusInput,0)});var resizeHandler=connect(window,"resize",function(){if(wrapper.parentNode)updateDisplay(true);else resizeHandler()},true);connect(input,"keyup",operation(onKeyUp));connect(input,"input",fastPoll);connect(input,"keydown",operation(onKeyDown));connect(input,"keypress",operation(onKeyPress));connect(input,"focus",onFocus);connect(input,"blur",onBlur);function drag_(e){if(options.onDragEvent&&options.onDragEvent(instance,addStop(e)))return;e_stop(e)}if(options.dragDrop){connect(scroller,"dragstart",onDragStart);connect(scroller,"dragenter",drag_);connect(scroller,"dragover",drag_);connect(scroller,"drop",operation(onDrop))}connect(scroller,"paste",function(){focusInput();fastPoll()});connect(input,"paste",function(){pasteIncoming=true;fastPoll()});connect(input,"cut",operation(function(){if(!options.readOnly)replaceSelection("")}));if(khtml)connect(sizer,"mouseup",function(){if(document.activeElement==input)input.blur();focusInput()});var hasFocus;try{hasFocus=document.activeElement==input}catch(e){}if(hasFocus||options.autofocus)setTimeout(onFocus,20);else onBlur();function isLine(l){return l>=0&&lvspace&&pos.y>node.offsetHeight)top=pos.y-node.offsetHeight;if(left+node.offsetWidth>hspace)left=hspace-node.offsetWidth}node.style.top=top+paddingTop()+"px";node.style.left=node.style.right="";if(horiz=="right"){left=sizer.clientWidth-node.offsetWidth;node.style.right="0px"}else{if(horiz=="left")left=0;else if(horiz=="middle")left=(sizer.clientWidth-node.offsetWidth)/2;node.style.left=left+paddingLeft()+"px"}if(scroll)scrollIntoView(left,top,left+node.offsetWidth,top+node.offsetHeight)},lineCount:function(){return doc.size},clipPos:clipPos,getCursor:function(start){if(start==null||start=="head")start=sel.inverted;if(start=="anchor")start=!sel.inverted;if(start=="end")start=false;return copyPos(start?sel.from:sel.to)},somethingSelected:function(){return!posEq(sel.from,sel.to)},setCursor:operation(function(line,ch,user){if(ch==null&&typeof line.line=="number")setCursor(line.line,line.ch,user);else setCursor(line,ch,user)}),setSelection:operation(function(from,to,user){(user?setSelectionUser:setSelection)(clipPos(from),clipPos(to||from))}),getLine:function(line){if(isLine(line))return getLine(line).text},getLineHandle:function(line){if(isLine(line))return getLine(line)},setLine:operation(function(line,text){if(isLine(line))replaceRange(text,{line:line,ch:0},{line:line,ch:getLine(line).text.length})}),removeLine:operation(function(line){if(isLine(line))replaceRange("",{line:line,ch:0},clipPos({line:line+1,ch:0}))}),replaceRange:operation(replaceRange),getRange:function(from,to,lineSep){return getRange(clipPos(from),clipPos(to),lineSep)},triggerOnKeyDown:operation(onKeyDown),execCommand:function(cmd){return commands[cmd](instance)},moveH:operation(moveH),deleteH:operation(deleteH),moveV:operation(moveV),toggleOverwrite:function(){if(overwrite){overwrite=false;cursor.className=cursor.className.replace(" CodeMirror-overwrite","")}else{overwrite=true;cursor.className+=" CodeMirror-overwrite"}},posFromIndex:function(off){var lineNo=0,ch;doc.iter(0,doc.size,function(line){var sz=line.text.length+1;if(sz>off){ch=off;return true}off-=sz;++lineNo});return clipPos({line:lineNo,ch:ch})},indexFromPos:function(coords){if(coords.line<0||coords.ch<0)return 0;var index=coords.ch;doc.iter(0,coords.line,function(line){index+=line.text.length+1});return index},scrollTo:function(x,y){if(x!=null)scroller.scrollLeft=x;if(y!=null)scrollbar.scrollTop=scroller.scrollTop=y;updateDisplay([])},getScrollInfo:function(){return{x:scroller.scrollLeft,y:scrollbar.scrollTop,height:scrollbar.scrollHeight,width:scroller.scrollWidth}},scrollIntoView:function(pos){var coords=localCoords(pos?clipPos(pos):sel.inverted?sel.from:sel.to);scrollIntoView(coords.x,coords.y,coords.x,coords.yBot)},setSize:function(width,height){function interpret(val){val=String(val);return/^\d+$/.test(val)?val+"px":val}if(width!=null)wrapper.style.width=interpret(width);if(height!=null)scroller.style.height=interpret(height);instance.refresh()},operation:function(f){return operation(f)()},compoundChange:function(f){return compoundChange(f)},refresh:function(){updateDisplay(true,null,lastScrollTop);if(scrollbar.scrollHeight>lastScrollTop)scrollbar.scrollTop=lastScrollTop},getInputField:function(){return input},getWrapperElement:function(){return wrapper},getScrollerElement:function(){return scroller},getGutterElement:function(){return gutter}};function getLine(n){return getLineAt(doc,n)}function updateLineHeight(line,height){gutterDirty=true;var diff=height-line.height;for(var n=line;n;n=n.parent)n.height+=diff}function lineContent(line,wrapAt){if(!line.styles)line.highlight(mode,line.stateAfter=getStateBefore(lineNo(line)),options.tabSize);return line.getContent(options.tabSize,wrapAt,options.lineWrapping)}function setValue(code){var top={line:0,ch:0};updateLines(top,{line:doc.size-1,ch:getLine(doc.size-1).text.length},splitLines(code),top,top);updateInput=true}function getValue(lineSep){var text=[];doc.iter(0,doc.size,function(line){text.push(line.text)});return text.join(lineSep||"\n")}function onScrollBar(e){if(Math.abs(scrollbar.scrollTop-lastScrollTop)>1){lastScrollTop=scroller.scrollTop=scrollbar.scrollTop;updateDisplay([])}}function onScrollMain(e){if(options.fixedGutter&&gutter.style.left!=scroller.scrollLeft+"px")gutter.style.left=scroller.scrollLeft+"px";if(Math.abs(scroller.scrollTop-lastScrollTop)>1){lastScrollTop=scroller.scrollTop;if(scrollbar.scrollTop!=lastScrollTop)scrollbar.scrollTop=lastScrollTop;updateDisplay([])}if(options.onScroll)options.onScroll(instance)}function onMouseDown(e){setShift(e_prop(e,"shiftKey"));for(var n=e_target(e);n!=wrapper;n=n.parentNode)if(n.parentNode==sizer&&n!=mover)return;for(var n=e_target(e);n!=wrapper;n=n.parentNode)if(n.parentNode==gutterText){if(options.onGutterClick)options.onGutterClick(instance,indexOf(gutterText.childNodes,n)+showingFrom,e);return e_preventDefault(e)}var start=posFromMouse(e);switch(e_button(e)){case 3:if(gecko)onContextMenu(e);return;case 2:if(start)setCursor(start.line,start.ch,true);setTimeout(focusInput,20);e_preventDefault(e);return}if(!start){if(e_target(e)==scroller)e_preventDefault(e);return}if(!focused)onFocus();var now=+new Date,type="single";if(lastDoubleClick&&lastDoubleClick.time>now-400&&posEq(lastDoubleClick.pos,start)){type="triple";e_preventDefault(e);setTimeout(focusInput,20);selectLine(start.line)}else if(lastClick&&lastClick.time>now-400&&posEq(lastClick.pos,start)){type="double";lastDoubleClick={time:now,pos:start};e_preventDefault(e);var word=findWordAt(start);setSelectionUser(word.from,word.to)}else{lastClick={time:now,pos:start}}function dragEnd(e2){if(webkit)scroller.draggable=false;draggingText=false;up();drop();if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.clientY)<10){e_preventDefault(e2);setCursor(start.line,start.ch,true);focusInput()}}var last=start,going;if(options.dragDrop&&dragAndDrop&&!options.readOnly&&!posEq(sel.from,sel.to)&&!posLess(start,sel.from)&&!posLess(sel.to,start)&&type=="single"){if(webkit)scroller.draggable=true;var up=connect(document,"mouseup",operation(dragEnd),true);var drop=connect(scroller,"drop",operation(dragEnd),true);draggingText=true;if(scroller.dragDrop)scroller.dragDrop();return}e_preventDefault(e);if(type=="single")setCursor(start.line,start.ch,true);var startstart=sel.from,startend=sel.to;function doSelect(cur){if(type=="single"){setSelectionUser(clipPos(start),cur);return}startstart=clipPos(startstart);startend=clipPos(startend);if(type=="double"){var word=findWordAt(cur);if(posLess(cur,startstart))setSelectionUser(word.from,startend);else setSelectionUser(startstart,word.to)}else if(type=="triple"){if(posLess(cur,startstart))setSelectionUser(startend,clipPos({line:cur.line,ch:0}));else setSelectionUser(startstart,clipPos({line:cur.line+1,ch:0}))}}function extend(e){var cur=posFromMouse(e,true);if(cur&&!posEq(cur,last)){if(!focused)onFocus();last=cur;doSelect(cur);updateInput=false;var visible=visibleLines();if(cur.line>=visible.to||cur.line-1)setTimeout(operation(function(){indentLine(sel.to.line,"smart")}),75)}if(handleCharBinding(e,ch))return;fastPoll()}function onKeyUp(e){if(options.onKeyEvent&&options.onKeyEvent(instance,addStop(e)))return;if(e_prop(e,"keyCode")==16)shiftSelecting=null}function onFocus(){if(options.readOnly=="nocursor")return;if(!focused){if(options.onFocus)options.onFocus(instance);focused=true;if(scroller.className.search(/\bCodeMirror-focused\b/)==-1)scroller.className+=" CodeMirror-focused"}slowPoll();restartBlink()}function onBlur(){if(focused){if(options.onBlur)options.onBlur(instance);focused=false;if(bracketHighlighted)operation(function(){if(bracketHighlighted){bracketHighlighted();bracketHighlighted=null}})();scroller.className=scroller.className.replace(" CodeMirror-focused","")}clearInterval(blinker);setTimeout(function(){if(!focused)shiftSelecting=null},150)}function updateLines(from,to,newText,selFrom,selTo){if(suppressEdits)return;var old=[];doc.iter(from.line,to.line+1,function(line){old.push(newHL(line.text,line.markedSpans))});if(history){history.addChange(from.line,newText.length,old);while(history.done.length>options.undoDepth)history.done.shift()}var lines=updateMarkedSpans(hlSpans(old[0]),hlSpans(lst(old)),from.ch,to.ch,newText);updateLinesNoUndo(from,to,lines,selFrom,selTo)}function unredoHelper(from,to){if(!from.length)return;var set=from.pop(),out=[];for(var i=set.length-1;i>=0;i-=1){var change=set[i];var replaced=[],end=change.start+change.added;doc.iter(change.start,end,function(line){replaced.push(newHL(line.text,line.markedSpans))});out.push({start:change.start,added:change.old.length,old:replaced});var pos={line:change.start+change.old.length-1,ch:editEnd(hlText(lst(replaced)),hlText(lst(change.old)))};updateLinesNoUndo({line:change.start,ch:0},{line:end-1,ch:getLine(end-1).text.length},change.old,pos,pos)}updateInput=true;to.push(out)}function undo(){unredoHelper(history.done,history.undone)}function redo(){unredoHelper(history.undone,history.done)}function updateLinesNoUndo(from,to,lines,selFrom,selTo){if(suppressEdits)return;var recomputeMaxLength=false,maxLineLength=maxLine.text.length;if(!options.lineWrapping)doc.iter(from.line,to.line+1,function(line){if(!line.hidden&&line.text.length==maxLineLength){recomputeMaxLength=true;return true}});if(from.line!=to.line||lines.length>1)gutterDirty=true;var nlines=to.line-from.line,firstLine=getLine(from.line),lastLine=getLine(to.line);var lastHL=lst(lines);if(from.ch==0&&to.ch==0&&hlText(lastHL)==""){var added=[],prevLine=null;for(var i=0,e=lines.length-1;i1)doc.remove(from.line+1,nlines-1,callbacks);doc.insert(from.line+1,added)}if(options.lineWrapping){var perLine=Math.max(5,scroller.clientWidth/charWidth()-3);doc.iter(from.line,from.line+lines.length,function(line){if(line.hidden)return;var guess=Math.ceil(line.text.length/perLine)||1;if(guess!=line.height)updateLineHeight(line,guess)})}else{doc.iter(from.line,from.line+lines.length,function(line){var l=line.text;if(!line.hidden&&l.length>maxLineLength){maxLine=line;maxLineLength=l.length;maxLineChanged=true;recomputeMaxLength=false}});if(recomputeMaxLength)updateMaxLine=true}frontier=Math.min(frontier,from.line);startWorker(400);var lendiff=lines.length-nlines-1;changes.push({from:from.line,to:to.line+1,diff:lendiff});if(options.onChange){for(var i=0;iscroller.offsetHeight?realHeight:false}function updateVerticalScroll(scrollTop){var scrollHeight=needsScrollbar();scrollbar.style.display=scrollHeight?"block":"none";if(scrollHeight){scrollbarInner.style.height=sizer.style.minHeight=scrollHeight+"px";scrollbar.style.height=scroller.clientHeight+"px";if(scrollTop!=null){scrollbar.scrollTop=scroller.scrollTop=scrollTop;if(webkit)setTimeout(function(){if(scrollbar.scrollTop!=scrollTop)return;scrollbar.scrollTop=scrollTop+(scrollTop?-1:1);scrollbar.scrollTop=scrollTop},0)}}else{sizer.style.minHeight=""}mover.style.top=displayOffset*textHeight()+"px"}function computeMaxLength(){maxLine=getLine(0);maxLineChanged=true;var maxLineLength=maxLine.text.length;doc.iter(1,doc.size,function(line){var l=line.text;if(!line.hidden&&l.length>maxLineLength){maxLineLength=l.length;maxLine=line}});updateMaxLine=false}function replaceRange(code,from,to){from=clipPos(from);if(!to)to=from;else to=clipPos(to);code=splitLines(code);function adjustPos(pos){if(posLess(pos,from))return pos;if(!posLess(to,pos))return end;var line=pos.line+code.length-(to.line-from.line)-1;var ch=pos.ch;if(pos.line==to.line)ch+=lst(code).length-(to.ch-(to.line==from.line?from.ch:0));return{line:line,ch:ch}}var end;replaceRange1(code,from,to,function(end1){end=end1;return{from:adjustPos(sel.from),to:adjustPos(sel.to)}});return end}function replaceSelection(code,collapse){replaceRange1(splitLines(code),sel.from,sel.to,function(end){if(collapse=="end")return{from:end,to:end};else if(collapse=="start")return{from:sel.from,to:sel.from};else return{from:sel.from,to:end}})}function replaceRange1(code,from,to,computeSel){var endch=code.length==1?code[0].length+from.ch:lst(code).length;var newSel=computeSel({line:from.line+code.length-1,ch:endch});updateLines(from,to,code,newSel.from,newSel.to)}function getRange(from,to,lineSep){var l1=from.line,l2=to.line;if(l1==l2)return getLine(l1).text.slice(from.ch,to.ch);var code=[getLine(l1).text.slice(from.ch)];doc.iter(l1+1,l2,function(line){code.push(line.text)});code.push(getLine(l2).text.slice(0,to.ch));return code.join(lineSep||"\n")}function getSelection(lineSep){return getRange(sel.from,sel.to,lineSep)}function slowPoll(){if(pollingFast)return;poll.set(options.pollInterval,function(){readInput();if(focused)slowPoll()})}function fastPoll(){var missed=false;pollingFast=true;function p(){var changed=readInput();if(!changed&&!missed){missed=true;poll.set(60,p)}else{pollingFast=false;slowPoll()}}poll.set(20,p)}var prevInput="";function readInput(){if(!focused||hasSelection(input)||options.readOnly)return false;var text=input.value;if(text==prevInput)return false;if(!nestedOperation)startOperation();shiftSelecting=null;var same=0,l=Math.min(prevInput.length,text.length);while(same1e3){input.value=prevInput=""}else prevInput=text;if(!nestedOperation)endOperation();pasteIncoming=false;return true}function resetInput(user){if(!posEq(sel.from,sel.to)){prevInput="";input.value=getSelection();if(focused)selectInput(input)}else if(user)prevInput=input.value=""}function focusInput(){if(options.readOnly!="nocursor"&&(ie_lt9||document.activeElement!=input))input.focus()}function scrollCursorIntoView(){var coords=calculateCursorCoords();scrollIntoView(coords.x,coords.y,coords.x,coords.yBot);if(!focused)return;var box=sizer.getBoundingClientRect(),doScroll=null;if(coords.y+box.top<0)doScroll=true;else if(coords.y+box.top+textHeight()>(window.innerHeight||document.documentElement.clientHeight))doScroll=false;if(doScroll!=null){var hidden=cursor.style.display=="none";if(hidden){cursor.style.display="";cursor.style.left=coords.x+"px";cursor.style.top=coords.y-displayOffset+"px"}cursor.scrollIntoView(doScroll);if(hidden)cursor.style.display="none"}}function calculateCursorCoords(){var cursor=localCoords(sel.inverted?sel.from:sel.to);var x=options.lineWrapping?Math.min(cursor.x,lineSpace.offsetWidth):cursor.x;return{x:x,y:cursor.y,yBot:cursor.yBot}}function scrollIntoView(x1,y1,x2,y2){var scrollPos=calculateScrollPos(x1,y1,x2,y2);if(scrollPos.scrollLeft!=null){scroller.scrollLeft=scrollPos.scrollLeft}if(scrollPos.scrollTop!=null){scrollbar.scrollTop=scroller.scrollTop=scrollPos.scrollTop}}function calculateScrollPos(x1,y1,x2,y2){var pl=paddingLeft(),pt=paddingTop();y1+=pt;y2+=pt;x1+=pl;x2+=pl;var screen=scroller.clientHeight,screentop=scrollbar.scrollTop,result={};var docBottom=needsScrollbar()||Infinity;var atTop=y1docBottom-10;if(y1screentop+screen)result.scrollTop=(atBottom?docBottom:y2)-screen;var screenw=scroller.clientWidth,screenleft=scroller.scrollLeft;var gutterw=options.fixedGutter?gutter.clientWidth:0;var atLeft=x1screenw+screenleft-3){result.scrollLeft=x2+10-screenw}return result}function visibleLines(scrollTop){var lh=textHeight(),top=(scrollTop!=null?scrollTop:scrollbar.scrollTop)-paddingTop();var fromHeight=Math.max(0,Math.floor(top/lh));var toHeight=Math.ceil((top+scroller.clientHeight)/lh);return{from:lineAtHeight(doc,fromHeight),to:lineAtHeight(doc,toHeight)}}function updateDisplay(changes,suppressCallback,scrollTop){if(!scroller.clientWidth){showingFrom=showingTo=displayOffset=0;return}var visible=visibleLines(scrollTop);if(changes!==true&&changes.length==0&&visible.from>showingFrom&&visible.toto&&showingTo-to<20)to=Math.min(doc.size,showingTo);var intact=changes===true?[]:computeIntact([{from:showingFrom,to:showingTo,domStart:0}],changes);var intactLines=0;for(var i=0;ito)range.to=to;if(range.from>=range.to)intact.splice(i--,1);else intactLines+=range.to-range.from}if(intactLines==to-from&&from==showingFrom&&to==showingTo){updateVerticalScroll(scrollTop);return}intact.sort(function(a,b){return a.domStart-b.domStart});var th=textHeight(),gutterDisplay=gutter.style.display;lineDiv.style.display="none";patchDisplay(from,to,intact);lineDiv.style.display=gutter.style.display="";var different=from!=showingFrom||to!=showingTo||lastSizeC!=scroller.clientHeight+th;if(different)lastSizeC=scroller.clientHeight+th;if(from!=showingFrom||to!=showingTo&&options.onViewportChange)setTimeout(function(){if(options.onViewportChange)options.onViewportChange(instance,from,to)});showingFrom=from;showingTo=to;displayOffset=heightAtLine(doc,from);startWorker(100);if(lineDiv.childNodes.length!=showingTo-showingFrom)throw new Error("BAD PATCH! "+JSON.stringify(intact)+" size="+(showingTo-showingFrom)+" nodes="+lineDiv.childNodes.length);function checkHeights(){var curNode=lineDiv.firstChild,heightChanged=false;doc.iter(showingFrom,showingTo,function(line){if(!curNode)return;if(!line.hidden){var height=Math.round(curNode.offsetHeight/th)||1;if(line.height!=height){updateLineHeight(line,height);gutterDirty=heightChanged=true}}curNode=curNode.nextSibling});return heightChanged}if(options.lineWrapping)checkHeights();gutter.style.display=gutterDisplay;if(different||gutterDirty){updateGutter()&&options.lineWrapping&&checkHeights()&&updateGutter()}updateVerticalScroll(scrollTop);updateSelection();if(!suppressCallback&&options.onUpdate)options.onUpdate(instance);return true}function computeIntact(intact,changes){for(var i=0,l=changes.length||0;i=range.to)intact2.push(range);else{if(change.from>range.from)intact2.push({from:range.from,to:change.from,domStart:range.domStart});if(change.todomPos){curNode=killNode(curNode);domPos++}for(var j=0,e=cur.to-cur.from;jj){if(line.hidden)var lineElement=elt("pre");else{var lineElement=lineContent(line);if(line.className)lineElement.className=line.className;if(line.bgClassName){var pre=elt("pre"," ",line.bgClassName,"position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2");lineElement=elt("div",[pre,lineElement],null,"position: relative")}}lineDiv.insertBefore(lineElement,curNode)}else{curNode=curNode.nextSibling}++j})}function updateGutter(){if(!options.gutter&&!options.lineNumbers)return;var hText=mover.offsetHeight,hEditor=scroller.clientHeight;gutter.style.height=(hText-hEditor<2?hEditor:hText)+"px";var fragment=document.createDocumentFragment(),i=showingFrom,normalNode;doc.iter(showingFrom,Math.max(showingTo,showingFrom+1),function(line){if(line.hidden){fragment.appendChild(elt("pre"))}else{var marker=line.gutterMarker;var text=options.lineNumbers?options.lineNumberFormatter(i+options.firstLineNumber):null;if(marker&&marker.text)text=marker.text.replace("%N%",text!=null?text:"");else if(text==null)text=" ";var markerElement=fragment.appendChild(elt("pre",null,marker&&marker.style));markerElement.innerHTML=text;for(var j=1;j2;lineSpace.style.marginLeft=gutter.offsetWidth+"px";gutterDirty=false;return resized}function updateSelection(){var collapsed=posEq(sel.from,sel.to);var fromPos=localCoords(sel.from,true);var toPos=collapsed?fromPos:localCoords(sel.to,true);var headPos=sel.inverted?fromPos:toPos,th=textHeight();var wrapOff=eltOffset(wrapper),lineOff=eltOffset(lineDiv);inputDiv.style.top=Math.max(0,Math.min(scroller.offsetHeight,headPos.y+lineOff.top-wrapOff.top))+"px";inputDiv.style.left=Math.max(0,Math.min(scroller.offsetWidth,headPos.x+lineOff.left-wrapOff.left))+"px";if(collapsed||options.showCursorWhenSelecting){cursor.style.top=headPos.y+"px";cursor.style.left=(options.lineWrapping?Math.min(headPos.x,lineSpace.offsetWidth):headPos.x)+"px";cursor.style.display=""}else{cursor.style.display="none"}if(!collapsed){var sameLine=fromPos.y==toPos.y,fragment=document.createDocumentFragment();var clientWidth=lineSpace.clientWidth||lineSpace.offsetWidth;var clientHeight=lineSpace.clientHeight||lineSpace.offsetHeight;var add=function(left,top,right,height){var rstyle=quirksMode?"width: "+(!right?clientWidth:clientWidth-right-left)+"px":"right: "+(right-1)+"px";fragment.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+left+"px; top: "+top+"px; "+rstyle+"; height: "+height+"px"))};if(sel.from.ch&&fromPos.y>=0){var right=sameLine?clientWidth-toPos.x:0;add(fromPos.x,fromPos.y,right,th)}var middleStart=Math.max(0,fromPos.y+(sel.from.ch?th:0));var middleHeight=Math.min(toPos.y,clientHeight)-middleStart;if(middleHeight>.2*th)add(0,middleStart,0,middleHeight);if((!sameLine||!sel.from.ch)&&toPos.yoldCh||ch>line.text.length)ch=line.text.length;return{line:lNo,ch:ch}}lNo+=dir}}var line=getLine(pos.line);var toEnd=pos.ch==line.text.length&&pos.ch!=oldCh;if(!line.hidden)return pos;if(pos.line>=oldLine)return getNonHidden(1)||getNonHidden(-1);else return getNonHidden(-1)||getNonHidden(1)}function setCursor(line,ch,user){var pos=clipPos({line:line,ch:ch||0});(user?setSelectionUser:setSelection)(pos,pos)}function clipLine(n){return Math.max(0,Math.min(n,doc.size-1))}function clipPos(pos){if(pos.line<0)return{line:0,ch:0};if(pos.line>=doc.size)return{line:doc.size-1,ch:getLine(doc.size-1).text.length};var ch=pos.ch,linelen=getLine(pos.line).text.length;if(ch==null||ch>linelen)return{line:pos.line,ch:linelen};else if(ch<0)return{line:pos.line,ch:0};else return pos}function findPosH(dir,unit){var end=sel.inverted?sel.from:sel.to,line=end.line,ch=end.ch;var lineObj=getLine(line);function findNextLine(){for(var l=line+dir,e=dir<0?-1:doc.size;l!=e;l+=dir){var lo=getLine(l);if(!lo.hidden){line=l;lineObj=lo;return true}}}function moveOnce(boundToLine){if(ch==(dir<0?0:lineObj.text.length)){if(!boundToLine&&findNextLine())ch=dir<0?lineObj.text.length:0;else return false}else ch+=dir;return true}if(unit=="char")moveOnce();else if(unit=="column")moveOnce(true);else if(unit=="word"){var sawWord=false;for(;;){if(dir<0)if(!moveOnce())break;if(isWordChar(lineObj.text.charAt(ch)))sawWord=true;else if(sawWord){if(dir<0){dir=1;moveOnce()}break}if(dir>0)if(!moveOnce())break}}return{line:line,ch:ch}}function moveH(dir,unit){var pos=dir<0?sel.from:sel.to;if(shiftSelecting||posEq(sel.from,sel.to))pos=findPosH(dir,unit);setCursor(pos.line,pos.ch,true)}function deleteH(dir,unit){if(!posEq(sel.from,sel.to))replaceRange("",sel.from,sel.to);else if(dir<0)replaceRange("",findPosH(dir,unit),sel.to);else replaceRange("",sel.from,findPosH(dir,unit));userSelChange=true}function moveV(dir,unit){var dist=0,pos=localCoords(sel.inverted?sel.from:sel.to,true);if(goalColumn!=null)pos.x=goalColumn;if(unit=="page"){var screen=Math.min(scroller.clientHeight,window.innerHeight||document.documentElement.clientHeight);var target=coordsChar(pos.x,pos.y+screen*dir)}else if(unit=="line"){var th=textHeight();var target=coordsChar(pos.x,pos.y+.5*th+dir*th)}if(unit=="page")scrollbar.scrollTop+=localCoords(target,true).y-pos.y;setCursor(target.line,target.ch,true);goalColumn=pos.x}function findWordAt(pos){var line=getLine(pos.line).text;var start=pos.ch,end=pos.ch;if(line){if(pos.after===false||end==line.length)--start;else++end;var startChar=line.charAt(start);var check=isWordChar(startChar)?isWordChar:/\s/.test(startChar)?function(ch){return/\s/.test(ch)}:function(ch){return!/\s/.test(ch)&&isWordChar(ch)};while(start>0&&check(line.charAt(start-1)))--start;while(end=pos.ch))markers.push(span.marker)}return markers}function addGutterMarker(line,text,className){if(typeof line=="number")line=getLine(clipLine(line));line.gutterMarker={text:text,style:className};gutterDirty=true;return line}function removeGutterMarker(line){if(typeof line=="number")line=getLine(clipLine(line));line.gutterMarker=null;gutterDirty=true}function changeLine(handle,op){var no=handle,line=handle;if(typeof handle=="number")line=getLine(clipLine(handle));else no=lineNo(handle);if(no==null)return null;if(op(line,no))changes.push({from:no,to:no+1});else return null;return line}function setLineClass(handle,className,bgClassName){return changeLine(handle,function(line){if(line.className!=className||line.bgClassName!=bgClassName){line.className=className;line.bgClassName=bgClassName;return true}})}function setLineHidden(handle,hidden){return changeLine(handle,function(line,no){if(line.hidden!=hidden){line.hidden=hidden;if(!options.lineWrapping){if(hidden&&line.text.length==maxLine.text.length){updateMaxLine=true}else if(!hidden&&line.text.length>maxLine.text.length){maxLine=line;updateMaxLine=false}}updateLineHeight(line,hidden?0:1);var fline=sel.from.line,tline=sel.to.line;if(hidden&&(fline==no||tline==no)){var from=fline==no?skipHidden({line:fline,ch:0},fline,0):sel.from;var to=tline==no?skipHidden({line:tline,ch:0},tline,0):sel.to;if(!to)return;setSelection(from,to)}return gutterDirty=true}})}function lineInfo(line){if(typeof line=="number"){if(!isLine(line))return null;var n=line;line=getLine(line);if(!line)return null}else{var n=lineNo(line);if(n==null)return null}var marker=line.gutterMarker;return{line:n,handle:line,text:line.text,markerText:marker&&marker.text,markerClass:marker&&marker.style,lineClass:line.className,bgClass:line.bgClassName}}function measureLine(line,ch){if(ch==0)return{top:0,left:0};var pre=lineContent(line,ch);removeChildrenAndAdd(measure,pre);var anchor=pre.anchor;var top=anchor.offsetTop,left=anchor.offsetLeft;if(ie&&top==0&&left==0){var backup=elt("span","x");anchor.parentNode.insertBefore(backup,anchor.nextSibling);top=backup.offsetTop}return{top:top,left:left}}function localCoords(pos,inLineWrap){var x,lh=textHeight(),y=lh*(heightAtLine(doc,pos.line)-(inLineWrap?displayOffset:0));if(pos.ch==0)x=0;else{var sp=measureLine(getLine(pos.line),pos.ch);x=sp.left;if(options.lineWrapping)y+=Math.max(0,sp.top)}return{x:x,y:y,yBot:y+lh}}function coordsChar(x,y){var th=textHeight(),cw=charWidth(),heightPos=displayOffset+Math.floor(y/th);if(heightPos<0)return{line:0,ch:0};var lineNo=lineAtHeight(doc,heightPos);if(lineNo>=doc.size)return{line:doc.size-1,ch:getLine(doc.size-1).text.length};var lineObj=getLine(lineNo),text=lineObj.text;var tw=options.lineWrapping,innerOff=tw?heightPos-heightAtLine(doc,lineNo):0;if(x<=0&&innerOff==0)return{line:lineNo,ch:0};var wrongLine=false;function getX(len){var sp=measureLine(lineObj,len);if(tw){var off=Math.round(sp.top/th);wrongLine=off!=innerOff;return Math.max(0,sp.left+(off-innerOff)*scroller.clientWidth)}return sp.left}var from=0,fromX=0,to=text.length,toX;var estimated=Math.min(to,Math.ceil((x+innerOff*scroller.clientWidth*.9)/cw));for(;;){var estX=getX(estimated);if(estX<=x&&estimatedtoX)return{line:lineNo,ch:to};estimated=Math.floor(to*.8);estX=getX(estimated);if(estXx){to=middle;toX=middleX;if(wrongLine)toX+=1e3}else{from=middle;fromX=middleX}}}function pageCoords(pos){var local=localCoords(pos,true),off=eltOffset(lineSpace);return{x:off.left+local.x,y:off.top+local.y,yBot:off.top+local.yBot}}var cachedHeight,cachedHeightFor,measurePre;function textHeight(){if(measurePre==null){measurePre=elt("pre");for(var i=0;i<49;++i){measurePre.appendChild(document.createTextNode("x"));measurePre.appendChild(elt("br"))}measurePre.appendChild(document.createTextNode("x"))}var offsetHeight=lineDiv.clientHeight;if(offsetHeight==cachedHeightFor)return cachedHeight;cachedHeightFor=offsetHeight;removeChildrenAndAdd(measure,measurePre.cloneNode(true));cachedHeight=measure.firstChild.offsetHeight/50||1;removeChildren(measure);return cachedHeight}var cachedWidth,cachedWidthFor=0;function charWidth(){if(scroller.clientWidth==cachedWidthFor)return cachedWidth;cachedWidthFor=scroller.clientWidth;var anchor=elt("span","x");var pre=elt("pre",[anchor]);removeChildrenAndAdd(measure,pre);return cachedWidth=anchor.offsetWidth||10}function paddingTop(){return lineSpace.offsetTop}function paddingLeft(){return lineSpace.offsetLeft}function posFromMouse(e,liberal){var offW=eltOffset(scroller,true),x,y;try{x=e.clientX;y=e.clientY}catch(e){return null}if(!liberal&&(x-offW.left>scroller.clientWidth||y-offW.top>scroller.clientHeight))return null;var offL=eltOffset(lineSpace,true);return coordsChar(x-offL.left,y-offL.top)}var detectingSelectAll;function onContextMenu(e){var pos=posFromMouse(e),scrollPos=scrollbar.scrollTop;if(!pos||opera)return;if(posEq(sel.from,sel.to)||posLess(pos,sel.from)||!posLess(pos,sel.to))operation(setCursor)(pos.line,pos.ch);var oldCSS=input.style.cssText;inputDiv.style.position="absolute";input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";focusInput();resetInput(true);if(posEq(sel.from,sel.to))input.value=prevInput=" ";function rehide(){inputDiv.style.position="relative";input.style.cssText=oldCSS;if(ie_lt9)scrollbar.scrollTop=scrollPos;slowPoll();if(input.selectionStart!=null){clearTimeout(detectingSelectAll);var extval=input.value=" "+(posEq(sel.from,sel.to)?"":input.value),i=0;prevInput=" ";input.selectionStart=1;input.selectionEnd=extval.length;detectingSelectAll=setTimeout(function poll(){if(prevInput==" "&&input.selectionStart==0)operation(commands.selectAll)(instance);else if(i++<10)detectingSelectAll=setTimeout(poll,500);else resetInput()},200)}}if(gecko){e_stop(e);var mouseup=connect(window,"mouseup",function(){mouseup();setTimeout(rehide,20)},true)}else{setTimeout(rehide,50)}}function restartBlink(){clearInterval(blinker);var on=true;cursor.style.visibility="";blinker=setInterval(function(){cursor.style.visibility=(on=!on)?"":"hidden"},options.cursorBlinkRate)}var matching={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};function matchBrackets(autoclear){var head=sel.inverted?sel.from:sel.to,line=getLine(head.line),pos=head.ch-1;var match=pos>=0&&matching[line.text.charAt(pos)]||matching[line.text.charAt(++pos)];if(!match)return;var ch=match.charAt(0),forward=match.charAt(1)==">",d=forward?1:-1,st=line.styles;for(var off=pos+1,i=0,e=st.length;i=from&&pos"==forward)stack.push(cur);else if(stack.pop()!=match.charAt(0))return{pos:pos,match:false};else if(!stack.length)return{pos:pos,match:true}}}}}for(var i=head.line,e=forward?Math.min(i+100,doc.size):Math.max(-1,i-100);i!=e;i+=d){var line=getLine(i),first=i==head.line;var found=scan(line,first&&forward?pos+1:0,first&&!forward?pos:line.text.length);if(found)break}if(!found)found={pos:null,match:false};var style=found.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";var one=markText({line:head.line,ch:pos},{line:head.line,ch:pos+1},style),two=found.pos!=null&&markText({line:i,ch:found.pos},{line:i,ch:found.pos+1},style);var clear=operation(function(){one.clear();two&&two.clear()});if(autoclear)setTimeout(clear,800);else bracketHighlighted=clear}function findStartLine(n){var minindent,minline;for(var search=n,lim=n-40;search>lim;--search){if(search==0)return 0;var line=getLine(search-1);if(line.stateAfter)return search;var indented=line.indentation(options.tabSize);if(minline==null||minindent>indented){minline=search-1;minindent=indented}}return minline}function getStateBefore(n){var pos=findStartLine(n),state=pos&&getLine(pos-1).stateAfter;if(!state)state=startState(mode);else state=copyState(mode,state);doc.iter(pos,n,function(line){line.process(mode,state,options.tabSize);line.stateAfter=pos==n-1||pos%5==0?copyState(mode,state):null});return state}function highlightWorker(){if(frontier>=showingTo)return;var end=+new Date+options.workTime,state=copyState(mode,getStateBefore(frontier));var startFrontier=frontier;doc.iter(frontier,showingTo,function(line){if(frontier>=showingFrom){line.highlight(mode,state,options.tabSize);line.stateAfter=copyState(mode,state)}else{line.process(mode,state,options.tabSize);line.stateAfter=frontier%5==0?copyState(mode,state):null}++frontier;if(+new Date>end){startWorker(options.workDelay);return true}});if(showingTo>startFrontier&&frontier>=showingFrom)operation(function(){changes.push({from:startFrontier,to:frontier})})()}function startWorker(time){if(frontier2){mode.dependencies=[];for(var i=2;i0&&cur.ch=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.posstart},eatSpace:function(){var start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true}},backUp:function(n){this.pos-=n},column:function(){return countColumn(this.string,this.start,this.tabSize)},indentation:function(){return countColumn(this.string,null,this.tabSize)},match:function(pattern,consume,caseInsensitive){if(typeof pattern=="string"){var cased=function(str){return caseInsensitive?str.toLowerCase():str};if(cased(this.string).indexOf(cased(pattern),this.pos)==this.pos){if(consume!==false)this.pos+=pattern.length;return true}}else{var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;if(match&&consume!==false)this.pos+=match[0].length;return match}},current:function(){return this.string.slice(this.start,this.pos)}};CodeMirror.StringStream=StringStream;function MarkedSpan(from,to,marker){this.from=from;this.to=to;this.marker=marker}function getMarkedSpanFor(spans,marker){if(spans)for(var i=0;i=startCh:span.to>startCh);(nw||(nw=[])).push({from:span.from,to:endsAfter?null:span.to,marker:marker})}}return nw}function markedSpansAfter(old,endCh){if(old)for(var i=0,nw;i=endCh:span.to>endCh);if(endsAfter||marker.type=="bookmark"&&span.from==endCh){var startsBefore=span.from==null||(marker.inclusiveLeft?span.from<=endCh:span.from0&&first)for(var i=0;i5e3){st[pos++]=this.text.slice(stream.pos);st[pos++]=null;break}}},process:function(mode,state,tabSize){var stream=new StringStream(this.text,tabSize);if(this.text==""&&mode.blankLine)mode.blankLine(state);while(!stream.eol()&&stream.pos<=5e3){mode.token(stream,state);stream.start=stream.pos}},getTokenAt:function(mode,state,tabSize,ch){var txt=this.text,stream=new StringStream(txt,tabSize);while(stream.pos=outPos&&wrapAtwrapAt+10&&/\s/.test(text))span=function(){}}}}var st=this.styles,allText=this.text,marked=this.markedSpans;var len=allText.length;function styleToClass(style){if(!style)return null;return"cm-"+style.replace(/ +/g," cm-")}if(!allText&&wrapAt==null){span(pre," ")}else if(!marked||!marked.length){for(var i=0,ch=0;chlen)str=str.slice(0,len-ch);ch+=l;span(pre,str,styleToClass(style))}}else{marked.sort(function(a,b){return a.from-b.from});var pos=0,i=0,text="",style,sg=0;var nextChange=marked[0].from||0,marks=[],markpos=0;var advanceMarks=function(){var m;while(markposupto?text.slice(0,upto-pos):text,appliedStyle);if(end>=upto){text=text.slice(upto-pos);pos=upto;break}pos=end}text=st[i++];style=styleToClass(st[i++])}}}return pre},cleanUp:function(){this.parent=null;detachMarkedSpans(this)}};function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,e=lines.length,height=0;i50){while(child.lines.length>50){var spilled=child.lines.splice(child.lines.length-25,25);var newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.children.splice(i+1,0,newleaf);newleaf.parent=this}this.maybeSpill()}break}at-=sz}},maybeSpill:function(){if(this.children.length<=10)return;var me=this;do{var spilled=me.children.splice(me.children.length-5,5);var sibling=new BranchChunk(spilled);if(!me.parent){var copy=new BranchChunk(me.children);copy.parent=me;me.children=[copy,sibling];me=copy}else{me.size-=sibling.size;me.height-=sibling.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice(myIndex+1,0,sibling)}sibling.parent=me.parent}while(me.children.length>10);me.parent.maybeSpill()},iter:function(from,to,op){this.iterN(from,to-from,op)},iterN:function(at,n,op){for(var i=0,e=this.children.length;i400||!last||this.closed||last.start>start+old.length||last.start+last.added0;--i)last.old.unshift(old[i-1]);for(var i=endAfter;i>0;--i)last.old.push(old[old.length-i]);if(startBefore)last.start=start;last.added+=added-(old.length-startBefore-endAfter)}this.time=time},startCompound:function(){if(!this.compound++)this.closed=true},endCompound:function(){if(!--this.compound)this.closed=true}};function stopMethod(){e_stop(this)}function addStop(event){if(!event.stop)event.stop=stopMethod;return event}function e_preventDefault(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false}function e_stopPropagation(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true}function e_stop(e){e_preventDefault(e);e_stopPropagation(e)}CodeMirror.e_stop=e_stop;CodeMirror.e_preventDefault=e_preventDefault;CodeMirror.e_stopPropagation=e_stopPropagation;function e_target(e){return e.target||e.srcElement}function e_button(e){var b=e.which;if(b==null){if(e.button&1)b=1;else if(e.button&2)b=3;else if(e.button&4)b=2}if(mac&&e.ctrlKey&&b==1)b=3;return b}function e_prop(e,prop){var overridden=e.override&&e.override.hasOwnProperty(prop);return overridden?e.override[prop]:e[prop]}function connect(node,type,handler,disconnect){if(typeof node.addEventListener=="function"){node.addEventListener(type,handler,false);if(disconnect)return function(){node.removeEventListener(type,handler,false)}}else{var wrapHandler=function(event){handler(event||window.event)};node.attachEvent("on"+type,wrapHandler);if(disconnect)return function(){node.detachEvent("on"+type,wrapHandler)}}}CodeMirror.connect=connect;function Delayed(){this.id=null}Delayed.prototype={set:function(ms,f){clearTimeout(this.id);this.id=setTimeout(f,ms)}};var Pass=CodeMirror.Pass={toString:function(){return"CodeMirror.Pass"}};var dragAndDrop=function(){if(ie_lt9)return false;var div=elt("div");return"draggable"in div||"dragDrop"in div}();var lineSep=function(){var te=elt("textarea");te.value="foo\nbar";if(te.value.indexOf("\r")>-1)return"\r\n";return"\n"}();var spanAffectsWrapping=/^$/;if(gecko)spanAffectsWrapping=/$'/;else if(safari)spanAffectsWrapping=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/;else if(chrome)spanAffectsWrapping=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/;function countColumn(string,end,tabSize){if(end==null){end=string.search(/[^\s\u00a0]/);if(end==-1)end=string.length}for(var i=0,n=0;i=0&&j>=0;--i,--j)if(from.charAt(i)!=to.charAt(j))break;return j+1}function indexOf(collection,elt){if(collection.indexOf)return collection.indexOf(elt);for(var i=0,e=collection.length;i"€"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch))}var splitLines="\n\nb".split(/\n/).length!=3?function(string){var pos=0,result=[],l=string.length;while(pos<=l){var nl=string.indexOf("\n",pos);if(nl==-1)nl=string.length;var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl);var rt=line.indexOf("\r");if(rt!=-1){result.push(line.slice(0,rt));pos+=rt+1}else{result.push(line);pos=nl+1}}return result}:function(string){return string.split(/\r\n?|\n/)};CodeMirror.splitLines=splitLines;var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd}catch(e){return false}}:function(te){try{var range=te.ownerDocument.selection.createRange()}catch(e){}if(!range||range.parentElement()!=te)return false;return range.compareEndPoints("StartToEnd",range)!=0};CodeMirror.defineMode("null",function(){return{token:function(stream){stream.skipToEnd()}}});CodeMirror.defineMIME("text/plain","null");var keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};CodeMirror.keyNames=keyNames;!function(){for(var i=0;i<10;i++)keyNames[i+48]=String(i);for(var i=65;i<=90;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;i<=12;i++)keyNames[i+111]=keyNames[i+63235]="F"+i}();CodeMirror.version="2.38";return CodeMirror}();CodeMirror.defineMode("htmlmixed",function(config){var htmlMode=CodeMirror.getMode(config,{name:"xml",htmlMode:true});var jsMode=CodeMirror.getMode(config,"javascript");var cssMode=CodeMirror.getMode(config,"css");function html(stream,state){var style=htmlMode.token(stream,state.htmlState);if(/(?:^|\s)tag(?:\s|$)/.test(style)&&stream.current()==">"&&state.htmlState.context){if(/^script$/i.test(state.htmlState.context.tagName)){state.token=javascript;state.localState=jsMode.startState(htmlMode.indent(state.htmlState,""))}else if(/^style$/i.test(state.htmlState.context.tagName)){state.token=css;state.localState=cssMode.startState(htmlMode.indent(state.htmlState,""))}}return style}function maybeBackup(stream,pat,style){var cur=stream.current();var close=cur.search(pat),m;if(close>-1)stream.backUp(cur.length-close);else if(m=cur.match(/<\/?$/)){stream.backUp(cur.length);if(!stream.match(pat,false))stream.match(cur[0])}return style}function javascript(stream,state){if(stream.match(/^<\/\s*script\s*>/i,false)){state.token=html;state.localState=null;return html(stream,state)}return maybeBackup(stream,/<\/\s*script\s*>/,jsMode.token(stream,state.localState))}function css(stream,state){if(stream.match(/^<\/\s*style\s*>/i,false)){state.token=html;state.localState=null;return html(stream,state)}return maybeBackup(stream,/<\/\s*style\s*>/,cssMode.token(stream,state.localState))}return{startState:function(){var state=htmlMode.startState();return{token:html,localState:null,mode:"html",htmlState:state}},copyState:function(state){if(state.localState)var local=CodeMirror.copyState(state.token==css?cssMode:jsMode,state.localState);return{token:state.token,localState:local,mode:state.mode,htmlState:CodeMirror.copyState(htmlMode,state.htmlState)}},token:function(stream,state){return state.token(stream,state)},indent:function(state,textAfter){if(state.token==html||/^\s*<\//.test(textAfter))return htmlMode.indent(state.htmlState,textAfter);else if(state.token==javascript)return jsMode.indent(state.localState,textAfter);else return cssMode.indent(state.localState,textAfter)},electricChars:"/{}:",innerMode:function(state){var mode=state.token==html?htmlMode:state.token==javascript?jsMode:cssMode;return{state:state.localState||state.htmlState,mode:mode}}}},"xml","javascript","css");CodeMirror.defineMIME("text/html","htmlmixed");CodeMirror.defineMode("javascript",function(config,parserConfig){var indentUnit=config.indentUnit;var jsonMode=parserConfig.json;var isTS=parserConfig.typescript;var keywords=function(){function kw(type){return{type:type,style:"keyword"}}var A=kw("keyword a"),B=kw("keyword b"),C=kw("keyword c");var operator=kw("operator"),atom={type:"atom",style:"atom"};var jsKeywords={"if":A,"while":A,"with":A,"else":B,"do":B,"try":B,"finally":B,"return":C,"break":C,"continue":C,"new":C,"delete":C,"throw":C,"var":kw("var"),"const":kw("var"),let:kw("var"),"function":kw("function"),"catch":kw("catch"),"for":kw("for"),"switch":kw("switch"),"case":kw("case"),"default":kw("default"),"in":operator,"typeof":operator,"instanceof":operator,"true":atom,"false":atom,"null":atom,undefined:atom,NaN:atom,Infinity:atom};if(isTS){var type={type:"variable",style:"variable-3"};var tsKeywords={"interface":kw("interface"),"class":kw("class"),"extends":kw("extends"),constructor:kw("constructor"),"public":kw("public"),"private":kw("private"),"protected":kw("protected"),"static":kw("static"),"super":kw("super"),string:type,number:type,bool:type,any:type};for(var attr in tsKeywords){jsKeywords[attr]=tsKeywords[attr]}}return jsKeywords}();var isOperatorChar=/[+\-*&%=<>!?|]/;function chain(stream,state,f){state.tokenize=f;return f(stream,state)}function nextUntilUnescaped(stream,end){var escaped=false,next;while((next=stream.next())!=null){if(next==end&&!escaped)return false;escaped=!escaped&&next=="\\"}return escaped}var type,content;function ret(tp,style,cont){type=tp;content=cont;return style}function jsTokenBase(stream,state){var ch=stream.next();if(ch=='"'||ch=="'")return chain(stream,state,jsTokenString(ch));else if(/[\[\]{}\(\),;\:\.]/.test(ch))return ret(ch);else if(ch=="0"&&stream.eat(/x/i)){stream.eatWhile(/[\da-f]/i);return ret("number","number")}else if(/\d/.test(ch)||ch=="-"&&stream.eat(/\d/)){stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);return ret("number","number")}else if(ch=="/"){if(stream.eat("*")){return chain(stream,state,jsTokenComment)}else if(stream.eat("/")){stream.skipToEnd();return ret("comment","comment")}else if(state.lastType=="operator"||state.lastType=="keyword c"||/^[\[{}\(,;:]$/.test(state.lastType)){nextUntilUnescaped(stream,"/");stream.eatWhile(/[gimy]/);return ret("regexp","string-2")}else{stream.eatWhile(isOperatorChar);return ret("operator",null,stream.current())}}else if(ch=="#"){stream.skipToEnd();return ret("error","error")}else if(isOperatorChar.test(ch)){stream.eatWhile(isOperatorChar);return ret("operator",null,stream.current())}else{stream.eatWhile(/[\w\$_]/);var word=stream.current(),known=keywords.propertyIsEnumerable(word)&&keywords[word];return known&&state.lastType!="."?ret(known.type,known.style,word):ret("variable","variable",word)}}function jsTokenString(quote){return function(stream,state){if(!nextUntilUnescaped(stream,quote))state.tokenize=jsTokenBase;return ret("string","string")}}function jsTokenComment(stream,state){var maybeEnd=false,ch;while(ch=stream.next()){if(ch=="/"&&maybeEnd){state.tokenize=jsTokenBase;break}maybeEnd=ch=="*"}return ret("comment","comment")}var atomicTypes={atom:true,number:true,variable:true,string:true,regexp:true};function JSLexical(indented,column,type,align,prev,info){this.indented=indented;this.column=column;this.type=type;this.prev=prev;this.info=info;if(align!=null)this.align=align}function inScope(state,varname){for(var v=state.localVars;v;v=v.next)if(v.name==varname)return true}function parseJS(state,style,type,content,stream){var cc=state.cc;cx.state=state;cx.stream=stream;cx.marked=null,cx.cc=cc;if(!state.lexical.hasOwnProperty("align"))state.lexical.align=true;while(true){var combinator=cc.length?cc.pop():jsonMode?expression:statement;if(combinator(type,content)){while(cc.length&&cc[cc.length-1].lex)cc.pop()();if(cx.marked)return cx.marked;if(type=="variable"&&inScope(state,content))return"variable-2";return style}}}var cx={state:null,column:null,marked:null,cc:null};function pass(){for(var i=arguments.length-1;i>=0;i--)cx.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return true}function register(varname){function inList(list){for(var v=list;v;v=v.next)if(v.name==varname)return true;return false}var state=cx.state;if(state.context){cx.marked="def";if(inList(state.localVars))return;state.localVars={name:varname,next:state.localVars}}else{if(inList(state.globalVars))return;state.globalVars={name:varname,next:state.globalVars}}}var defaultVars={name:"this",next:{name:"arguments"}};function pushcontext(){cx.state.context={prev:cx.state.context,vars:cx.state.localVars};cx.state.localVars=defaultVars}function popcontext(){cx.state.localVars=cx.state.context.vars;cx.state.context=cx.state.context.prev}function pushlex(type,info){var result=function(){var state=cx.state;state.lexical=new JSLexical(state.indented,cx.stream.column(),type,null,state.lexical,info)};result.lex=true;return result}function poplex(){var state=cx.state;if(state.lexical.prev){if(state.lexical.type==")")state.indented=state.lexical.indented;state.lexical=state.lexical.prev}}poplex.lex=true;function expect(wanted){return function expecting(type){if(type==wanted)return cont();else if(wanted==";")return pass();else return cont(arguments.callee)}}function statement(type){if(type=="var")return cont(pushlex("vardef"),vardef1,expect(";"),poplex);if(type=="keyword a")return cont(pushlex("form"),expression,statement,poplex);if(type=="keyword b")return cont(pushlex("form"),statement,poplex);if(type=="{")return cont(pushlex("}"),block,poplex);if(type==";")return cont();if(type=="function")return cont(functiondef);if(type=="for")return cont(pushlex("form"),expect("("),pushlex(")"),forspec1,expect(")"),poplex,statement,poplex);if(type=="variable")return cont(pushlex("stat"),maybelabel);if(type=="switch")return cont(pushlex("form"),expression,pushlex("}","switch"),expect("{"),block,poplex,poplex);if(type=="case")return cont(expression,expect(":"));if(type=="default")return cont(expect(":")); +if(type=="catch")return cont(pushlex("form"),pushcontext,expect("("),funarg,expect(")"),statement,poplex,popcontext);return pass(pushlex("stat"),expression,expect(";"),poplex)}function expression(type){if(atomicTypes.hasOwnProperty(type))return cont(maybeoperator);if(type=="function")return cont(functiondef);if(type=="keyword c")return cont(maybeexpression);if(type=="(")return cont(pushlex(")"),maybeexpression,expect(")"),poplex,maybeoperator);if(type=="operator")return cont(expression);if(type=="[")return cont(pushlex("]"),commasep(expression,"]"),poplex,maybeoperator);if(type=="{")return cont(pushlex("}"),commasep(objprop,"}"),poplex,maybeoperator);return cont()}function maybeexpression(type){if(type.match(/[;\}\)\],]/))return pass();return pass(expression)}function maybeoperator(type,value){if(type=="operator"&&/\+\+|--/.test(value))return cont(maybeoperator);if(type=="operator"&&value=="?")return cont(expression,expect(":"),expression);if(type==";")return;if(type=="(")return cont(pushlex(")"),commasep(expression,")"),poplex,maybeoperator);if(type==".")return cont(property,maybeoperator);if(type=="[")return cont(pushlex("]"),expression,expect("]"),poplex,maybeoperator)}function maybelabel(type){if(type==":")return cont(poplex,statement);return pass(maybeoperator,expect(";"),poplex)}function property(type){if(type=="variable"){cx.marked="property";return cont()}}function objprop(type){if(type=="variable")cx.marked="property";if(atomicTypes.hasOwnProperty(type))return cont(expect(":"),expression)}function commasep(what,end){function proceed(type){if(type==",")return cont(what,proceed);if(type==end)return cont();return cont(expect(end))}return function commaSeparated(type){if(type==end)return cont();else return pass(what,proceed)}}function block(type){if(type=="}")return cont();return pass(statement,block)}function maybetype(type){if(type==":")return cont(typedef);return pass()}function typedef(type){if(type=="variable"){cx.marked="variable-3";return cont()}return pass()}function vardef1(type,value){if(type=="variable"){register(value);return isTS?cont(maybetype,vardef2):cont(vardef2)}return pass()}function vardef2(type,value){if(value=="=")return cont(expression,vardef2);if(type==",")return cont(vardef1)}function forspec1(type){if(type=="var")return cont(vardef1,expect(";"),forspec2);if(type==";")return cont(forspec2);if(type=="variable")return cont(formaybein);return cont(forspec2)}function formaybein(type,value){if(value=="in")return cont(expression);return cont(maybeoperator,forspec2)}function forspec2(type,value){if(type==";")return cont(forspec3);if(value=="in")return cont(expression);return cont(expression,expect(";"),forspec3)}function forspec3(type){if(type!=")")cont(expression)}function functiondef(type,value){if(type=="variable"){register(value);return cont(functiondef)}if(type=="(")return cont(pushlex(")"),pushcontext,commasep(funarg,")"),poplex,statement,popcontext)}function funarg(type,value){if(type=="variable"){register(value);return isTS?cont(maybetype):cont()}}return{startState:function(basecolumn){return{tokenize:jsTokenBase,lastType:null,cc:[],lexical:new JSLexical((basecolumn||0)-indentUnit,0,"block",false),localVars:parserConfig.localVars,globalVars:parserConfig.globalVars,context:parserConfig.localVars&&{vars:parserConfig.localVars},indented:0}},token:function(stream,state){if(stream.sol()){if(!state.lexical.hasOwnProperty("align"))state.lexical.align=false;state.indented=stream.indentation()}if(stream.eatSpace())return null;var style=state.tokenize(stream,state);if(type=="comment")return style;state.lastType=type;return parseJS(state,style,type,content,stream)},indent:function(state,textAfter){if(state.tokenize==jsTokenComment)return CodeMirror.Pass;if(state.tokenize!=jsTokenBase)return 0;var firstChar=textAfter&&textAfter.charAt(0),lexical=state.lexical;if(lexical.type=="stat"&&firstChar=="}")lexical=lexical.prev;var type=lexical.type,closing=firstChar==type;if(type=="vardef")return lexical.indented+(state.lastType=="operator"||state.lastType==","?4:0);else if(type=="form"&&firstChar=="{")return lexical.indented;else if(type=="form")return lexical.indented+indentUnit;else if(type=="stat")return lexical.indented+(state.lastType=="operator"||state.lastType==","?indentUnit:0);else if(lexical.info=="switch"&&!closing)return lexical.indented+(/^(?:case|default)\b/.test(textAfter)?indentUnit:2*indentUnit);else if(lexical.align)return lexical.column+(closing?0:1);else return lexical.indented+(closing?0:indentUnit)},electricChars:":{}",jsonMode:jsonMode}});CodeMirror.defineMIME("text/javascript","javascript");CodeMirror.defineMIME("text/ecmascript","javascript");CodeMirror.defineMIME("application/javascript","javascript");CodeMirror.defineMIME("application/ecmascript","javascript");CodeMirror.defineMIME("application/json",{name:"javascript",json:true});CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:true});CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:true});CodeMirror.defineMode("xml",function(config,parserConfig){var indentUnit=config.indentUnit;var Kludges=parserConfig.htmlMode?{autoSelfClosers:{area:true,base:true,br:true,col:true,command:true,embed:true,frame:true,hr:true,img:true,input:true,keygen:true,link:true,meta:true,param:true,source:true,track:true,wbr:true},implicitlyClosed:{dd:true,li:true,optgroup:true,option:true,p:true,rp:true,rt:true,tbody:true,td:true,tfoot:true,th:true,tr:true},contextGrabbers:{dd:{dd:true,dt:true},dt:{dd:true,dt:true},li:{li:true},option:{option:true,optgroup:true},optgroup:{optgroup:true},p:{address:true,article:true,aside:true,blockquote:true,dir:true,div:true,dl:true,fieldset:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,menu:true,nav:true,ol:true,p:true,pre:true,section:true,table:true,ul:true},rp:{rp:true,rt:true},rt:{rp:true,rt:true},tbody:{tbody:true,tfoot:true},td:{td:true,th:true},tfoot:{tbody:true},th:{td:true,th:true},thead:{tbody:true,tfoot:true},tr:{tr:true}},doNotIndent:{pre:true},allowUnquoted:true,allowMissing:true}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:false,allowMissing:false};var alignCDATA=parserConfig.alignCDATA;var tagName,type;function inText(stream,state){function chain(parser){state.tokenize=parser;return parser(stream,state)}var ch=stream.next();if(ch=="<"){if(stream.eat("!")){if(stream.eat("[")){if(stream.match("CDATA["))return chain(inBlock("atom","]]>"));else return null}else if(stream.match("--"))return chain(inBlock("comment","-->"));else if(stream.match("DOCTYPE",true,true)){stream.eatWhile(/[\w\._\-]/);return chain(doctype(1))}else return null}else if(stream.eat("?")){stream.eatWhile(/[\w\._\-]/);state.tokenize=inBlock("meta","?>");return"meta"}else{var isClose=stream.eat("/");tagName="";var c;while(c=stream.eat(/[^\s\u00a0=<>\"\'\/?]/))tagName+=c;if(!tagName)return"error";type=isClose?"closeTag":"openTag";state.tokenize=inTag;return"tag"}}else if(ch=="&"){var ok;if(stream.eat("#")){if(stream.eat("x")){ok=stream.eatWhile(/[a-fA-F\d]/)&&stream.eat(";")}else{ok=stream.eatWhile(/[\d]/)&&stream.eat(";")}}else{ok=stream.eatWhile(/[\w\.\-:]/)&&stream.eat(";")}return ok?"atom":"error"}else{stream.eatWhile(/[^&<]/);return null}}function inTag(stream,state){var ch=stream.next();if(ch==">"||ch=="/"&&stream.eat(">")){state.tokenize=inText;type=ch==">"?"endTag":"selfcloseTag";return"tag"}else if(ch=="="){type="equals";return null}else if(/[\'\"]/.test(ch)){state.tokenize=inAttribute(ch);return state.tokenize(stream,state)}else{stream.eatWhile(/[^\s\u00a0=<>\"\']/);return"word"}}function inAttribute(quote){return function(stream,state){while(!stream.eol()){if(stream.next()==quote){state.tokenize=inTag;break}}return"string"}}function inBlock(style,terminator){return function(stream,state){while(!stream.eol()){if(stream.match(terminator)){state.tokenize=inText;break}stream.next()}return style}}function doctype(depth){return function(stream,state){var ch;while((ch=stream.next())!=null){if(ch=="<"){state.tokenize=doctype(depth+1);return state.tokenize(stream,state)}else if(ch==">"){if(depth==1){state.tokenize=inText;break}else{state.tokenize=doctype(depth-1);return state.tokenize(stream,state)}}}return"meta"}}var curState,setStyle;function pass(){for(var i=arguments.length-1;i>=0;i--)curState.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return true}function pushContext(tagName,startOfLine){var noIndent=Kludges.doNotIndent.hasOwnProperty(tagName)||curState.context&&curState.context.noIndent;curState.context={prev:curState.context,tagName:tagName,indent:curState.indented,startOfLine:startOfLine,noIndent:noIndent}}function popContext(){if(curState.context)curState.context=curState.context.prev}function element(type){if(type=="openTag"){curState.tagName=tagName;return cont(attributes,endtag(curState.startOfLine))}else if(type=="closeTag"){var err=false;if(curState.context){if(curState.context.tagName!=tagName){if(Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())){popContext()}err=!curState.context||curState.context.tagName!=tagName}}else{err=true}if(err)setStyle="error";return cont(endclosetag(err))}return cont()}function endtag(startOfLine){return function(type){if(type=="selfcloseTag"||type=="endTag"&&Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())){maybePopContext(curState.tagName.toLowerCase());return cont()}if(type=="endTag"){maybePopContext(curState.tagName.toLowerCase());pushContext(curState.tagName,startOfLine);return cont()}return cont()}}function endclosetag(err){return function(type){if(err)setStyle="error";if(type=="endTag"){popContext();return cont()}setStyle="error";return cont(arguments.callee)}}function maybePopContext(nextTagName){var parentTagName;while(true){if(!curState.context){return}parentTagName=curState.context.tagName.toLowerCase();if(!Kludges.contextGrabbers.hasOwnProperty(parentTagName)||!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)){return}popContext()}}function attributes(type){if(type=="word"){setStyle="attribute";return cont(attribute,attributes)}if(type=="endTag"||type=="selfcloseTag")return pass();setStyle="error";return cont(attributes)}function attribute(type){if(type=="equals")return cont(attvalue,attributes);if(!Kludges.allowMissing)setStyle="error";else if(type=="word")setStyle="attribute";return type=="endTag"||type=="selfcloseTag"?pass():cont()}function attvalue(type){if(type=="string")return cont(attvaluemaybe);if(type=="word"&&Kludges.allowUnquoted){setStyle="string";return cont()}setStyle="error";return type=="endTag"||type=="selfCloseTag"?pass():cont()}function attvaluemaybe(type){if(type=="string")return cont(attvaluemaybe);else return pass()}return{startState:function(){return{tokenize:inText,cc:[],indented:0,startOfLine:true,tagName:null,context:null}},token:function(stream,state){if(stream.sol()){state.startOfLine=true;state.indented=stream.indentation()}if(stream.eatSpace())return null;setStyle=type=tagName=null;var style=state.tokenize(stream,state);state.type=type;if((style||type)&&style!="comment"){curState=state;while(true){var comb=state.cc.pop()||element;if(comb(type||style))break}}state.startOfLine=false;return setStyle||style},indent:function(state,textAfter,fullLine){var context=state.context;if(state.tokenize!=inTag&&state.tokenize!=inText||context&&context.noIndent)return fullLine?fullLine.match(/^(\s*)/)[0].length:0;if(alignCDATA&&/ 0 ? this : null; + }, + + findAndSelf: function(selector) { + return this.find(selector).add(this.filter(selector)); + } +}); + +// Little Helpers + +function hyphenate(str) { + return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); +} + +function isVisible(el) { + if (el.is(':hidden')) + return false; + var viewTop = $(window).scrollTop(); + var viewBottom = viewTop + $(window).height(); + var top = el.offset().top; + var bottom = top + el.height(); + return top >= viewTop && bottom <= viewBottom + || top <= viewTop && bottom >= viewTop + || top <= viewBottom && bottom >= viewBottom; +} + +function smoothScrollTo(el, callback) { + $('html, body').animate({ + scrollTop: el.offset().top + }, 250, callback); +} + +var behaviors = {}; + +behaviors.hiDPI = function() { + // Turn off hiDPI for all touch devices for now, until the site is built + // true to scale. + if ($.support.touch) + $('canvas').attr('hidpi', 'off'); +}; + +behaviors.sections = function() { + var toc = $('.toc'); + var checks = []; + var active; + + function update() { + $.each(checks, function() { + if (this()) + return false; + }); + } + + $(document).scroll(update); + $(window).resize(update); + setTimeout(update, 0); + + $('article section').each(function() { + var section = $(this); + var anchor = $('a', section); + // Move content until next section inside section + section.append(section.nextUntil('section')); + var title = anchor.attr('title') || $('h1,h2', section).first().text(); + var id = section.attr('id'); + if (!id) { + id = hyphenate(title) + .replace(/\s+/g, '-') + .replace(/^#/, '') + .replace(/[!"#$%&'\()*+,.\/:;<=>?@\[\\\]\^_`{|}~]+/g, '-') + .replace(/-+/g, '-'); + section.attr('id', id); + anchor.attr('name', id); + } + + function activate() { + if (active) + active.removeClass('active'); + selector.addClass('active'); + active = selector; + } + + // Create table of contents on the fly + if (toc) { + var selector = $('
  • ' + + title + '
  • ').appendTo(toc); + if (section.is('.spacer')) + selector.addClass('spacer'); + $('a', selector).click(function() { + smoothScrollTo(section, function() { + window.location.hash = id; + }); + return false; + }); + + checks.push(function() { + var visible = isVisible(section); + if (visible) + activate(); + return visible; + }); + } + }); + + // Adjust height of last section so that the last anchor aligns perfectly + // with the top of the browser window. + var lastSection = $('article section:last'); + var lastAnchor = $('a[name]', lastSection); + + function resize() { + lastSection.height('auto'); + var bottom = $(document).height() - lastAnchor.offset().top - $(window).height(); + if (bottom < 0) + lastSection.height(lastSection.height() - bottom); + } + + if (lastSection.length && lastAnchor.length) { + $(window).on({ + load: resize, + resize: resize + }); + resize(); + } +}; + +behaviors.sticky = function() { + $('.sticky').each(function() { + me = $(this); + container = $('
    ').append(me.contents()).appendTo(me); + // Insert a div wrapper of which the fixed class is modified depending on position + $(window).scroll(function() { + if (container.is(':visible')) + container.toggleClass('fixed', me.offset().top - $(this).scrollTop() <= 0); + }); + }); +}; + +behaviors.hash = function() { + var hash = unescape(window.location.hash); + if (hash) { + // First see if there's a class member to open + var target = $(hash); + if (target.length) { + if (target.hasClass('member')) + toggleMember(target); + smoothScrollTo(target); + } + } +}; + +behaviors.thumbnails = function() { + var thumbnails = $('.thumbnail'); + var height = 0; + thumbnails.each(function() { + height = Math.max(height, $(this).height()); + }); + $('.thumbnail').height(height); +}; + +behaviors.expandableLists = function() { + $('.expandable-list').each(function() { + var list = $(this); + $('') + .prependTo(list) + .click(function() { + list.toggleClass('expanded'); + }); + }); +}; + +behaviors.referenceClass = function() { + var classes = $('.reference-classes'); + if (classes.length) { + // Mark currently selected class as active. Do it client-sided + // since the menu is generated by jsdocs. + var path = window.location.pathname.toLowerCase(); + $('a[href="' + path + '"]', classes).addClass('active'); + } +}; + +behaviors.hover = function() { + $('.hover').hover(function() { + $('.normal', this).toggleClass('hidden'); + $('.over', this).toggleClass('hidden'); + }); +}; + +behaviors.code = function() { + $('.code:visible, pre:visible code').each(function() { + createCode($(this)); + }); +}; + +behaviors.paperscript = function() { + // Ignore all paperscripts in the automatic load event, and load them + // separately in createPaperScript() when needed. + $('script[type="text/paperscript"]').attr('ignore', 'true'); + $('.paperscript:visible').each(function() { + createPaperScript($(this)); + }); +}; + +function createCodeMirror(place, options, source) { + return new CodeMirror(place, $.extend({}, { + mode: 'javascript', + lineNumbers: true, + matchBrackets: true, + tabSize: 4, + indentUnit: 4, + indentWithTabs: true, + tabMode: 'shift', + value: source.text().match( + // Remove first & last empty line + /^\s*?[\n\r]?([\u0000-\uffff]*?)[\n\r]?\s*?$/)[1] + }, options)); +} + +function createCode(element) { + if (element.data('initialized')) + return; + var start = element.attr('start'); + var highlight = element.attr('highlight'); + var editor = createCodeMirror(function(el) { + element.replaceWith(el); + }, { + lineNumbers: !element.parent('.resource-text').length, + firstLineNumber: parseInt(start || 1, 10), + mode: element.attr('mode') || 'javascript', + readOnly: true + }, element); + if (highlight) { + var highlights = highlight.split(','); + for (var i = 0, l = highlights.length; i < l; i++) { + var highlight = highlights[i].split('-'); + var hlStart = parseInt(highlight[0], 10) - 1; + var hlEnd = highlight.length == 2 + ? parseInt(highlight[1], 10) - 1 : hlStart; + if (start) { + hlStart -= start - 1; + hlEnd -= start - 1; + } + for (var j = hlStart; j <= hlEnd; j++) { + editor.setLineClass(j, 'highlight'); + } + } + } + element.data('initialized', true); +} + +function createPaperScript(element) { + if (element.data('initialized')) + return; + + var script = $('script', element).orNull(), + runButton = $('.button.run', element).orNull(); + if (!script) + return; + // Now load / parse / execute the script + script.removeAttr('ignore'); + var scope = paper.PaperScript.load(script[0]); + if (!runButton) + return; + + var canvas = $('canvas', element), + hasResize = canvas.attr('resize'), + showSplit = element.hasClass('split'), + sourceFirst = element.hasClass('source'), + editor = null, + hasBorders = true, + edited = false, + animateExplain, + explain = $('.explain', element).orNull(), + source = $('