Merge branch 'storageareas' of github.com:/ConnorTechnology/ZoneMinder into storageareas

This commit is contained in:
Isaac Connor 2017-05-19 13:49:57 -04:00
commit 4dc5f0060f
46 changed files with 2055 additions and 2818 deletions

View File

@ -331,12 +331,12 @@ function getVideoStreamHTML( $id, $src, $width, $height, $format, $title="" ) {
</embed>'; </embed>';
} }
function outputImageStream( $id, $src, $width, $height, $title="" ) { function outputImageStream( $id, $src, $width, $height, $title='' ) {
echo getImageStream( $id, $src, $width, $height, $title ); echo getImageStream( $id, $src, $width, $height, $title );
} }
function getImageStream( $id, $src, $width, $height, $title="" ) { function getImageStream( $id, $src, $width, $height, $title='' ) {
if ( canStreamIframe() ) { if ( canStreamIframe() ) {
return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>'; return '<iframe id="'.$id.'" src="'.$src.'" alt="'. validHtmlStr($title) .'" '.($width? ' width="'. validInt($width).'"' : '').($height?' height="'.validInt($height).'"' : '' ).'/>';
} else { } else {

View File

@ -175,9 +175,9 @@ foreach ( getSkinIncludes( 'skin.php' ) as $includeFile )
if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) { if ( ZM_OPT_USE_AUTH && ZM_AUTH_HASH_LOGINS ) {
if ( empty($user) && ! empty($_REQUEST['auth']) ) { if ( empty($user) && ! empty($_REQUEST['auth']) ) {
Debug("Getting user from auth hash"); Logger::Debug("Getting user from auth hash");
if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) { if ( $authUser = getAuthUser( $_REQUEST['auth'] ) ) {
Debug("Success Getting user from auth hash"); Logger::Debug("Success Getting user from auth hash");
userLogin( $authUser['Username'], $authUser['Password'], true ); userLogin( $authUser['Username'], $authUser['Password'], true );
} }
} else if ( ! empty($user) ) { } else if ( ! empty($user) ) {
@ -205,7 +205,7 @@ require_once( 'includes/actions.php' );
# If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in. # If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in.
if ( ZM_OPT_USE_AUTH && ! isset($user) ) { if ( ZM_OPT_USE_AUTH && ! isset($user) ) {
Debug("Redirecting to login" ); Logger::Debug("Redirecting to login" );
$view = 'login'; $view = 'login';
} }

View File

@ -45,11 +45,11 @@
*/ */
.ptzControls .controlsPanel .upBtn { .ptzControls .controlsPanel .upBtn {
background: url("../../graphics/arrow-l-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .downBtn { .ptzControls .controlsPanel .downBtn {
background: url("../../graphics/arrow-l-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .focusControls { .ptzControls .controlsPanel .focusControls {
@ -92,39 +92,39 @@
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn {
background: url("../../graphics/arrow-ul.gif") no-repeat 0 0; background: url("../../graphics/arrow-ul.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn {
background: url("../../graphics/arrow-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn {
background: url("../../graphics/arrow-ur.gif") no-repeat 0 0; background: url("../../graphics/arrow-ur.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn {
background: url("../../graphics/arrow-l.gif") no-repeat 0 0; background: url("../../graphics/arrow-l.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn {
background: url("../../graphics/center.gif") no-repeat 0 0; background: url("../../graphics/center.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn {
background: url("../../graphics/arrow-r.gif") no-repeat 0 0; background: url("../../graphics/arrow-r.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn {
background: url("../../graphics/arrow-dl.gif") no-repeat 0 0; background: url("../../graphics/arrow-dl.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn {
background: url("../../graphics/arrow-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn {
background: url("../../graphics/arrow-dr.gif") no-repeat 0 0; background: url("../../graphics/arrow-dr.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .powerControls { .ptzControls .controlsPanel .powerControls {

View File

@ -45,11 +45,11 @@
*/ */
.ptzControls .controlsPanel .upBtn { .ptzControls .controlsPanel .upBtn {
background: url("../../graphics/arrow-l-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .downBtn { .ptzControls .controlsPanel .downBtn {
background: url("../../graphics/arrow-l-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .focusControls { .ptzControls .controlsPanel .focusControls {
@ -92,39 +92,39 @@
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn {
background: url("../../graphics/arrow-ul.gif") no-repeat 0 0; background: url("../../graphics/arrow-ul.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn {
background: url("../../graphics/arrow-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn {
background: url("../../graphics/arrow-ur.gif") no-repeat 0 0; background: url("../../graphics/arrow-ur.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn {
background: url("../../graphics/arrow-l.gif") no-repeat 0 0; background: url("../../graphics/arrow-l.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn {
background: url("../../graphics/center.gif") no-repeat 0 0; background: url("../../graphics/center.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn {
background: url("../../graphics/arrow-r.gif") no-repeat 0 0; background: url("../../graphics/arrow-r.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn {
background: url("../../graphics/arrow-dl.gif") no-repeat 0 0; background: url("../../graphics/arrow-dl.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn {
background: url("../../graphics/arrow-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn {
background: url("../../graphics/arrow-dr.gif") no-repeat 0 0; background: url("../../graphics/arrow-dr.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .powerControls { .ptzControls .controlsPanel .powerControls {

View File

@ -45,11 +45,11 @@
*/ */
.ptzControls .controlsPanel .upBtn { .ptzControls .controlsPanel .upBtn {
background: url("../../graphics/arrow-l-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .downBtn { .ptzControls .controlsPanel .downBtn {
background: url("../../graphics/arrow-l-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-l-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .focusControls { .ptzControls .controlsPanel .focusControls {
@ -92,39 +92,39 @@
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upLeftBtn {
background: url("../../graphics/arrow-ul.gif") no-repeat 0 0; background: url("../../graphics/arrow-ul.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upBtn {
background: url("../../graphics/arrow-u.gif") no-repeat 0 0; background: url("../../graphics/arrow-u.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .upRightBtn {
background: url("../../graphics/arrow-ur.gif") no-repeat 0 0; background: url("../../graphics/arrow-ur.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .leftBtn {
background: url("../../graphics/arrow-l.gif") no-repeat 0 0; background: url("../../graphics/arrow-l.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .centerBtn {
background: url("../../graphics/center.gif") no-repeat 0 0; background: url("../../graphics/center.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .rightBtn {
background: url("../../graphics/arrow-r.gif") no-repeat 0 0; background: url("../../graphics/arrow-r.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downLeftBtn {
background: url("../../graphics/arrow-dl.gif") no-repeat 0 0; background: url("../../graphics/arrow-dl.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downBtn {
background: url("../../graphics/arrow-d.gif") no-repeat 0 0; background: url("../../graphics/arrow-d.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn { .ptzControls .controlsPanel .pantiltPanel .pantiltControls .downRightBtn {
background: url("../../graphics/arrow-dr.gif") no-repeat 0 0; background: url("../../graphics/arrow-dr.png") no-repeat 0 0;
} }
.ptzControls .controlsPanel .powerControls { .ptzControls .controlsPanel .powerControls {

View File

@ -10,8 +10,9 @@ table.filterTable {
} }
#fieldsTable input[type=button] { #fieldsTable input[type=button] {
width: 1.6em; width: 1.8em;
margin-left: 2px; margin-left: 2px;
padding: 5px;
text-align: center; text-align: center;
} }

View File

@ -22,8 +22,7 @@
// Don't load in additional JS to these views // Don't load in additional JS to these views
$bad_views = array('monitor', 'log'); $bad_views = array('monitor', 'log');
function xhtmlHeaders( $file, $title ) function xhtmlHeaders( $file, $title ) {
{
global $css; global $css;
global $skin; global $skin;
$skinCssFile = getSkinFile( 'css/'.$css.'/skin.css' ); $skinCssFile = getSkinFile( 'css/'.$css.'/skin.css' );
@ -55,14 +54,12 @@ function xhtmlHeaders( $file, $title )
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/> <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="<?php echo $skinCssFile ?>" type="text/css" media="screen"/> <link rel="stylesheet" href="<?php echo $skinCssFile ?>" type="text/css" media="screen"/>
<?php <?php
if ( $viewCssFile ) if ( $viewCssFile ) {
{
?> ?>
<link rel="stylesheet" href="<?php echo $viewCssFile ?>" type="text/css" media="screen"/> <link rel="stylesheet" href="<?php echo $viewCssFile ?>" type="text/css" media="screen"/>
<?php <?php
} }
if ( $viewCssPhpFile ) if ( $viewCssPhpFile ) {
{
?> ?>
<style type="text/css"> <style type="text/css">
/*<![CDATA[*/ /*<![CDATA[*/
@ -98,14 +95,12 @@ var $j = jQuery.noConflict();
<script src='https://www.google.com/recaptcha/api.js'></script> <script src='https://www.google.com/recaptcha/api.js'></script>
<?php } else if ( $title == 'Event' ) { <?php } else if ( $title == 'Event' ) {
?> ?>
<link href="skins/<?php echo $skin ?>/js/video-js.css" rel="stylesheet"> <link href="skins/<?php echo $skin ?>/js/video-js.css" rel="stylesheet">
<script src="skins/<?php echo $skin ?>/js/video.js"></script> <script src="skins/<?php echo $skin ?>/js/video.js"></script>
<script src="./js/videojs.zoomrotate.js"></script> <script src="./js/videojs.zoomrotate.js"></script>
<script src="skins/<?php echo $skin ?>/js/moment.min.js"></script> <script src="skins/<?php echo $skin ?>/js/moment.min.js"></script>
<?php <?php }
} if ( $skinJsPhpFile ) {
if ( $skinJsPhpFile )
{
?> ?>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
@ -118,8 +113,7 @@ var $j = jQuery.noConflict();
</script> </script>
<?php <?php
} }
if ( $viewJsPhpFile ) if ( $viewJsPhpFile ) {
{
?> ?>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
@ -139,8 +133,7 @@ var $j = jQuery.noConflict();
<script type="text/javascript" src="<?php echo $skinJsFile ?>"></script> <script type="text/javascript" src="<?php echo $skinJsFile ?>"></script>
<script type="text/javascript" src="js/logger.js"></script> <script type="text/javascript" src="js/logger.js"></script>
<?php <?php
if ( $viewJsFile ) if ( $viewJsFile ) {
{
?> ?>
<script type="text/javascript" src="<?php echo $viewJsFile ?>"></script> <script type="text/javascript" src="<?php echo $viewJsFile ?>"></script>
<?php <?php

View File

@ -19,8 +19,8 @@
// //
if ( !canView( 'Events' ) ) { if ( !canView( 'Events' ) ) {
$view = 'error'; $view = 'error';
return; return;
} }
$eid = validInt( $_REQUEST['eid'] ); $eid = validInt( $_REQUEST['eid'] );
@ -37,9 +37,9 @@ if ( $user['MonitorIds'] ) {
} }
if ( isset( $_REQUEST['rate'] ) ) if ( isset( $_REQUEST['rate'] ) )
$rate = validInt($_REQUEST['rate']); $rate = validInt($_REQUEST['rate']);
else else
$rate = reScale( RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE ); $rate = reScale( RATE_BASE, $Monitor->DefaultRate(), ZM_WEB_DEFAULT_RATE );
if ( isset( $_REQUEST['scale'] ) ) { if ( isset( $_REQUEST['scale'] ) ) {
$scale = validInt($_REQUEST['scale']); $scale = validInt($_REQUEST['scale']);
@ -56,14 +56,14 @@ $replayModes = array(
); );
if ( isset( $_REQUEST['streamMode'] ) ) if ( isset( $_REQUEST['streamMode'] ) )
$streamMode = validHtmlStr($_REQUEST['streamMode']); $streamMode = validHtmlStr($_REQUEST['streamMode']);
else else
$streamMode = 'video'; $streamMode = 'video';
if ( isset( $_REQUEST['replayMode'] ) ) if ( isset( $_REQUEST['replayMode'] ) )
$replayMode = validHtmlStr($_REQUEST['replayMode']); $replayMode = validHtmlStr($_REQUEST['replayMode']);
if ( isset( $_COOKIE['replayMode']) && preg_match('#^[a-z]+$#', $_COOKIE['replayMode']) ) if ( isset( $_COOKIE['replayMode']) && preg_match('#^[a-z]+$#', $_COOKIE['replayMode']) )
$replayMode = validHtmlStr($_COOKIE['replayMode']); $replayMode = validHtmlStr($_COOKIE['replayMode']);
else { else {
$keys = array_keys( $replayModes ); $keys = array_keys( $replayModes );
$replayMode = array_shift( $keys ); $replayMode = array_shift( $keys );
@ -73,10 +73,10 @@ else {
$Zoom = 1; $Zoom = 1;
$Rotation = 0; $Rotation = 0;
if ( $Monitor->VideoWriter() == '2' ) { if ( $Monitor->VideoWriter() == '2' ) {
# Passthrough # Passthrough
$Rotation = $Event->Orientation(); $Rotation = $Event->Orientation();
if ( in_array($Event->Orientation(),array('90','270')) ) if ( in_array($Event->Orientation(),array('90','270')) )
$Zoom = $Event->Height()/$Event->Width(); $Zoom = $Event->Height()/$Event->Width();
} }
parseSort(); parseSort();
@ -127,7 +127,8 @@ if ( canEdit( 'Events' ) ) {
<div id="editEvent"><a href="#" onclick="editEvent()"><?php echo translate('Edit') ?></a></div> <div id="editEvent"><a href="#" onclick="editEvent()"><?php echo translate('Edit') ?></a></div>
<div id="archiveEvent" class="hidden"><a href="#" onclick="archiveEvent()"><?php echo translate('Archive') ?></a></div> <div id="archiveEvent" class="hidden"><a href="#" onclick="archiveEvent()"><?php echo translate('Archive') ?></a></div>
<div id="unarchiveEvent" class="hidden"><a href="#" onclick="unarchiveEvent()"><?php echo translate('Unarchive') ?></a></div> <div id="unarchiveEvent" class="hidden"><a href="#" onclick="unarchiveEvent()"><?php echo translate('Unarchive') ?></a></div>
<?php if ( $Event->DefaultVideo() ) { ?> <?php
if ( $Event->DefaultVideo() ) { ?>
<div id="downloadEventFile"><a href="<?php echo $Event->getStreamSrc()?>">Download MP4</a></div> <div id="downloadEventFile"><a href="<?php echo $Event->getStreamSrc()?>">Download MP4</a></div>
<?php <?php
} // end if Event->DefaultVideo } // end if Event->DefaultVideo
@ -169,15 +170,15 @@ if ( $Event->DefaultVideo() ) {
<div id="imageFeed" <?php if ( $Event->DefaultVideo() ) { ?>class="hidden"<?php } ?> > <div id="imageFeed" <?php if ( $Event->DefaultVideo() ) { ?>class="hidden"<?php } ?> >
<?php <?php
if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) { if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
$streamSrc = getStreamSrc( array( "source=event", "mode=mpeg", "event=".$eid, "frame=".$fid, "scale=".$scale, "rate=".$rate, "bitrate=".ZM_WEB_VIDEO_BITRATE, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "format=".ZM_MPEG_REPLAY_FORMAT, "replay=".$replayMode ) ); $streamSrc = getStreamSrc( array( 'source=event', 'mode=mpeg', 'event='.$eid, 'frame='.$fid, 'scale='.$scale, 'rate='.$rate, 'bitrate='.ZM_WEB_VIDEO_BITRATE, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'format='.ZM_MPEG_REPLAY_FORMAT, 'replay='.$replayMode ) );
outputVideoStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), ZM_MPEG_LIVE_FORMAT ); outputVideoStream( 'evtStream', $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), ZM_MPEG_LIVE_FORMAT );
} else { } else {
$streamSrc = getStreamSrc( array( "source=event", "mode=jpeg", "event=".$eid, "frame=".$fid, "scale=".$scale, "rate=".$rate, "maxfps=".ZM_WEB_VIDEO_MAXFPS, "replay=".$replayMode) ); $streamSrc = getStreamSrc( array( 'source=event', 'mode=jpeg', 'event='.$eid, 'frame='.$fid, 'scale='.$scale, 'rate='.$rate, 'maxfps='.ZM_WEB_VIDEO_MAXFPS, 'replay='.$replayMode) );
if ( canStreamNative() ) { if ( canStreamNative() ) {
outputImageStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), validHtmlStr($Event->Name()) ); outputImageStream( 'evtStream', $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ), validHtmlStr($Event->Name()) );
} else { } else {
outputHelperStream( "evtStream", $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ) ); outputHelperStream( 'evtStream', $streamSrc, reScale( $Event->Width(), $scale ), reScale( $Event->Height(), $scale ) );
} }
} // end if stream method } // end if stream method
?> ?>
</div> </div>
@ -206,7 +207,7 @@ if ( ZM_WEB_STREAM_METHOD == 'mpeg' && ZM_MPEG_LIVE_FORMAT ) {
</div> </div>
</div> </div>
<?php <?php
if ($Event->SaveJPEGs() & 3) { // frames or analysis if ( $Event->SaveJPEGs() & 3 ) { // frames or analysis
?> ?>
<div id="eventStills" class="hidden"> <div id="eventStills" class="hidden">
<div id="eventThumbsPanel"> <div id="eventThumbsPanel">

View File

@ -1,96 +1,79 @@
var jsTranslatedAddText; var jsTranslatedAddText;
var jsTranslatedCloneText; var jsTranslatedCloneText;
function setButtonStates( element ) function setButtonStates( element ) {
{ var form = element.form;
var form = element.form; var checked = 0;
var checked = 0; for ( var i = 0; i < form.elements.length; i++ ) {
for ( var i = 0; i < form.elements.length; i++ ) if ( form.elements[i].type == "checkbox" ) {
{ if ( form.elements[i].checked ) {
if ( form.elements[i].type == "checkbox" ) if ( checked++ > 1 )
{ break;
if ( form.elements[i].checked ) }
{ }
if ( checked++ > 1 ) }
break; $(element).closest("tr").toggleClass("danger");
} form.editBtn.disabled = (checked!=1);
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText;
form.deleteBtn.disabled = (checked==0);
}
function addMonitor( element) {
var form = element.form;
var dupParam;
var monitorId=-1;
if (form.addBtn.value == jsTranslatedCloneText) {
// get the value of the first checkbox
for ( var i = 0; i < form.elements.length; i++ ) {
if ( form.elements[i].type == "checkbox" ) {
if ( form.elements[i].checked ) {
monitorId = form.elements[i].value;
break;
} }
}
} }
$(element).closest("tr").toggleClass("danger"); }
form.editBtn.disabled = (checked!=1); dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId;
form.addBtn.value = (checked==1) ? jsTranslatedCloneText:jsTranslatedAddText; createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' );
form.deleteBtn.disabled = (checked==0);
} }
function addMonitor( element) function editMonitor( element ) {
{ var form = element.form;
for ( var i = 0; i < form.elements.length; i++ ) {
if ( form.elements[i].type == "checkbox" ) {
if ( form.elements[i].checked ) {
var monitorId = form.elements[i].value;
createPopup( '?view=monitor&mid='+monitorId, 'zmMonitor'+monitorId, 'monitor' );
form.elements[i].checked = false;
setButtonStates( form.elements[i] );
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
break;
}
}
}
}
function deleteMonitor( element ) {
if ( confirm( 'Warning, deleting a monitor also deletes all events and database entries associated with it.\nAre you sure you wish to delete?' ) ) {
var form = element.form; var form = element.form;
var dupParam; form.elements['action'].value = 'delete';
var monitorId=-1; form.submit();
if (form.addBtn.value == jsTranslatedCloneText) }
{
// get the value of the first checkbox
for ( var i = 0; i < form.elements.length; i++ )
{
if ( form.elements[i].type == "checkbox" )
{
if ( form.elements[i].checked )
{
monitorId = form.elements[i].value;
break;
}
}
}
}
dupParam = (monitorId == -1 ) ? '': '&dupId='+monitorId;
createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' );
} }
function editMonitor( element ) function reloadWindow() {
{ window.location.replace( thisUrl );
var form = element.form;
for ( var i = 0; i < form.elements.length; i++ )
{
if ( form.elements[i].type == "checkbox" )
{
if ( form.elements[i].checked )
{
var monitorId = form.elements[i].value;
createPopup( '?view=monitor&mid='+monitorId, 'zmMonitor'+monitorId, 'monitor' );
form.elements[i].checked = false;
setButtonStates( form.elements[i] );
//$(form.elements[i]).getParent( 'tr' ).removeClass( 'highlight' );
break;
}
}
}
} }
function deleteMonitor( element ) function initPage() {
{ jsTranslatedAddText = translatedAddText;
if ( confirm( 'Warning, deleting a monitor also deletes all events and database entries associated with it.\nAre you sure you wish to delete?' ) ) jsTranslatedCloneText = translatedCloneText;
{ reloadWindow.periodical( consoleRefreshTimeout );
var form = element.form; if ( showVersionPopup )
form.elements['action'].value = 'delete'; createPopup( '?view=version', 'zmVersion', 'version' );
form.submit(); if ( showDonatePopup )
} createPopup( '?view=donate', 'zmDonate', 'donate' );
}
function reloadWindow()
{
window.location.replace( thisUrl );
}
function initPage()
{
jsTranslatedAddText = translatedAddText;
jsTranslatedCloneText = translatedCloneText;
reloadWindow.periodical( consoleRefreshTimeout );
if ( showVersionPopup )
createPopup( '?view=version', 'zmVersion', 'version' );
if ( showDonatePopup )
createPopup( '?view=donate', 'zmDonate', 'donate' );
} }
function applySort(event, ui) { function applySort(event, ui) {

View File

@ -1,27 +1,19 @@
var consoleRefreshTimeout = <?php echo 1000*ZM_WEB_REFRESH_MAIN ?>; var consoleRefreshTimeout = <?php echo 1000*ZM_WEB_REFRESH_MAIN ?>;
<?php <?php
if ( ZM_CHECK_FOR_UPDATES && canEdit('System') && ZM_DYN_LAST_VERSION && ( verNum(ZM_VERSION) < verNum(ZM_DYN_LAST_VERSION) ) && ( verNum(ZM_DYN_CURR_VERSION) < verNum(ZM_DYN_LAST_VERSION) ) && ( ZM_DYN_NEXT_REMINDER < time() ) ) if ( ZM_CHECK_FOR_UPDATES && canEdit('System') && ZM_DYN_LAST_VERSION && ( verNum(ZM_VERSION) < verNum(ZM_DYN_LAST_VERSION) ) && ( verNum(ZM_DYN_CURR_VERSION) < verNum(ZM_DYN_LAST_VERSION) ) && ( ZM_DYN_NEXT_REMINDER < time() ) ) {
{ $showVersionPopup = true;
$showVersionPopup = true; } elseif ( ZM_DYN_SHOW_DONATE_REMINDER ) {
} if ( canEdit('System') ) {
elseif ( ZM_DYN_SHOW_DONATE_REMINDER ) if ( ZM_DYN_DONATE_REMINDER_TIME > 0 ) {
{ if ( ZM_DYN_DONATE_REMINDER_TIME < time() ) {
if ( canEdit('System') ) $showDonatePopup = true;
{ }
if ( ZM_DYN_DONATE_REMINDER_TIME > 0 ) } else {
{ $nextReminder = time() + 30*24*60*60;
if ( ZM_DYN_DONATE_REMINDER_TIME < time() ) dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_DONATE_REMINDER_TIME'" );
{
$showDonatePopup = true;
}
}
else
{
$nextReminder = time() + 30*24*60*60;
dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_DONATE_REMINDER_TIME'" );
}
} }
}
} }
?> ?>
var showVersionPopup = <?php echo isset($showVersionPopup )?'true':'false' ?>; var showVersionPopup = <?php echo isset($showVersionPopup )?'true':'false' ?>;

View File

@ -1,49 +1,43 @@
var controlParms = "view=request&request=control"; var controlParms = "view=request&request=control";
var controlReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, onSuccess: getControlResponse } ); var controlReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, onSuccess: getControlResponse } );
function getControlResponse( respObj, respText ) function getControlResponse( respObj, respText ) {
{ if ( !respObj )
if ( !respObj ) return;
return; //console.log( respText );
//console.log( respText ); if ( respObj.result != 'Ok' ) {
if ( respObj.result != 'Ok' ) alert( "Control response was status = "+respObj.status+"\nmessage = "+respObj.message );
{ }
alert( "Control response was status = "+respObj.status+"\nmessage = "+respObj.message );
}
} }
function controlCmd( control, event, xtell, ytell ) function controlCmd( control, event, xtell, ytell ) {
{ var locParms = "&id="+$('mid').get('value');
var locParms = "&id="+$('mid').get('value'); if ( event && (xtell || ytell) ) {
if ( event && (xtell || ytell) ) var xEvent = new Event( event );
{ var target = xEvent.target;
var xEvent = new Event( event ); var coords = $(target).getCoordinates();
var target = xEvent.target;
var coords = $(target).getCoordinates();
var l = coords.left; var l = coords.left;
var t = coords.top; var t = coords.top;
var x = xEvent.page.x - l; var x = xEvent.page.x - l;
var y = xEvent.page.y - t; var y = xEvent.page.y - t;
if ( xtell ) if ( xtell ) {
{ var xge = parseInt( (x*100)/coords.width );
var xge = parseInt( (x*100)/coords.width ); if ( xtell == -1 )
if ( xtell == -1 ) xge = 100 - xge;
xge = 100 - xge; else if ( xtell == 2 )
else if ( xtell == 2 ) xge = 2*(50 - xge);
xge = 2*(50 - xge); locParms += "&xge="+xge;
locParms += "&xge="+xge;
}
if ( ytell )
{
var yge = parseInt( (y*100)/coords.height );
if ( ytell == -1 )
yge = 100 - yge;
else if ( ytell == 2 )
yge = 2*(50 - yge);
locParms += "&yge="+yge;
}
} }
controlReq.send( controlParms+"&control="+control+locParms ); if ( ytell ) {
var yge = parseInt( (y*100)/coords.height );
if ( ytell == -1 )
yge = 100 - yge;
else if ( ytell == 2 )
yge = 2*(50 - yge);
locParms += "&yge="+yge;
}
}
controlReq.send( controlParms+"&control="+control+locParms );
} }

View File

@ -1,23 +1,23 @@
function validateForm( form ) { function validateForm( form ) {
var errors = new Array(); var errors = new Array();
// If "Can Move" is enabled, then the end user must also select at least one of the other check boxes (excluding Can Move Diagonally) // If "Can Move" is enabled, then the end user must also select at least one of the other check boxes (excluding Can Move Diagonally)
if ( form.elements['newControl[CanMove]'].checked ) { if ( form.elements['newControl[CanMove]'].checked ) {
if ( !(form.elements['newControl[CanMoveCon]'].checked || form.elements['newControl[CanMoveRel]'].checked || form.elements['newControl[CanMoveAbs]'].checked || form.elements['newControl[CanMoveMap]'].checked) ) { if ( !(form.elements['newControl[CanMoveCon]'].checked || form.elements['newControl[CanMoveRel]'].checked || form.elements['newControl[CanMoveAbs]'].checked || form.elements['newControl[CanMoveMap]'].checked) ) {
errors[errors.length] = "In addition to \"Can Move\", you also must select at least one of: \"Can Move Mapped\", \"Can Move Absolute\", \"Can Move Relative\", or \"Can Move Continuous\""; errors[errors.length] = "In addition to \"Can Move\", you also must select at least one of: \"Can Move Mapped\", \"Can Move Absolute\", \"Can Move Relative\", or \"Can Move Continuous\"";
} }
} else { } else {
// Now lets check for the opposite condition. If any of the boxes below Can Move are checked, but Can Move is not checked then signal an error // Now lets check for the opposite condition. If any of the boxes below Can Move are checked, but Can Move is not checked then signal an error
if ( form.elements['newControl[CanMoveCon]'].checked || form.elements['newControl[CanMoveRel]'].checked || form.elements['newControl[CanMoveAbs]'].checked || form.elements['newControl[CanMoveMap]'].checked || form.elements['newControl[CanMoveDiag]'].checked ) { if ( form.elements['newControl[CanMoveCon]'].checked || form.elements['newControl[CanMoveRel]'].checked || form.elements['newControl[CanMoveAbs]'].checked || form.elements['newControl[CanMoveMap]'].checked || form.elements['newControl[CanMoveDiag]'].checked ) {
errors[errors.length] = "\"Can Move\" must also be selected if any one of the movement types are sleceted"; errors[errors.length] = "\"Can Move\" must also be selected if any one of the movement types are sleceted";
}
} }
}
if ( errors.length ) { if ( errors.length ) {
alert( errors.join( "\n" ) ); alert( errors.join( "\n" ) );
return( false ); return( false );
} }
return( true ); return( true );
} }

View File

@ -1,14 +1,10 @@
function updateLabel() function updateLabel() {
{ var presetIndex = $('contentForm').preset.getValue();
var presetIndex = $('contentForm').preset.getValue(); if ( labels[presetIndex] ) {
if ( labels[presetIndex] ) $('contentForm').newLabel.value = labels[presetIndex];
{ } else {
$('contentForm').newLabel.value = labels[presetIndex]; $('contentForm').newLabel.value = "";
} }
else
{
$('contentForm').newLabel.value = "";
}
} }
window.addEvent( 'domready', updateLabel ); window.addEvent( 'domready', updateLabel );

View File

@ -1,11 +1,9 @@
function nextCycleView() function nextCycleView() {
{ window.location.replace( '?view=cycle&group='+currGroup+'&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout );
window.location.replace( '?view=cycle&group='+currGroup+'&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout );
} }
function initCycle() function initCycle() {
{ nextCycleView.periodical( cycleRefreshTimeout );
nextCycleView.periodical( cycleRefreshTimeout );
} }
window.addEvent( 'domready', initCycle ); window.addEvent( 'domready', initCycle );

View File

@ -1,47 +1,40 @@
function switchDeviceOn( element, key ) function switchDeviceOn( element, key ) {
{ var form = element.form;
var form = element.form; form.view.value = currentView;
form.view.value = currentView; form.action.value = 'device';
form.action.value = 'device'; form.command.value = 'on';
form.command.value = 'on'; form.key.value = key;
form.key.value = key; form.submit();
form.submit();
} }
function switchDeviceOff( element, key ) function switchDeviceOff( element, key ) {
{ var form = element.form;
var form = element.form; form.view.value = currentView;
form.view.value = currentView; form.action.value = 'device';
form.action.value = 'device'; form.command.value = 'off';
form.command.value = 'off'; form.key.value = key;
form.key.value = key; form.submit();
form.submit();
} }
function deleteDevice( element ) function deleteDevice( element ) {
{ var form = element.form;
var form = element.form; form.view.value = currentView;
form.view.value = currentView; form.action.value = 'delete';
form.action.value = 'delete'; form.submit();
form.submit();
} }
function configureButtons( element, name ) function configureButtons( element, name ) {
{ var form = element.form;
var form = element.form; var checked = false;
var checked = false; for (var i = 0; i < form.elements.length; i++) {
for (var i = 0; i < form.elements.length; i++) if ( form.elements[i].name.indexOf(name) == 0) {
{ if ( form.elements[i].checked ) {
if ( form.elements[i].name.indexOf(name) == 0) checked = true;
{ break;
if ( form.elements[i].checked ) }
{
checked = true;
break;
}
}
} }
form.deleteBtn.disabled = !checked; }
form.deleteBtn.disabled = !checked;
} }
window.focus(); window.focus();

View File

@ -1,14 +1,12 @@
function submitForm( element ) function submitForm( element ) {
{ var form = element.form;
var form = element.form; if ( form.option.selectedIndex == 0 )
if ( form.option.selectedIndex == 0 ) form.view.value = currentView;
form.view.value = currentView; else
else form.view.value = 'none';
form.view.value = 'none'; form.submit();
form.submit();
} }
if ( action == "donate" && option == "go" ) if ( action == "donate" && option == "go" ) {
{ zmWindow();
zmWindow();
} }

View File

@ -1,150 +1,121 @@
function closeWindows() function closeWindows() {
{ window.close();
window.close(); // This is a hack. The only way to close an existing window is to try and open it!
// This is a hack. The only way to close an existing window is to try and open it! var filterWindow = window.open( thisUrl+'?view=none', 'zmFilter', 'width=1,height=1' );
var filterWindow = window.open( thisUrl+'?view=none', 'zmFilter', 'width=1,height=1' ); filterWindow.close();
filterWindow.close();
} }
function toggleCheckbox( element, name ) function toggleCheckbox( element, name ) {
{ var form = element.form;
var form = element.form; var checked = element.checked;
var checked = element.checked; for (var i = 0; i < form.elements.length; i++)
for (var i = 0; i < form.elements.length; i++) if (form.elements[i].name.indexOf(name) == 0)
if (form.elements[i].name.indexOf(name) == 0) form.elements[i].checked = checked;
form.elements[i].checked = checked; form.viewBtn.disabled = !checked;
form.viewBtn.disabled = !checked; form.editBtn.disabled = !checked;
form.editBtn.disabled = !checked; form.archiveBtn.disabled = unarchivedEvents?!checked:true;
form.archiveBtn.disabled = unarchivedEvents?!checked:true; form.unarchiveBtn.disabled = archivedEvents?!checked:true;
form.unarchiveBtn.disabled = archivedEvents?!checked:true; form.exportBtn.disabled = !checked;
form.exportBtn.disabled = !checked; form.deleteBtn.disabled = !checked;
form.deleteBtn.disabled = !checked;
} }
function configureButton( element, name ) function configureButton( element, name ) {
{ var form = element.form;
var form = element.form; var checked = element.checked;
var checked = element.checked; if ( !checked ) {
if ( !checked ) for (var i = 0; i < form.elements.length; i++) {
{ if ( form.elements[i].name.indexOf(name) == 0) {
for (var i = 0; i < form.elements.length; i++) if ( form.elements[i].checked ) {
{ checked = true;
if ( form.elements[i].name.indexOf(name) == 0) break;
{
if ( form.elements[i].checked )
{
checked = true;
break;
}
}
} }
}
} }
if ( !element.checked ) }
form.toggleCheck.checked = false; if ( !element.checked )
form.viewBtn.disabled = !checked; form.toggleCheck.checked = false;
form.editBtn.disabled = !checked; form.viewBtn.disabled = !checked;
form.archiveBtn.disabled = (!checked)||(!unarchivedEvents); form.editBtn.disabled = !checked;
form.unarchiveBtn.disabled = (!checked)||(!archivedEvents); form.archiveBtn.disabled = (!checked)||(!unarchivedEvents);
form.exportBtn.disabled = !checked; form.unarchiveBtn.disabled = (!checked)||(!archivedEvents);
form.deleteBtn.disabled = !checked; form.exportBtn.disabled = !checked;
form.deleteBtn.disabled = !checked;
} }
function deleteEvents( element, name ) function deleteEvents( element, name ) {
{ var form = element.form;
var form = element.form; var count = 0;
var count = 0; for (var i = 0; i < form.elements.length; i++) {
for (var i = 0; i < form.elements.length; i++) if (form.elements[i].name.indexOf(name) == 0) {
{ if ( form.elements[i].checked ) {
if (form.elements[i].name.indexOf(name) == 0) count++;
{ break;
if ( form.elements[i].checked ) }
{
count++;
break;
}
}
} }
if ( count > 0 ) }
{ if ( count > 0 ) {
if ( confirm( confirmDeleteEventsString ) ) if ( confirm( confirmDeleteEventsString ) ) {
{ form.action.value = 'delete';
form.action.value = 'delete'; form.submit();
form.submit();
}
} }
}
} }
function editEvents( element, name ) function editEvents( element, name ) {
{ var form = element.form;
var form = element.form; var eids = new Array();
var eids = new Array(); for (var i = 0; i < form.elements.length; i++) {
for (var i = 0; i < form.elements.length; i++) if (form.elements[i].name.indexOf(name) == 0) {
{ if ( form.elements[i].checked ) {
if (form.elements[i].name.indexOf(name) == 0) eids[eids.length] = 'eids[]='+form.elements[i].value;
{ }
if ( form.elements[i].checked )
{
eids[eids.length] = 'eids[]='+form.elements[i].value;
}
}
} }
createPopup( '?view=eventdetail&'+eids.join( '&' ), 'zmEventDetail', 'eventdetail' ); }
createPopup( '?view=eventdetail&'+eids.join( '&' ), 'zmEventDetail', 'eventdetail' );
} }
function exportEvents( element, name ) function exportEvents( element, name ) {
{ var form = element.form;
var form = element.form; var eids = new Array();
var eids = new Array(); for (var i = 0; i < form.elements.length; i++) {
for (var i = 0; i < form.elements.length; i++) if (form.elements[i].name.indexOf(name) == 0) {
{ if ( form.elements[i].checked ) {
if (form.elements[i].name.indexOf(name) == 0) eids[eids.length] = 'eids[]='+form.elements[i].value;
{ }
if ( form.elements[i].checked )
{
eids[eids.length] = 'eids[]='+form.elements[i].value;
}
}
} }
createPopup( '?view=export&'+eids.join( '&' ), 'zmExport', 'export' ); }
createPopup( '?view=export&'+eids.join( '&' ), 'zmExport', 'export' );
} }
function viewEvents( element, name ) function viewEvents( element, name ) {
{ var form = element.form;
var form = element.form; var events = new Array();
var events = new Array(); for (var i = 0; i < form.elements.length; i++) {
for (var i = 0; i < form.elements.length; i++) if ( form.elements[i].name.indexOf(name) == 0) {
{ if ( form.elements[i].checked ) {
if ( form.elements[i].name.indexOf(name) == 0) events[events.length] = form.elements[i].value;
{ }
if ( form.elements[i].checked )
{
events[events.length] = form.elements[i].value;
}
}
}
if ( events.length > 0 )
{
createPopup( '?view=event&eid='+events[0]+'&filter[terms][0][attr]=Id&&filter[terms][0][op]=%3D%5B%5D&&filter[terms][0][val]='+events.join('%2C')+sortQuery+'&page=1&play=1', 'zmEvent', 'event', maxWidth, maxHeight );
} }
}
if ( events.length > 0 ) {
createPopup( '?view=event&eid='+events[0]+'&filter[terms][0][attr]=Id&&filter[terms][0][op]=%3D%5B%5D&&filter[terms][0][val]='+events.join('%2C')+sortQuery+'&page=1&play=1', 'zmEvent', 'event', maxWidth, maxHeight );
}
} }
function archiveEvents( element, name ) function archiveEvents( element, name ) {
{ var form = element.form;
var form = element.form; form.action.value = 'archive';
form.action.value = 'archive'; form.submit();
form.submit();
} }
function unarchiveEvents( element, name ) function unarchiveEvents( element, name ) {
{ var form = element.form;
var form = element.form; form.action.value = 'unarchive';
form.action.value = 'unarchive'; form.submit();
form.submit();
} }
if ( openFilterWindow ) if ( openFilterWindow ) {
{ //opener.location.reload(true);
//opener.location.reload(true); createPopup( '?view=filter&page='+thisPage+filterQuery, 'zmFilter', 'filter' );
createPopup( '?view=filter&page='+thisPage+filterQuery, 'zmFilter', 'filter' ); location.replace( '?view='+currentView+'&page='+thisPage+filterQuery );
location.replace( '?view='+currentView+'&page='+thisPage+filterQuery );
} }

View File

@ -1,58 +1,52 @@
function configureExportButton( element ) function configureExportButton( element ) {
{ var form = element.form;
var form = element.form;
var checkCount = 0; var checkCount = 0;
var radioCount = 0; var radioCount = 0;
for ( var i = 0; i < form.elements.length; i++ ) for ( var i = 0; i < form.elements.length; i++ ) {
if ( form.elements[i].type == "checkbox" && form.elements[i].checked ) if ( form.elements[i].type == "checkbox" && form.elements[i].checked )
checkCount++; checkCount++;
else if ( form.elements[i].type == "radio" && form.elements[i].checked ) else if ( form.elements[i].type == "radio" && form.elements[i].checked )
radioCount++; radioCount++;
form.elements['exportButton'].disabled = (checkCount == 0 || radioCount == 0); }
form.elements['exportButton'].disabled = (checkCount == 0 || radioCount == 0);
} }
function startDownload( exportFile ) function startDownload( exportFile ) {
{ window.location.replace( exportFile );
window.location.replace( exportFile );
} }
var exportTimer = null; var exportTimer = null;
function exportProgress() function exportProgress() {
{ var tickerText = $('exportProgressTicker').get('text');
var tickerText = $('exportProgressTicker').get('text'); if ( tickerText.length < 1 || tickerText.length > 4 )
if ( tickerText.length < 1 || tickerText.length > 4 ) $('exportProgressTicker').set( 'text', '.' );
$('exportProgressTicker').set( 'text', '.' ); else
else $('exportProgressTicker').appendText( '.' );
$('exportProgressTicker').appendText( '.' );
} }
function exportResponse( respObj, respText ) function exportResponse( respObj, respText ) {
{ window.location.replace( thisUrl+'?view='+currentView+'&'+eidParm+'&exportFile='+respObj.exportFile+'&generated='+((respObj.result=='Ok')?1:0) );
window.location.replace( thisUrl+'?view='+currentView+'&'+eidParm+'&exportFile='+respObj.exportFile+'&generated='+((respObj.result=='Ok')?1:0) );
} }
function exportEvent( form ) function exportEvent( form ) {
{ var parms = 'view=request&request=event&action=export';
var parms = 'view=request&request=event&action=export'; parms += '&'+$(form).toQueryString();
parms += '&'+$(form).toQueryString(); var query = new Request.JSON( { url: thisUrl, method: 'post', data: parms, onSuccess: exportResponse } );
var query = new Request.JSON( { url: thisUrl, method: 'post', data: parms, onSuccess: exportResponse } ); query.send();
query.send(); $('exportProgress').removeClass( 'hidden' );
$('exportProgress').removeClass( 'hidden' ); $('exportProgress').setProperty( 'class', 'warnText' );
$('exportProgress').setProperty( 'class', 'warnText' ); $('exportProgressText').set( 'text', exportProgressString );
$('exportProgressText').set( 'text', exportProgressString ); exportProgress();
exportProgress(); exportTimer = exportProgress.periodical( 500 );
exportTimer = exportProgress.periodical( 500 );
} }
function initPage() function initPage() {
{ configureExportButton( $('exportButton') );
configureExportButton( $('exportButton') ); if ( exportReady ) {
if ( exportReady ) startDownload.pass( exportFile ).delay( 1500 );
{ }
startDownload.pass( exportFile ).delay( 1500 );
}
} }
window.addEvent( 'domready', initPage ); window.addEvent( 'domready', initPage );

View File

@ -1,15 +1,12 @@
<?php <?php
if ( isset($_REQUEST['eids']) ) if ( isset($_REQUEST['eids']) ) {
{ $eidParms = array();
$eidParms = array(); foreach ( $_REQUEST['eids'] as $eid )
foreach ( $_REQUEST['eids'] as $eid ) $eidParms[] = "eids[]=".validInt($eid);
$eidParms[] = "eids[]=".validInt($eid);
?> ?>
var eidParm = '<?php echo join( '&', $eidParms ) ?>'; var eidParm = '<?php echo join( '&', $eidParms ) ?>';
<?php <?php
} } else {
else
{
?> ?>
var eidParm = 'eid=<?php echo validInt($_REQUEST['eid']) ?>'; var eidParm = 'eid=<?php echo validInt($_REQUEST['eid']) ?>';
<?php <?php

View File

@ -1,119 +1,106 @@
function updateButtons( element ) function updateButtons( element ) {
{ var form = element.form;
var form = element.form;
if ( element.type == 'checkbox' && element.checked ) if ( element.type == 'checkbox' && element.checked ) {
form.elements['executeButton'].disabled = false; form.elements['executeButton'].disabled = false;
else } else {
{ var canExecute = false;
var canExecute = false; if ( form.elements['AutoArchive'].checked )
if ( form.elements['AutoArchive'].checked ) canExecute = true;
canExecute = true; else if ( typeof ZM_OPT_FFMPEG !== "undefined" && form.elements['AutoVideo'].checked )
else if ( typeof ZM_OPT_FFMPEG !== "undefined" && form.elements['AutoVideo'].checked ) canExecute = true;
canExecute = true; else if ( typeof ZM_OPT_UPLOAD !== "undefined" && form.elements['AutoUpload'].checked )
else if ( typeof ZM_OPT_UPLOAD !== "undefined" && form.elements['AutoUpload'].checked ) canExecute = true;
canExecute = true; else if ( typeof ZM_OPT_EMAIL !== "undefined" && form.elements['AutoEmail'].checked )
else if ( typeof ZM_OPT_EMAIL !== "undefined" && form.elements['AutoEmail'].checked ) canExecute = true;
canExecute = true; else if ( typeof ZM_OPT_MESSAGE !== "undefined" && form.elements['AutoMessage'].checked )
else if ( typeof ZM_OPT_MESSAGE !== "undefined" && form.elements['AutoMessage'].checked ) canExecute = true;
canExecute = true; else if ( form.elements['AutoExecute'].checked && form.elements['AutoExecuteCmd'].value != '' )
else if ( form.elements['AutoExecute'].checked && form.elements['AutoExecuteCmd'].value != '' ) canExecute = true;
canExecute = true; else if ( form.elements['AutoDelete'].checked )
else if ( form.elements['AutoDelete'].checked ) canExecute = true;
canExecute = true; form.elements['executeButton'].disabled = !canExecute;
form.elements['executeButton'].disabled = !canExecute; }
}
} }
function clearValue( element, line ) function clearValue( element, line ) {
{ var form = element.form;
var form = element.form; var val = form.elements['filter[terms]['+line+'][val]'];
var val = form.elements['filter[terms]['+line+'][val]']; val.value = '';
val.value = '';
} }
function submitToFilter( element, reload ) function submitToFilter( element, reload ) {
{ var form = element.form;
var form = element.form; form.target = window.name;
form.target = window.name; form.view.value = 'filter';
form.view.value = 'filter'; form.reload.value = reload;
form.reload.value = reload; form.submit();
}
function submitToEvents( element ) {
var form = element.form;
if ( validateForm( form ) ) {
form.target = 'zmEvents';
form.view.value = 'events';
form.action.value = '';
form.execute.value = 0;
form.submit(); form.submit();
}
} }
function submitToEvents( element ) function executeFilter( element ) {
{ var form = element.form;
var form = element.form; if ( validateForm( form ) ) {
if ( validateForm( form ) ) form.target = 'zmEvents';
{ form.view.value = 'events';
form.target = 'zmEvents';
form.view.value = 'events';
form.action.value = '';
form.execute.value = 0;
form.submit();
}
}
function executeFilter( element )
{
var form = element.form;
if ( validateForm( form ) )
{
form.target = 'zmEvents';
form.view.value = 'events';
form.action.value = 'filter';
form.execute.value = 1;
form.submit();
}
}
function saveFilter( element )
{
var form = element.form;
var popupName = 'zmEventsFilterSave';
createPopup( thisUrl, popupName, 'filtersave' );
form.target = popupName;
form.view.value = 'filtersave';
form.submit();
}
function deleteFilter( element, id, name )
{
if ( confirm( deleteSavedFilterString+" '"+name+"'?" ) )
{
var form = element.form;
form.action.value = 'delete';
submitToFilter( element, 0 );
}
}
function addTerm( element, line )
{
var form = element.form;
form.target = window.name;
form.view.value = currentView;
form.action.value = 'filter'; form.action.value = 'filter';
form.subaction.value = 'addterm'; form.execute.value = 1;
form.line.value = line;
form.submit(); form.submit();
}
} }
function delTerm( element, line ) function saveFilter( element ) {
{ var form = element.form;
var popupName = 'zmEventsFilterSave';
createPopup( thisUrl, popupName, 'filtersave' );
form.target = popupName;
form.view.value = 'filtersave';
form.submit();
}
function deleteFilter( element, name ) {
if ( confirm( deleteSavedFilterString+" '"+name+"'" ) ) {
var form = element.form; var form = element.form;
form.target = window.name; form.action.value = 'delete';
form.view.value = currentView; form.fid.value = name;
form.action.value = 'filter'; submitToFilter( element, 1 );
form.subaction.value = 'delterm'; }
form.line.value = line;
form.submit();
} }
function init() function addTerm( element, line ) {
{ var form = element.form;
updateButtons( $('executeButton') ); form.target = window.name;
form.view.value = currentView;
form.action.value = 'filter';
form.subaction.value = 'addterm';
form.line.value = line;
form.submit();
}
function delTerm( element, line ) {
var form = element.form;
form.target = window.name;
form.view.value = currentView;
form.action.value = 'filter';
form.subaction.value = 'delterm';
form.line.value = line;
form.submit();
}
function init() {
updateButtons( $('executeButton') );
} }
window.addEvent( 'domready', init ); window.addEvent( 'domready', init );

View File

@ -1,48 +1,41 @@
var deleteSavedFilterString = "<?php echo translate('DeleteSavedFilter') ?>"; var deleteSavedFilterString = "<?php echo translate('DeleteSavedFilter') ?>";
function validateForm( form ) function validateForm( form ) {
{
<?php <?php
if ( isset ($_REQUEST['filter']) && count($_REQUEST['filter']['terms']) > 2 ) if ( isset ($_REQUEST['filter']) && count($_REQUEST['filter']['terms']) > 2 ) {
{
?> ?>
var bracket_count = 0; var bracket_count = 0;
<?php <?php
for ( $i = 0; $i < count($_REQUEST['filter']['terms']); $i++ ) for ( $i = 0; $i < count($_REQUEST['filter']['terms']); $i++ ) {
{
?> ?>
var obr = form.elements['filter[terms][<?php echo $i ?>][obr]']; var obr = form.elements['filter[terms][<?php echo $i ?>][obr]'];
var cbr = form.elements['filter[terms][<?php echo $i ?>][cbr]']; var cbr = form.elements['filter[terms][<?php echo $i ?>][cbr]'];
bracket_count += parseInt(obr.options[obr.selectedIndex].value); bracket_count += parseInt(obr.options[obr.selectedIndex].value);
bracket_count -= parseInt(cbr.options[cbr.selectedIndex].value); bracket_count -= parseInt(cbr.options[cbr.selectedIndex].value);
<?php <?php
} }
?> ?>
if ( bracket_count ) if ( bracket_count ) {
{ alert( "<?php echo translate('ErrorBrackets') ?>" );
alert( "<?php echo translate('ErrorBrackets') ?>" ); return( false );
return( false ); }
}
<?php <?php
} }
?> ?>
<?php <?php
for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['terms']); $i++ ) for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['terms']); $i++ ) {
{
?> ?>
var val = form.elements['filter[terms][<?php echo $i ?>][val]']; var val = form.elements['filter[terms][<?php echo $i ?>][val]'];
if ( val.value == '' ) if ( val.value == '' ) {
{ alert( "<?php echo translate('ErrorValidValue') ?>" );
alert( "<?php echo translate('ErrorValidValue') ?>" ); return( false );
return( false ); }
}
<?php <?php
} }
?> ?>
return( true ); return( true );
} }
<?php <?php
if ( !empty($hasCal) ) if ( !empty($hasCal) ) {
{
?> ?>
</script> </script>
<style type="text/css">@import url(tools/jscalendar/calendar-win2k-1.css);</style> <style type="text/css">@import url(tools/jscalendar/calendar-win2k-1.css);</style>

View File

@ -1,18 +1,16 @@
function selectMonitors() function selectMonitors() {
{ createPopup( '?view=monitorselect&callForm=groupForm&callField=newGroup[MonitorIds]', 'zmMonitors', 'monitorselect' );
createPopup( '?view=monitorselect&callForm=groupForm&callField=newGroup[MonitorIds]', 'zmMonitors', 'monitorselect' );
} }
if ( refreshParent ) if ( refreshParent ) {
{ opener.location.reload(true);
opener.location.reload(true);
} }
function configureButtons( element ) { function configureButtons( element ) {
if ( canEditGroups ) { if ( canEditGroups ) {
var form = element.form; var form = element.form;
form.saveBtn.disabled = (element.value == 0); form.saveBtn.disabled = (element.value == 0);
} }
} }
window.focus(); window.focus();

View File

@ -1,47 +1,38 @@
function newGroup() function newGroup() {
{ createPopup( '?view=group', 'zmGroup', 'group' );
createPopup( '?view=group', 'zmGroup', 'group' );
} }
function editGroup( element ) function editGroup( element ) {
{ var form = element.form;
var form = element.form; form.action.value = 'setgroup';
form.action.value = 'setgroup'; form.submit();
form.submit();
} }
function editGroup( element ) function editGroup( element ) {
{ var form = element.form;
var form = element.form; for ( var i = 0; i < form.gid.length; i++ ) {
for ( var i = 0; i < form.gid.length; i++ ) if ( form.gid[i].checked ) {
{ createPopup( '?view=group&gid='+form.gid[i].value, 'zmGroup', 'group' );
if ( form.gid[i].checked ) return;
{
createPopup( '?view=group&gid='+form.gid[i].value, 'zmGroup', 'group' );
return;
}
} }
}
} }
function deleteGroup( element ) function deleteGroup( element ) {
{ var form = element.form;
form.view.value = currentView;
form.action.value = 'delete';
form.submit();
}
function configureButtons( element ) {
if ( canEditGroups ) {
var form = element.form; var form = element.form;
form.view.value = currentView; if ( element.checked ) {
form.action.value = 'delete'; form.editBtn.disabled = (element.value == 0);
form.submit(); form.deleteBtn.disabled = (element.value == 0);
}
function configureButtons( element )
{
if ( canEditGroups )
{
var form = element.form;
if ( element.checked )
{
form.editBtn.disabled = (element.value == 0);
form.deleteBtn.disabled = (element.value == 0);
}
} }
}
} }
window.focus(); window.focus();

View File

@ -25,313 +25,269 @@ var sortReversed = false;
var filterFields = ['Component', 'ServerId', 'Pid', 'Level', 'File', 'Line']; var filterFields = ['Component', 'ServerId', 'Pid', 'Level', 'File', 'Line'];
var options = {}; var options = {};
function buildFetchParms( parms ) function buildFetchParms( parms ) {
{ var fetchParms = logParms+'&limit='+maxLogFetch;
var fetchParms = logParms+'&limit='+maxLogFetch; if ( parms )
if ( parms ) fetchParms += '&'+parms;
fetchParms += '&'+parms; Object.each(filter,
Object.each(filter, function( value, key ) {
function( value, key ) fetchParms += '&filter['+key+']='+value;
{ }
fetchParms += '&filter['+key+']='+value; );
} return( fetchParms );
);
return( fetchParms );
} }
function fetchNextLogs() function fetchNextLogs() {
{ logReq.send( buildFetchParms( 'minTime='+maxLogTime ) );
logReq.send( buildFetchParms( 'minTime='+maxLogTime ) );
} }
function fetchPrevLogs() function fetchPrevLogs() {
{ logReq.send( buildFetchParms( 'maxTime='+minLogTime ) );
logReq.send( buildFetchParms( 'maxTime='+minLogTime ) );
} }
function logResponse( respObj ) function logResponse( respObj ) {
{ if ( logTimer )
if ( logTimer ) logTimer = clearTimeout( logTimer );
logTimer = clearTimeout( logTimer );
if ( respObj.result == 'Ok' ) if ( respObj.result == 'Ok' ) {
{ if ( respObj.logs.length > 0 ) {
if ( respObj.logs.length > 0 ) logTimeout = minSampleTime;
{ logCount += respObj.logs.length;
logTimeout = minSampleTime; try {
logCount += respObj.logs.length; respObj.logs.each(
try { function( log ) {
respObj.logs.each( if ( !maxLogTime || log.TimeKey > maxLogTime )
function( log ) maxLogTime = log.TimeKey;
{ if ( !minLogTime || log.TimeKey < minLogTime )
if ( !maxLogTime || log.TimeKey > maxLogTime ) minLogTime = log.TimeKey;
maxLogTime = log.TimeKey; var row = logTable.push( [{ content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Server, log.Pid, log.Code, log.Message, log.File, log.Line] );
if ( !minLogTime || log.TimeKey < minLogTime ) delete log.Message;
minLogTime = log.TimeKey; row.tr.store( 'log', log );
var row = logTable.push( [{ content: log.DateTime, properties: { style: 'white-space: nowrap' }}, log.Component, log.Server, log.Pid, log.Code, log.Message, log.File, log.Line] ); if ( log.Level <= -3 )
delete log.Message; row.tr.addClass( 'log-fat' );
row.tr.store( 'log', log ); else if ( log.Level <= -2 )
if ( log.Level <= -3 ) row.tr.addClass( 'log-err' );
row.tr.addClass( 'log-fat' ); else if ( log.Level <= -1 )
else if ( log.Level <= -2 ) row.tr.addClass( 'log-war' );
row.tr.addClass( 'log-err' ); else if ( log.Level > 0 )
else if ( log.Level <= -1 ) row.tr.addClass( 'log-dbg' );
row.tr.addClass( 'log-war' ); if ( !firstLoad ) {
else if ( log.Level > 0 ) var color = document.defaultView.getComputedStyle(row.tr, null).getPropertyValue('color');
row.tr.addClass( 'log-dbg' ); var colorParts = color.match(/^rgb.*\((\d+),\s*(\d+),\s*(\d+)/);
if ( !firstLoad ) rowOrigColor = '#' + parseInt(colorParts[1]).toString(16) + parseInt(colorParts[2]).toString(16) + parseInt(colorParts[3]).toString(16);
{ new Fx.Tween( row.tr, { duration: 10000, transition: Fx.Transitions.Sine } ).start( 'color', '#6495ED', rowOrigColor );
var color = document.defaultView.getComputedStyle(row.tr, null).getPropertyValue('color'); }
var colorParts = color.match(/^rgb.*\((\d+),\s*(\d+),\s*(\d+)/);
rowOrigColor = '#' + parseInt(colorParts[1]).toString(16) + parseInt(colorParts[2]).toString(16) + parseInt(colorParts[3]).toString(16);
new Fx.Tween( row.tr, { duration: 10000, transition: Fx.Transitions.Sine } ).start( 'color', '#6495ED', rowOrigColor );
}
}
);
options = respObj.options;
updateFilterSelectors();
$('lastUpdate').set('text', respObj.updated);
$('logState').set('text', respObj.state);
$('logState').removeClass('ok');
$('logState').removeClass('alert');
$('logState').removeClass('alarm');
$('logState').addClass(respObj.state);
$('totalLogs').set('text', respObj.total);
$('availLogs').set('text', respObj.available);
$('displayLogs').set('text', logCount);
if ( firstLoad )
{
if ( logCount < displayLimit )
fetchPrevLogs();
}
logTable.reSort();
} }
catch( e ) );
{ options = respObj.options;
console.error( e ); updateFilterSelectors();
} $('lastUpdate').set('text', respObj.updated);
logTimeout /= 2; $('logState').set('text', respObj.state);
if ( logTimeout < minSampleTime ) $('logState').removeClass('ok');
logTimeout = minSampleTime; $('logState').removeClass('alert');
} $('logState').removeClass('alarm');
else $('logState').addClass(respObj.state);
{ $('totalLogs').set('text', respObj.total);
firstLoad = false; $('availLogs').set('text', respObj.available);
logTimeout *= 2; $('displayLogs').set('text', logCount);
if ( logTimeout > maxSampleTime ) if ( firstLoad ) {
logTimeout = maxSampleTime; if ( logCount < displayLimit )
fetchPrevLogs();
} }
logTable.reSort();
} catch( e ) {
console.error( e );
}
logTimeout /= 2;
if ( logTimeout < minSampleTime )
logTimeout = minSampleTime;
} else {
firstLoad = false;
logTimeout *= 2;
if ( logTimeout > maxSampleTime )
logTimeout = maxSampleTime;
} }
logTimer = fetchNextLogs.delay( logTimeout ); }
logTimer = fetchNextLogs.delay( logTimeout );
} }
function refreshLog() function refreshLog() {
{ options = {};
options = {}; logTable.empty();
logTable.empty(); firstLoad = true;
firstLoad = true; maxLogTime = 0;
maxLogTime = 0; minLogTime = 0;
minLogTime = 0; logCount = 0;
logCount = 0; logTimeout = maxSampleTime;
logTimeout = maxSampleTime; displayLimit = initialDisplayLimit;
displayLimit = initialDisplayLimit; fetchNextLogs();
fetchNextLogs();
} }
function expandLog() function expandLog() {
{ displayLimit += maxLogFetch;
displayLimit += maxLogFetch; fetchPrevLogs();
fetchPrevLogs();
} }
function clearLog() function clearLog() {
{ logReq.cancel();
logReq.cancel(); minLogTime = 0;
minLogTime = 0; logCount = 0;
logCount = 0; logTimeout = maxSampleTime;
logTimeout = maxSampleTime; displayLimit = initialDisplayLimit;
displayLimit = initialDisplayLimit; $('displayLogs').set('text', logCount);
$('displayLogs').set('text', logCount); options = {};
options = {}; logTable.empty();
logTable.empty();
} }
function filterLog() function filterLog() {
{ filter = {};
filter = {}; filterFields.each(
filterFields.each( function( field ) {
function( field ) var selector = $('filter['+field+']');
{ if ( ! selector ) {
var selector = $('filter['+field+']'); if ( window.console && window.console.log ) {
if ( ! selector ) { window.console.log("No selector found for " + field );
if ( window.console && window.console.log ) { }
window.console.log("No selector found for " + field ); return;
}
return;
}
var value = selector.get('value');
if ( value )
filter[field] = value;
} }
); var value = selector.get('value');
refreshLog(); if ( value )
filter[field] = value;
}
);
refreshLog();
} }
function resetLog() function resetLog() {
{ filter = {};
filter = {}; refreshLog();
refreshLog();
} }
var exportFormValidator; var exportFormValidator;
function exportLog() function exportLog() {
{ exportFormValidator.reset();
exportFormValidator.reset(); $('exportLog').overlayShow();
$('exportLog').overlayShow();
} }
function exportResponse( response ) function exportResponse( response ) {
{ $('exportLog').unspin();
$('exportLog').unspin(); if ( response.result == 'Ok' ) {
if ( response.result == 'Ok' ) window.location.replace( thisUrl+'?view=request&request=log&task=download&key='+response.key+'&format='+response.format );
{ }
window.location.replace( thisUrl+'?view=request&request=log&task=download&key='+response.key+'&format='+response.format ); }
function exportFail( request ) {
$('exportLog').unspin();
$('exportErrorText').set('text', request.status+" / "+request.statusText );
$('exportError').show();
Error( "Export request failed: "+request.status+" / "+request.statusText );
}
function exportRequest() {
var form = $('exportForm');
$('exportErrorText').set('text', "" );
$('exportError').hide();
if ( form.validate() ) {
var exportParms = "view=request&request=log&task=export";
var exportReq = new Request.JSON( { url: thisUrl, method: 'post', link: 'cancel', onSuccess: exportResponse, onFailure: exportFail } );
var selection = form.getElement('input[name=selector]:checked').get('value');
if ( selection == 'filter' || selection == 'current' ) {
$$('#filters select').each(
function( select ) {
exportParms += "&"+select.get('id')+"="+select.get('value');
}
);
} }
if ( selection == 'current' ) {
var tbody = $(logTable).getElement( 'tbody' );
var rows = tbody.getElements( 'tr' );
if ( rows ) {
var minTime = rows[0].getElement('td').get('text');
exportParms += "&minTime="+encodeURIComponent(minTime);
var maxTime = rows[rows.length-1].getElement('td').get('text');
exportParms += "&maxTime="+encodeURIComponent(maxTime);
}
}
exportReq.send( exportParms+"&"+form.toQueryString() );
$('exportLog').spin();
}
} }
function exportFail( request ) function updateFilterSelectors() {
{ Object.each(options,
$('exportLog').unspin(); function( values, key ) {
$('exportErrorText').set('text', request.status+" / "+request.statusText ); var selector = $('filter['+key+']');
$('exportError').show(); if ( ! selector ) {
Error( "Export request failed: "+request.status+" / "+request.statusText ); if ( window.console && window.console.log ) {
} window.console.log("No selector found for " + key );
}
function exportRequest() return;
{ }
var form = $('exportForm'); selector.options.length = 1;
$('exportErrorText').set('text', "" ); if ( key == 'Level' ) {
$('exportError').hide(); Object.each(values,
if ( form.validate() ) function( value, label ) {
{ selector.options[selector.options.length] = new Option( value, label );
var exportParms = "view=request&request=log&task=export";
var exportReq = new Request.JSON( { url: thisUrl, method: 'post', link: 'cancel', onSuccess: exportResponse, onFailure: exportFail } );
var selection = form.getElement('input[name=selector]:checked').get('value');
if ( selection == 'filter' || selection == 'current' )
{
$$('#filters select').each(
function( select )
{
exportParms += "&"+select.get('id')+"="+select.get('value');
} }
); );
} } else if ( key == 'ServerId' ) {
if ( selection == 'current' ) Object.each(values,
{ function( value, label ) {
var tbody = $(logTable).getElement( 'tbody' ); selector.options[selector.options.length] = new Option( value, label );
var rows = tbody.getElements( 'tr' );
if ( rows )
{
var minTime = rows[0].getElement('td').get('text');
exportParms += "&minTime="+encodeURIComponent(minTime);
var maxTime = rows[rows.length-1].getElement('td').get('text');
exportParms += "&maxTime="+encodeURIComponent(maxTime);
}
}
exportReq.send( exportParms+"&"+form.toQueryString() );
$('exportLog').spin();
}
}
function updateFilterSelectors()
{
Object.each(options,
function( values, key )
{
var selector = $('filter['+key+']');
if ( ! selector ) {
if ( window.console && window.console.log ) {
window.console.log("No selector found for " + key );
}
return;
}
selector.options.length = 1;
if ( key == 'Level' )
{
Object.each(values,
function( value, label )
{
selector.options[selector.options.length] = new Option( value, label );
}
);
}
else if ( key == 'ServerId' )
{
Object.each(values,
function( value, label )
{
selector.options[selector.options.length] = new Option( value, label );
}
);
}
else
{
values.each(
function( value )
{
selector.options[selector.options.length] = new Option( value );
}
);
}
if ( filter[key] )
selector.set('value', filter[key]);
}
);
}
function initPage()
{
displayLimit = initialDisplayLimit;
for ( var i = 1; i <= 9; i++ )
logCodes[''+i] = 'DB'+i;
logTable = new HtmlTable( $('logTable'),
{
zebra: true,
sortable: true,
sortReverse: true
}
);
logTable.addEvent( 'sort', function( tbody, index )
{
var header = tbody.getParent( 'table' ).getElement( 'thead' );
var columns = header.getElement( 'tr' ).getElements( 'th' );
var column = columns[index];
sortReversed = column.hasClass( 'table-th-sort-rev' );
if ( logCount > displayLimit )
{
var rows = tbody.getElements( 'tr' );
var startIndex;
if ( sortReversed )
startIndex = displayLimit;
else
startIndex = 0;
for ( var i = startIndex; logCount > displayLimit; i++ )
{
rows[i].destroy();
logCount--;
} }
$('displayLogs').set('text', logCount); );
} } else {
values.each(
function( value ) {
selector.options[selector.options.length] = new Option( value );
}
);
}
if ( filter[key] )
selector.set('value', filter[key]);
}
);
}
function initPage() {
displayLimit = initialDisplayLimit;
for ( var i = 1; i <= 9; i++ )
logCodes[''+i] = 'DB'+i;
logTable = new HtmlTable( $('logTable'),
{
zebra: true,
sortable: true,
sortReverse: true
}
);
logTable.addEvent( 'sort', function( tbody, index ) {
var header = tbody.getParent( 'table' ).getElement( 'thead' );
var columns = header.getElement( 'tr' ).getElements( 'th' );
var column = columns[index];
sortReversed = column.hasClass( 'table-th-sort-rev' );
if ( logCount > displayLimit ) {
var rows = tbody.getElements( 'tr' );
var startIndex;
if ( sortReversed )
startIndex = displayLimit;
else
startIndex = 0;
for ( var i = startIndex; logCount > displayLimit; i++ ) {
rows[i].destroy();
logCount--;
} }
); $('displayLogs').set('text', logCount);
exportFormValidator = new Form.Validator.Inline($('exportForm'), { } // end if loCount > displayLimit
useTitles: true, }
warningPrefix: "", );
errorPrefix: "" exportFormValidator = new Form.Validator.Inline($('exportForm'), {
}); useTitles: true,
new Asset.css( "/css/spinner.css" ); warningPrefix: "",
fetchNextLogs(); errorPrefix: ""
});
new Asset.css( "/css/spinner.css" );
fetchNextLogs();
} }
// Kick everything off // Kick everything off

View File

@ -1,56 +1,49 @@
function updateMonitorDimensions( element ) function updateMonitorDimensions( element ) {
{ var form = element.form;
var form = element.form; var widthFactor = parseInt( defaultAspectRatio.replace( /:.*$/, '' ) );
var widthFactor = parseInt( defaultAspectRatio.replace( /:.*$/, '' ) ); var heightFactor = parseInt( defaultAspectRatio.replace( /^.*:/, '' ) );
var heightFactor = parseInt( defaultAspectRatio.replace( /^.*:/, '' ) );
if ( form.elements['preserveAspectRatio'].checked ) if ( form.elements['preserveAspectRatio'].checked ) {
{ var monitorWidth = parseInt(form.elements['newMonitor[Width]'].value);
var monitorWidth = parseInt(form.elements['newMonitor[Width]'].value); var monitorHeight = parseInt(form.elements['newMonitor[Height]'].value);
var monitorHeight = parseInt(form.elements['newMonitor[Height]'].value); switch( element.name ) {
switch( element.name ) case 'newMonitor[Width]':
{ if ( monitorWidth >= 0 )
case 'newMonitor[Width]': form.elements['newMonitor[Height]'].value = Math.round((monitorWidth * heightFactor) / widthFactor);
if ( monitorWidth >= 0 ) else
form.elements['newMonitor[Height]'].value = Math.round((monitorWidth * heightFactor) / widthFactor); form.elements['newMonitor[Height]'].value = '';
else break;
form.elements['newMonitor[Height]'].value = ''; case 'newMonitor[Height]':
break; if ( monitorHeight >= 0 )
case 'newMonitor[Height]': form.elements['newMonitor[Width]'].value = Math.round((monitorHeight * widthFactor) / heightFactor);
if ( monitorHeight >= 0 ) else
form.elements['newMonitor[Width]'].value = Math.round((monitorHeight * widthFactor) / heightFactor); form.elements['newMonitor[Width]'].value = '';
else break;
form.elements['newMonitor[Width]'].value = '';
break;
}
} }
return( false ); }
return( false );
} }
function loadLocations( element ) function loadLocations( element ) {
{ var form = element.form;
var form = element.form; var controlIdSelect = form.elements['newMonitor[ControlId]'];
var controlIdSelect = form.elements['newMonitor[ControlId]']; var returnLocationSelect = form.elements['newMonitor[ReturnLocation]'];
var returnLocationSelect = form.elements['newMonitor[ReturnLocation]'];
returnLocationSelect.options.length = 1; returnLocationSelect.options.length = 1;
//returnLocationSelect.options[0] = new Option( noneString, -1 ); //returnLocationSelect.options[0] = new Option( noneString, -1 );
var returnLocationOptions = controlOptions[controlIdSelect.selectedIndex]; var returnLocationOptions = controlOptions[controlIdSelect.selectedIndex];
if ( returnLocationOptions ) if ( returnLocationOptions ) {
{ for ( var i = 0; i < returnLocationOptions.length; i++ ) {
for ( var i = 0; i < returnLocationOptions.length; i++ ) returnLocationSelect.options[returnLocationSelect.options.length] = new Option( returnLocationOptions[i], i );
{
returnLocationSelect.options[returnLocationSelect.options.length] = new Option( returnLocationOptions[i], i );
}
} }
}
} }
function initPage() function initPage() {
{ //var protocolSelector = $('contentForm').elements['newMonitor[Protocol]'];
//var protocolSelector = $('contentForm').elements['newMonitor[Protocol]']; //if ( $(protocolSelector).getTag() == 'select' )
//if ( $(protocolSelector).getTag() == 'select' ) //updateMethods( $(protocolSelector) );
//updateMethods( $(protocolSelector) );
} }
window.addEvent( 'domready', initPage ); window.addEvent( 'domready', initPage );

View File

@ -2,194 +2,174 @@ var optControl = <?php echo ZM_OPT_CONTROL ?>;
var defaultAspectRatio = '<?php echo ZM_DEFAULT_ASPECT_RATIO ?>'; var defaultAspectRatio = '<?php echo ZM_DEFAULT_ASPECT_RATIO ?>';
<?php <?php
if ( ZM_OPT_CONTROL ) if ( ZM_OPT_CONTROL ) {
{
?> ?>
var controlOptions = new Object(); var controlOptions = new Object();
<?php <?php
global $controlTypes; global $controlTypes;
$controlTypes = array( ''=>translate('None') ); $controlTypes = array( ''=>translate('None') );
# Temporary workaround to show all ptz control types regardless of monitor source type # Temporary workaround to show all ptz control types regardless of monitor source type
# $sql = "select * from Controls where Type = '".$newMonitor['Type']."'"; # $sql = "select * from Controls where Type = '".$newMonitor['Type']."'";
$sql = "select * from Controls"; $sql = "select * from Controls";
foreach( dbFetchAll( $sql ) as $row ) foreach( dbFetchAll( $sql ) as $row ) {
{ $controlTypes[$row['Id']] = $row['Name'];
$controlTypes[$row['Id']] = $row['Name'];
?> ?>
controlOptions[<?php echo $row['Id'] ?>] = new Array(); controlOptions[<?php echo $row['Id'] ?>] = new Array();
<?php <?php
if ( $row['HasHomePreset'] ) if ( $row['HasHomePreset'] ) {
{
?> ?>
controlOptions[<?php echo $row['Id'] ?>][0] = '<?php echo translate('Home') ?>'; controlOptions[<?php echo $row['Id'] ?>][0] = '<?php echo translate('Home') ?>';
<?php <?php
} } else {
else
{
?> ?>
controlOptions[<?php echo $row['Id'] ?>][0] = null; controlOptions[<?php echo $row['Id'] ?>][0] = null;
<?php <?php
} }
for ( $i = 1; $i <= $row['NumPresets']; $i++ ) for ( $i = 1; $i <= $row['NumPresets']; $i++ ) {
{
?> ?>
controlOptions[<?php echo $row['Id'] ?>][<?php echo $i ?>] = '<?php echo translate('Preset').' '.$i ?>'; controlOptions[<?php echo $row['Id'] ?>][<?php echo $i ?>] = '<?php echo translate('Preset').' '.$i ?>';
<?php <?php
}
} }
}
} }
?> ?>
<?php <?php
if ( empty($_REQUEST['mid']) ) if ( empty($_REQUEST['mid']) ) {
{
?> ?>
var monitorNames = new Object(); var monitorNames = new Object();
<?php <?php
foreach ( dbFetchAll( "select Name from Monitors order by Name asc", "Name" ) as $name ) foreach ( dbFetchAll( "select Name from Monitors order by Name asc", "Name" ) as $name ) {
{
?> ?>
monitorNames['<?php echo validJsStr($name) ?>'] = true; monitorNames['<?php echo validJsStr($name) ?>'] = true;
<?php <?php
} }
} }
?> ?>
function validateForm( form ) function validateForm( form ) {
{ var errors = new Array();
var errors = new Array();
if ( form.elements['newMonitor[Name]'].value.search( /[^\w- ]/ ) >= 0 ) if ( form.elements['newMonitor[Name]'].value.search( /[^\w- ]/ ) >= 0 )
errors[errors.length] = "<?php echo translate('BadNameChars') ?>"; errors[errors.length] = "<?php echo translate('BadNameChars') ?>";
else if ( form.elements.mid.value == 0 && monitorNames[form.elements['newMonitor[Name]'].value] ) else if ( form.elements.mid.value == 0 && monitorNames[form.elements['newMonitor[Name]'].value] )
errors[errors.length] = "<?php echo translate('DuplicateMonitorName') ?>"; errors[errors.length] = "<?php echo translate('DuplicateMonitorName') ?>";
if ( form.elements['newMonitor[AnalysisFPS]'].value && !(parseFloat(form.elements['newMonitor[AnalysisFPS]'].value) > 0 ) ) if ( form.elements['newMonitor[AnalysisFPS]'].value && !(parseFloat(form.elements['newMonitor[AnalysisFPS]'].value) > 0 ) )
errors[errors.length] = "<?php echo translate('BadAnalysisFPS') ?>"; errors[errors.length] = "<?php echo translate('BadAnalysisFPS') ?>";
if ( form.elements['newMonitor[MaxFPS]'].value && !(parseFloat(form.elements['newMonitor[MaxFPS]'].value) > 0 ) ) if ( form.elements['newMonitor[MaxFPS]'].value && !(parseFloat(form.elements['newMonitor[MaxFPS]'].value) > 0 ) )
errors[errors.length] = "<?php echo translate('BadMaxFPS') ?>"; errors[errors.length] = "<?php echo translate('BadMaxFPS') ?>";
if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) ) if ( form.elements['newMonitor[AlarmMaxFPS]'].value && !(parseFloat(form.elements['newMonitor[AlarmMaxFPS]'].value) > 0 ) )
errors[errors.length] = "<?php echo translate('BadAlarmMaxFPS') ?>"; errors[errors.length] = "<?php echo translate('BadAlarmMaxFPS') ?>";
if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) ) if ( !form.elements['newMonitor[RefBlendPerc]'].value || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) > 100 ) || (parseInt(form.elements['newMonitor[RefBlendPerc]'].value) < 0 ) )
errors[errors.length] = "<?php echo translate('BadRefBlendPerc') ?>"; errors[errors.length] = "<?php echo translate('BadRefBlendPerc') ?>";
if ( form.elements['newMonitor[Type]'].value == 'Local' ) if ( form.elements['newMonitor[Type]'].value == 'Local' ) {
{ if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) )
if ( !form.elements['newMonitor[Palette]'].value || !form.elements['newMonitor[Palette]'].value.match( /^\d+$/ ) ) errors[errors.length] = "<?php echo translate('BadPalette') ?>";
errors[errors.length] = "<?php echo translate('BadPalette') ?>"; if ( !form.elements['newMonitor[Device]'].value )
if ( !form.elements['newMonitor[Device]'].value ) errors[errors.length] = "<?php echo translate('BadDevice') ?>";
errors[errors.length] = "<?php echo translate('BadDevice') ?>"; if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) )
if ( !form.elements['newMonitor[Channel]'].value || !form.elements['newMonitor[Channel]'].value.match( /^\d+$/ ) ) errors[errors.length] = "<?php echo translate('BadChannel') ?>";
errors[errors.length] = "<?php echo translate('BadChannel') ?>"; if ( !form.elements['newMonitor[Format]'].value || !form.elements['newMonitor[Format]'].value.match( /^\d+$/ ) )
if ( !form.elements['newMonitor[Format]'].value || !form.elements['newMonitor[Format]'].value.match( /^\d+$/ ) ) errors[errors.length] = "<?php echo translate('BadFormat') ?>";
errors[errors.length] = "<?php echo translate('BadFormat') ?>"; } else if ( form.elements['newMonitor[Type]'].value == 'Remote' ) {
} //if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) )
else if ( form.elements['newMonitor[Type]'].value == 'Remote' ) //errors[errors.length] = "<?php echo translate('BadHost') ?>";
{ if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) )
//if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) ) errors[errors.length] = "<?php echo translate('BadPort') ?>";
//errors[errors.length] = "<?php echo translate('BadHost') ?>"; //if ( !form.elements['newMonitor[Path]'].value )
if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) ) //errors[errors.length] = "<?php echo translate('BadPath') ?>";
errors[errors.length] = "<?php echo translate('BadPort') ?>"; } else if ( form.elements['newMonitor[Type]'].value == 'File' ) {
//if ( !form.elements['newMonitor[Path]'].value ) if ( !form.elements['newMonitor[Path]'].value )
//errors[errors.length] = "<?php echo translate('BadPath') ?>"; errors[errors.length] = "<?php echo translate('BadPath') ?>";
} }
else if ( form.elements['newMonitor[Type]'].value == 'File' ) if ( !form.elements['newMonitor[Colours]'].value || (parseInt(form.elements['newMonitor[Colours]'].value) != 1 && parseInt(form.elements['newMonitor[Colours]'].value) != 3 && parseInt(form.elements['newMonitor[Colours]'].value) != 4 ) )
{ errors[errors.length] = "<?php echo translate('BadColours') ?>";
if ( !form.elements['newMonitor[Path]'].value ) if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) )
errors[errors.length] = "<?php echo translate('BadPath') ?>"; errors[errors.length] = "<?php echo translate('BadWidth') ?>";
} if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) )
if ( !form.elements['newMonitor[Colours]'].value || (parseInt(form.elements['newMonitor[Colours]'].value) != 1 && parseInt(form.elements['newMonitor[Colours]'].value) != 3 && parseInt(form.elements['newMonitor[Colours]'].value) != 4 ) ) errors[errors.length] = "<?php echo translate('BadHeight') ?>";
errors[errors.length] = "<?php echo translate('BadColours') ?>"; if ( !form.elements['newMonitor[LabelX]'].value || !(parseInt(form.elements['newMonitor[LabelX]'].value) >= 0 ) )
if ( !form.elements['newMonitor[Width]'].value || !(parseInt(form.elements['newMonitor[Width]'].value) > 0 ) ) errors[errors.length] = "<?php echo translate('BadLabelX') ?>";
errors[errors.length] = "<?php echo translate('BadWidth') ?>"; if ( !form.elements['newMonitor[LabelY]'].value || !(parseInt(form.elements['newMonitor[LabelY]'].value) >= 0 ) )
if ( !form.elements['newMonitor[Height]'].value || !(parseInt(form.elements['newMonitor[Height]'].value) > 0 ) ) errors[errors.length] = "<?php echo translate('BadLabelY') ?>";
errors[errors.length] = "<?php echo translate('BadHeight') ?>"; if ( !form.elements['newMonitor[ImageBufferCount]'].value || !(parseInt(form.elements['newMonitor[ImageBufferCount]'].value) >= 10 ) )
if ( !form.elements['newMonitor[LabelX]'].value || !(parseInt(form.elements['newMonitor[LabelX]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadImageBufferCount') ?>";
errors[errors.length] = "<?php echo translate('BadLabelX') ?>"; if ( !form.elements['newMonitor[WarmupCount]'].value || !(parseInt(form.elements['newMonitor[WarmupCount]'].value) >= 0 ) )
if ( !form.elements['newMonitor[LabelY]'].value || !(parseInt(form.elements['newMonitor[LabelY]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadWarmupCount') ?>";
errors[errors.length] = "<?php echo translate('BadLabelY') ?>"; if ( !form.elements['newMonitor[PreEventCount]'].value || !(parseInt(form.elements['newMonitor[PreEventCount]'].value) > 0 ) || (parseInt(form.elements['newMonitor[PreEventCount]'].value) > parseInt(form.elements['newMonitor[ImageBufferCount]'].value)) )
if ( !form.elements['newMonitor[ImageBufferCount]'].value || !(parseInt(form.elements['newMonitor[ImageBufferCount]'].value) >= 10 ) ) errors[errors.length] = "<?php echo translate('BadPreEventCount') ?>";
errors[errors.length] = "<?php echo translate('BadImageBufferCount') ?>"; if ( !form.elements['newMonitor[PostEventCount]'].value || !(parseInt(form.elements['newMonitor[PostEventCount]'].value) >= 0 ) )
if ( !form.elements['newMonitor[WarmupCount]'].value || !(parseInt(form.elements['newMonitor[WarmupCount]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadPostEventCount') ?>";
errors[errors.length] = "<?php echo translate('BadWarmupCount') ?>"; if ( !form.elements['newMonitor[StreamReplayBuffer]'].value || !(parseInt(form.elements['newMonitor[StreamReplayBuffer]'].value) >= 0 ) )
if ( !form.elements['newMonitor[PreEventCount]'].value || !(parseInt(form.elements['newMonitor[PreEventCount]'].value) > 0 ) || (parseInt(form.elements['newMonitor[PreEventCount]'].value) > parseInt(form.elements['newMonitor[ImageBufferCount]'].value)) ) errors[errors.length] = "<?php echo translate('BadStreamReplayBuffer') ?>";
errors[errors.length] = "<?php echo translate('BadPreEventCount') ?>"; if ( !form.elements['newMonitor[AlarmFrameCount]'].value || !(parseInt(form.elements['newMonitor[AlarmFrameCount]'].value) > 0 ) )
if ( !form.elements['newMonitor[PostEventCount]'].value || !(parseInt(form.elements['newMonitor[PostEventCount]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadAlarmFrameCount') ?>";
errors[errors.length] = "<?php echo translate('BadPostEventCount') ?>"; if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) )
if ( !form.elements['newMonitor[StreamReplayBuffer]'].value || !(parseInt(form.elements['newMonitor[StreamReplayBuffer]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadSectionLength') ?>";
errors[errors.length] = "<?php echo translate('BadStreamReplayBuffer') ?>"; if ( !form.elements['newMonitor[AnalysisUpdateDelay]'].value || !(parseInt(form.elements['newMonitor[AnalysisUpdateDelay]'].value) >= 0 ) )
if ( !form.elements['newMonitor[AlarmFrameCount]'].value || !(parseInt(form.elements['newMonitor[AlarmFrameCount]'].value) > 0 ) ) errors[errors.length] = "<?php echo translate('BadAnalysisUpdateDelay') ?>";
errors[errors.length] = "<?php echo translate('BadAlarmFrameCount') ?>"; if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) )
if ( !form.elements['newMonitor[SectionLength]'].value || !(parseInt(form.elements['newMonitor[SectionLength]'].value) >= 30 ) ) errors[errors.length] = "<?php echo translate('BadFPSReportInterval') ?>";
errors[errors.length] = "<?php echo translate('BadSectionLength') ?>"; if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) )
if ( !form.elements['newMonitor[AnalysisUpdateDelay]'].value || !(parseInt(form.elements['newMonitor[AnalysisUpdateDelay]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadFrameSkip') ?>";
errors[errors.length] = "<?php echo translate('BadAnalysisUpdateDelay') ?>"; if ( !form.elements['newMonitor[MotionFrameSkip]'].value || !(parseInt(form.elements['newMonitor[MotionFrameSkip]'].value) >= 0 ) )
if ( !form.elements['newMonitor[FPSReportInterval]'].value || !(parseInt(form.elements['newMonitor[FPSReportInterval]'].value) >= 0 ) ) errors[errors.length] = "<?php echo translate('BadMotionFrameSkip') ?>";
errors[errors.length] = "<?php echo translate('BadFPSReportInterval') ?>"; if ( form.elements['newMonitor[Type]'].value == 'Local' )
if ( !form.elements['newMonitor[FrameSkip]'].value || !(parseInt(form.elements['newMonitor[FrameSkip]'].value) >= 0 ) ) if ( !form.elements['newMonitor[SignalCheckColour]'].value || !form.elements['newMonitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
errors[errors.length] = "<?php echo translate('BadFrameSkip') ?>"; errors[errors.length] = "<?php echo translate('BadSignalCheckColour') ?>";
if ( !form.elements['newMonitor[MotionFrameSkip]'].value || !(parseInt(form.elements['newMonitor[MotionFrameSkip]'].value) >= 0 ) ) if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
errors[errors.length] = "<?php echo translate('BadMotionFrameSkip') ?>"; errors[errors.length] = "<?php echo translate('BadWebColour') ?>";
if ( form.elements['newMonitor[Type]'].value == 'Local' )
if ( !form.elements['newMonitor[SignalCheckColour]'].value || !form.elements['newMonitor[SignalCheckColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
errors[errors.length] = "<?php echo translate('BadSignalCheckColour') ?>";
if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
errors[errors.length] = "<?php echo translate('BadWebColour') ?>";
if ( errors.length ) if ( errors.length ) {
{ alert( errors.join( "\n" ) );
alert( errors.join( "\n" ) ); return( false );
return( false ); }
} return( true );
return( true );
} }
function updateLinkedMonitors( element ) function updateLinkedMonitors( element ) {
{ var form = element.form;
var form = element.form; var monitorIds = new Array();
var monitorIds = new Array(); for ( var i = 0; i < element.options.length; i++ )
for ( var i = 0; i < element.options.length; i++ ) if ( element.options[i].selected )
if ( element.options[i].selected ) monitorIds[monitorIds.length] = element.options[i].value;
monitorIds[monitorIds.length] = element.options[i].value; form.elements['newMonitor[LinkedMonitors]'].value = monitorIds.join( ',' );
form.elements['newMonitor[LinkedMonitors]'].value = monitorIds.join( ',' );
} }
function updateMethods( element ) function updateMethods( element ) {
{ var form = element.form;
var form = element.form;
var origMethod = form.elements['origMethod']; var origMethod = form.elements['origMethod'];
var methodSelector = form.elements['newMonitor[Method]']; var methodSelector = form.elements['newMonitor[Method]'];
methodSelector.options.length = 0; methodSelector.options.length = 0;
switch ( element.value ) switch ( element.value ) {
{ case 'http' :
case 'http' : {
{ <?php
<?php foreach( $httpMethods as $value=>$label ) {
foreach( $httpMethods as $value=>$label ) ?>
{ methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
?>
methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
if ( origMethod.value == "<?php echo $value ?>" ) if ( origMethod.value == "<?php echo $value ?>" )
methodSelector.selectedIndex = methodSelector.options.length-1; methodSelector.selectedIndex = methodSelector.options.length-1;
<?php <?php
} }
?> ?>
break; break;
} }
case 'rtsp' : case 'rtsp' :
{ {
<?php <?php
foreach( $rtspMethods as $value=>$label ) foreach( $rtspMethods as $value=>$label ) {
{ ?>
?> methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
methodSelector.options[methodSelector.options.length] = new Option( "<?php echo htmlspecialchars($label) ?>", "<?php echo $value ?>" );
if ( origMethod.value == "<?php echo $value ?>" ) if ( origMethod.value == "<?php echo $value ?>" )
methodSelector.selectedIndex = form.elements['newMonitor[Method]'].options.length-1; methodSelector.selectedIndex = form.elements['newMonitor[Method]'].options.length-1;
<?php <?php
} }
?> ?>
break; break;
} }
} }
return( true ); return( true );
} }

View File

@ -1,14 +1,12 @@
function submitPreset( element ) function submitPreset( element ) {
{ var form = element.form;
var form = element.form; form.target = opener.name;
form.target = opener.name; form.view.value = 'monitor';
form.view.value = 'monitor'; form.submit();
form.submit(); closeWindow.delay( 250 );
closeWindow.delay( 250 );
} }
function configureButtons( element ) function configureButtons( element ) {
{ var form = element.form;
var form = element.form; form.saveBtn.disabled = (form.preset.selectedIndex==0);
form.saveBtn.disabled = (form.preset.selectedIndex==0);
} }

View File

@ -1,14 +1,12 @@
function submitCamera( element ) function submitCamera( element ) {
{ var form = element.form;
var form = element.form; form.target = opener.name;
form.target = opener.name; form.view.value = 'monitor';
form.view.value = 'monitor'; form.submit();
form.submit(); closeWindow.delay( 250 );
closeWindow.delay( 250 );
} }
function configureButtons( element ) function configureButtons( element ) {
{ var form = element.form;
var form = element.form; form.saveBtn.disabled = (form.probe.selectedIndex==0);
form.saveBtn.disabled = (form.probe.selectedIndex==0);
} }

View File

@ -1,209 +1,191 @@
var requestQueue = new Request.Queue( { concurrent: 2 } ); var requestQueue = new Request.Queue( { concurrent: 2 } );
function Monitor( monitorData ) function Monitor( monitorData ) {
{ this.id = monitorData.id;
this.id = monitorData.id; this.connKey = monitorData.connKey;
this.connKey = monitorData.connKey; this.server_url = monitorData.server_url;
this.server_url = monitorData.server_url; this.status = null;
this.status = null; this.alarmState = STATE_IDLE;
this.alarmState = STATE_IDLE; this.lastAlarmState = STATE_IDLE;
this.lastAlarmState = STATE_IDLE; this.streamCmdParms = "view=request&request=stream&connkey="+this.connKey;
this.streamCmdParms = "view=request&request=stream&connkey="+this.connKey; this.streamCmdTimer = null;
this.streamCmdTimer = null;
this.start = function( delay ) this.start = function( delay ) {
{ this.streamCmdTimer = this.streamCmdQuery.delay( delay, this );
this.streamCmdTimer = this.streamCmdQuery.delay( delay, this ); };
};
this.setStateClass = function( element, stateClass ) this.setStateClass = function( element, stateClass ) {
{ if ( !element.hasClass( stateClass ) ) {
if ( !element.hasClass( stateClass ) ) if ( stateClass != 'alarm' )
{ element.removeClass( 'alarm' );
if ( stateClass != 'alarm' ) if ( stateClass != 'alert' )
element.removeClass( 'alarm' ); element.removeClass( 'alert' );
if ( stateClass != 'alert' ) if ( stateClass != 'idle' )
element.removeClass( 'alert' ); element.removeClass( 'idle' );
if ( stateClass != 'idle' ) element.addClass( stateClass );
element.removeClass( 'idle' ); }
element.addClass( stateClass ); };
this.getStreamCmdResponse = function( respObj, respText ) {
if ( this.streamCmdTimer )
this.streamCmdTimer = clearTimeout( this.streamCmdTimer );
var stream = document.getElementById( "liveStream"+this.id );
if ( respObj.result == 'Ok' ) {
this.status = respObj.status;
this.alarmState = this.status.state;
var stateClass = "";
if ( this.alarmState == STATE_ALARM )
stateClass = "alarm";
else if ( this.alarmState == STATE_ALERT )
stateClass = "alert";
else
stateClass = "idle";
if ( !COMPACT_MONTAGE ) {
$('fpsValue'+this.id).set( 'text', this.status.fps );
$('stateValue'+this.id).set( 'text', stateStrings[this.alarmState] );
this.setStateClass( $('monitorState'+this.id), stateClass );
}
this.setStateClass( $('monitor'+this.id), stateClass );
/*Stream could be an applet so can't use moo tools*/
stream.className = stateClass;
var isAlarmed = ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT );
var wasAlarmed = ( this.lastAlarmState == STATE_ALARM || this.lastAlarmState == STATE_ALERT );
var newAlarm = ( isAlarmed && !wasAlarmed );
var oldAlarm = ( !isAlarmed && wasAlarmed );
if ( newAlarm ) {
if ( false && SOUND_ON_ALARM ) {
// Enable the alarm sound
$('alarmSound').removeClass( 'hidden' );
} }
}; if ( POPUP_ON_ALARM ) {
windowToFront();
this.getStreamCmdResponse = function( respObj, respText )
{
if ( this.streamCmdTimer )
this.streamCmdTimer = clearTimeout( this.streamCmdTimer );
var stream = document.getElementById( "liveStream"+this.id );
if ( respObj.result == 'Ok' )
{
this.status = respObj.status;
this.alarmState = this.status.state;
var stateClass = "";
if ( this.alarmState == STATE_ALARM )
stateClass = "alarm";
else if ( this.alarmState == STATE_ALERT )
stateClass = "alert";
else
stateClass = "idle";
if ( !COMPACT_MONTAGE )
{
$('fpsValue'+this.id).set( 'text', this.status.fps );
$('stateValue'+this.id).set( 'text', stateStrings[this.alarmState] );
this.setStateClass( $('monitorState'+this.id), stateClass );
}
this.setStateClass( $('monitor'+this.id), stateClass );
/*Stream could be an applet so can't use moo tools*/
stream.className = stateClass;
var isAlarmed = ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT );
var wasAlarmed = ( this.lastAlarmState == STATE_ALARM || this.lastAlarmState == STATE_ALERT );
var newAlarm = ( isAlarmed && !wasAlarmed );
var oldAlarm = ( !isAlarmed && wasAlarmed );
if ( newAlarm )
{
if ( false && SOUND_ON_ALARM )
{
// Enable the alarm sound
$('alarmSound').removeClass( 'hidden' );
}
if ( POPUP_ON_ALARM )
{
windowToFront();
}
}
if ( false && SOUND_ON_ALARM )
{
if ( oldAlarm )
{
// Disable alarm sound
$('alarmSound').addClass( 'hidden' );
}
}
if ( this.status.auth ) {
// Try to reload the image stream.
if ( stream )
stream.src = stream.src.replace( /auth=\w+/i, 'auth='+this.status.auth );
console.log("Changed auth to " + this.status.auth );
} // end if haev a new auth hash
} }
else }
{ if ( false && SOUND_ON_ALARM ) {
console.error( respObj.message ); if ( oldAlarm ) {
// Try to reload the image stream. // Disable alarm sound
if ( stream ) $('alarmSound').addClass( 'hidden' );
stream.src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
} }
var streamCmdTimeout = statusRefreshTimeout; }
if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT ) if ( this.status.auth ) {
streamCmdTimeout = streamCmdTimeout/5; // Try to reload the image stream.
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this ); if ( stream )
this.lastAlarmState = this.alarmState; stream.src = stream.src.replace( /auth=\w+/i, 'auth='+this.status.auth );
}; console.log("Changed auth to " + this.status.auth );
} // end if haev a new auth hash
} else {
console.error( respObj.message );
// Try to reload the image stream.
if ( stream )
stream.src = stream.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
}
var streamCmdTimeout = statusRefreshTimeout;
if ( this.alarmState == STATE_ALARM || this.alarmState == STATE_ALERT )
streamCmdTimeout = streamCmdTimeout/5;
this.streamCmdTimer = this.streamCmdQuery.delay( streamCmdTimeout, this );
this.lastAlarmState = this.alarmState;
};
this.streamCmdQuery = function( resent ) this.streamCmdQuery = function( resent ) {
{ //if ( resent )
//if ( resent ) //console.log( this.connKey+": Resending" );
//console.log( this.connKey+": Resending" ); //this.streamCmdReq.cancel();
//this.streamCmdReq.cancel(); this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY );
this.streamCmdReq.send( this.streamCmdParms+"&command="+CMD_QUERY ); };
};
this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } ); this.streamCmdReq = new Request.JSON( { url: this.server_url, method: 'get', timeout: AJAX_TIMEOUT, onSuccess: this.getStreamCmdResponse.bind( this ), onTimeout: this.streamCmdQuery.bind( this, true ), link: 'cancel' } );
requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq ); requestQueue.addRequest( "cmdReq"+this.id, this.streamCmdReq );
} }
function selectLayout( element ) function selectLayout( element ) {
{ var cssFile = skinPath+'/css/'+Cookie.read('zmCSS')+'/views/'+$(element).get('value');
var cssFile = skinPath+'/css/'+Cookie.read('zmCSS')+'/views/'+$(element).get('value'); if ( $('dynamicStyles') )
if ( $('dynamicStyles') ) $('dynamicStyles').destroy();
$('dynamicStyles').destroy(); new Asset.css( cssFile, { id: 'dynamicStyles' } );
new Asset.css( cssFile, { id: 'dynamicStyles' } ); Cookie.write( 'zmMontageLayout', $(element).get('value'), { duration: 10*365 } );
Cookie.write( 'zmMontageLayout', $(element).get('value'), { duration: 10*365 } );
} }
function changeWidth() { function changeWidth() {
var width = $('width').get('value'); var width = $('width').get('value');
for ( var x = 0; x < monitors.length; x++ ) { for ( var x = 0; x < monitors.length; x++ ) {
var monitor = monitors[x]; var monitor = monitors[x];
/*Stream could be an applet so can't use moo tools*/ /*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById( 'liveStream'+monitor.id ); var streamImg = document.getElementById( 'liveStream'+monitor.id );
if ( streamImg ) { if ( streamImg ) {
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
streamImg.style.width = width + "px"; streamImg.style.width = width + "px";
streamImg.style.height = ''; streamImg.style.height = '';
}
} }
$('scale').set('value', '' ); }
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } ); $('scale').set('value', '' );
Cookie.write( 'zmMontageWidth', width, { duration: 10*365 } ); Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
Cookie.write( 'zmMontageWidth', width, { duration: 10*365 } );
} // end function changeWidth() } // end function changeWidth()
function changeHeight() { function changeHeight() {
var height = $('height').get('value'); var height = $('height').get('value');
for ( var x = 0; x < monitors.length; x++ ) { for ( var x = 0; x < monitors.length; x++ ) {
var monitor = monitors[x]; var monitor = monitors[x];
/*Stream could be an applet so can't use moo tools*/ /*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById( 'liveStream'+monitor.id ); var streamImg = document.getElementById( 'liveStream'+monitor.id );
if ( streamImg ) { if ( streamImg ) {
streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); streamImg.src = streamImg.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
streamImg.style.height = height + "px"; streamImg.style.height = height + "px";
}
} }
$('scale').set('value', '' ); }
Cookie.write( 'zmMontageHeight', height, { duration: 10*365 } ); $('scale').set('value', '' );
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } ); Cookie.write( 'zmMontageHeight', height, { duration: 10*365 } );
Cookie.write( 'zmMontageScale', '', { duration: 10*365 } );
} // end function changeHeight() } // end function changeHeight()
function changeScale() { function changeScale() {
var scale = $('scale').get('value'); var scale = $('scale').get('value');
for ( var x = 0; x < monitors.length; x++ ) { for ( var x = 0; x < monitors.length; x++ ) {
var monitor = monitors[x]; var monitor = monitors[x];
var newWidth = ( monitorData[x].width * scale ) / SCALE_BASE; var newWidth = ( monitorData[x].width * scale ) / SCALE_BASE;
var newHeight = ( monitorData[x].height * scale ) / SCALE_BASE; var newHeight = ( monitorData[x].height * scale ) / SCALE_BASE;
/*Stream could be an applet so can't use moo tools*/ /*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById( 'liveStream'+monitor.id ); var streamImg = document.getElementById( 'liveStream'+monitor.id );
if ( streamImg ) { if ( streamImg ) {
var src = streamImg.src; var src = streamImg.src;
streamImg.src=''; streamImg.src='';
streamImg.style.width = newWidth + "px"; streamImg.style.width = newWidth + "px";
streamImg.style.height = newHeight + "px"; streamImg.style.height = newHeight + "px";
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); //src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
src = src.replace(/scale=[\.\d]+/i,'scale='+ scale ); src = src.replace(/scale=[\.\d]+/i,'scale='+ scale );
src = src.replace(/width=[\.\d]+/i,'width='+newWidth ); src = src.replace(/width=[\.\d]+/i,'width='+newWidth );
src = src.replace(/height=[\.\d]+/i,'height='+newHeight ); src = src.replace(/height=[\.\d]+/i,'height='+newHeight );
streamImg.src = src; streamImg.src = src;
}
} }
$('width').set('value', ''); }
$('height').set('value', ''); $('width').set('value', '');
Cookie.write( 'zmMontageScale', scale, { duration: 10*365 } ); $('height').set('value', '');
Cookie.write( 'zmMontageWidth', '', { duration: 10*365 } ); Cookie.write( 'zmMontageScale', scale, { duration: 10*365 } );
Cookie.write( 'zmMontageHeight', '', { duration: 10*365 } ); Cookie.write( 'zmMontageWidth', '', { duration: 10*365 } );
Cookie.write( 'zmMontageHeight', '', { duration: 10*365 } );
} }
var monitors = new Array(); var monitors = new Array();
function initPage() function initPage() {
{ for ( var i = 0; i < monitorData.length; i++ ) {
for ( var i = 0; i < monitorData.length; i++ ) monitors[i] = new Monitor( monitorData[i] );
{ var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
monitors[i] = new Monitor( monitorData[i] ); monitors[i].start( delay );
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout ); }
monitors[i].start( delay ); selectLayout( $('layout') );
}
selectLayout( $('layout') );
} }
// Kick everything off // Kick everything off

View File

@ -28,8 +28,7 @@ var canStreamNative = <?php echo canStreamNative()?'true':'false' ?>;
var monitorData = new Array(); var monitorData = new Array();
<?php <?php
foreach ( $monitors as $monitor ) foreach ( $monitors as $monitor ) {
{
?> ?>
monitorData[monitorData.length] = { monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>, 'id': <?php echo $monitor->Id() ?>,

View File

@ -1,39 +1,35 @@
function submitCamera( element ) function submitCamera( element ) {
{ var form = element.form;
var form = element.form; form.target = opener.name;
form.target = opener.name; form.view.value = 'monitor';
form.view.value = 'monitor'; form.submit();
form.submit(); closeWindow.delay( 250 );
closeWindow.delay( 250 );
} }
function gotoStep1( element ) function gotoStep1( element ) {
{ var form = element.form;
var form = element.form; form.target = self.name;
form.target = self.name; form.view.value = 'onvifprobe';
form.view.value = 'onvifprobe'; form.step.value = '1';
form.step.value = '1'; form.submit();
form.submit();
} }
function gotoStep2( element ) function gotoStep2( element ) {
{ var form = element.form;
var form = element.form; form.target = self.name;
form.target = self.name; form.view.value = 'onvifprobe';
form.view.value = 'onvifprobe'; form.step.value = '2';
form.step.value = '2'; form.submit();
form.submit();
} }
function configureButtons( element ) function configureButtons( element ) {
{ var form = element.form;
var form = element.form; if (form.elements.namedItem("nextBtn")) {
if(form.elements.namedItem("nextBtn")) { form.nextBtn.disabled = (form.probe.selectedIndex==0) ||
form.nextBtn.disabled = (form.probe.selectedIndex==0) || (form.username == "") || (form.username == null) ||
(form.username == "") || (form.username == null) || (form.password == "") || (form.password == null);
(form.password == "") || (form.password == null); }
} if(form.elements.namedItem("saveBtn")) {
if(form.elements.namedItem("saveBtn")) { form.saveBtn.disabled = (form.probe.selectedIndex==0);
form.saveBtn.disabled = (form.probe.selectedIndex==0); }
}
} }

View File

@ -1,5 +1,4 @@
var restartWarning = <?php echo empty($restartWarning)?'false':'true' ?>; var restartWarning = <?php echo empty($restartWarning)?'false':'true' ?>;
if ( restartWarning ) if ( restartWarning ) {
{ alert( "<?php echo translate('OptionRestartWarning') ?>" );
alert( "<?php echo translate('OptionRestartWarning') ?>" );
} }

View File

@ -1,29 +1,22 @@
function validateForm( form ) function validateForm( form ) {
{ return( true );
return( true );
} }
function submitForm( form ) function submitForm( form ) {
{ form.submit();
form.submit();
} }
function limitRange( field, minValue, maxValue ) function limitRange( field, minValue, maxValue ) {
{ if ( parseInt(field.value) < parseInt(minValue) ) {
if ( parseInt(field.value) < parseInt(minValue) ) field.value = minValue;
{ } else if ( parseInt(field.value) > parseInt(maxValue) ) {
field.value = minValue; field.value = maxValue;
} }
else if ( parseInt(field.value) > parseInt(maxValue) )
{
field.value = maxValue;
}
} }
function initPage() function initPage() {
{ return( true );
return( true );
} }
window.addEvent( 'domready', initPage ); window.addEvent( 'domready', initPage );

View File

@ -9,8 +9,7 @@
?> ?>
( (
function () function () {
{
// Append '?(GET query)' to URL if the GET query is not empty. // Append '?(GET query)' to URL if the GET query is not empty.
var querySuffix = "<?php var querySuffix = "<?php
if (!empty($_POST["postLoginQuery"])) { if (!empty($_POST["postLoginQuery"])) {

View File

@ -1,11 +1,11 @@
function validateForm( form, newServer ) { function validateForm( form, newServer ) {
var errors = new Array(); var errors = new Array();
if ( !form.elements['newServer[Name]'].value ) { if ( !form.elements['newServer[Name]'].value ) {
errors[errors.length] = "You must supply a name"; errors[errors.length] = "You must supply a name";
} }
if ( errors.length ) { if ( errors.length ) {
alert( errors.join( "\n" ) ); alert( errors.join( "\n" ) );
return( false ); return( false );
} }
return( true ); return( true );
} }

View File

@ -1,4 +1,3 @@
<<<<<<< HEAD
$j(document).ready(function() { $j(document).ready(function() {
// Enable or disable the Delete button depending on the selected run state // Enable or disable the Delete button depending on the selected run state
$j("#runState").change(function() { $j("#runState").change(function() {
@ -62,64 +61,6 @@ $j(document).ready(function() {
location.reload(); location.reload();
}); });
} }
}); });
=======
function checkState( element )
{
var form = element.form;
var minIndex = running?2:1;
if ( form.runState.selectedIndex < minIndex )
{
form.saveBtn.disabled = true;
form.deleteBtn.disabled = true;
}
else
{
form.saveBtn.disabled = false;
form.deleteBtn.disabled = false;
}
if ( form.newState.value != '' )
form.saveBtn.disabled = false;
// PP if we are in 'default' state, disable delete
// you can still save
if (element.value.toLowerCase() == 'default' )
{
form.saveBtn.disabled = false;
form.deleteBtn.disabled = true;
}
}
function saveState( element )
{
var form = element.form;
form.view.value = currentView;
form.action.value = 'save';
form.submit();
}
function deleteState( element )
{
var form = element.form;
form.view.value = currentView;
form.action.value = 'delete';
form.submit();
}
if ( applying )
{
function submitForm()
{
$('contentForm').submit();
}
window.addEvent( 'domready', function() { submitForm.delay( 1000 ); } );
}
>>>>>>> master

View File

@ -1,36 +1,26 @@
function validateForm( form, newUser ) function validateForm( form, newUser ) {
{ var errors = new Array();
var errors = new Array(); if ( !form.elements['newUser[Username]'].value ) {
if ( !form.elements['newUser[Username]'].value ) errors[errors.length] = "You must supply a username";
{ }
errors[errors.length] = "You must supply a username"; if ( form.elements['newUser[Password]'].value ) {
if ( !form.conf_password.value ) {
errors[errors.length] = "You must confirm the password";
} else if ( form.elements['newUser[Password]'].value != form.conf_password.value ) {
errors[errors.length] = "The new and confirm passwords are different";
} }
if ( form.elements['newUser[Password]'].value ) } else if ( newUser ) {
{ errors[errors.length] = "You must supply a password";
if ( !form.conf_password.value ) }
{ var monitorIds = new Array();
errors[errors.length] = "You must confirm the password"; for ( var i = 0; i < form.elements['monitorIds'].options.length; i++ ) {
} if ( form.elements['monitorIds'].options[i].selected )
else if ( form.elements['newUser[Password]'].value != form.conf_password.value ) monitorIds[monitorIds.length] = form.elements['monitorIds'].options[i].value;
{ }
errors[errors.length] = "The new and confirm passwords are different"; form.elements['newUser[MonitorIds]'].value = monitorIds.join( ',' );
} if ( errors.length ) {
} alert( errors.join( "\n" ) );
else if ( newUser ) return( false );
{ }
errors[errors.length] = "You must supply a password"; return( true );
}
var monitorIds = new Array();
for ( var i = 0; i < form.elements['monitorIds'].options.length; i++ )
{
if ( form.elements['monitorIds'].options[i].selected )
monitorIds[monitorIds.length] = form.elements['monitorIds'].options[i].value;
}
form.elements['newUser[MonitorIds]'].value = monitorIds.join( ',' );
if ( errors.length )
{
alert( errors.join( "\n" ) );
return( false );
}
return( true );
} }

View File

@ -1,18 +1,13 @@
function submitForm( element ) function submitForm( element ) {
{ var form = element.form;
var form = element.form; if ( form.option.selectedIndex == 0 ) {
if ( form.option.selectedIndex == 0 ) form.view.value = currentView;
{ } else {
form.view.value = currentView; form.view.value = 'none';
} }
else
{
form.view.value = 'none';
}
} }
if ( openZmWindow ) if ( openZmWindow ) {
{ zmWindow();
zmWindow();
} }

View File

@ -1,38 +1,33 @@
function deleteVideo( index ) function deleteVideo( index ) {
{ window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&deleteIndex='+index );
window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&deleteIndex='+index );
} }
function downloadVideo( index ) function downloadVideo( index ) {
{ window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&downloadIndex='+index );
window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&downloadIndex='+index );
} }
var generateVideoTimer = null; var generateVideoTimer = null;
function generateVideoProgress() function generateVideoProgress() {
{ var tickerText = $('videoProgressTicker').get('text');
var tickerText = $('videoProgressTicker').get('text'); if ( tickerText.length < 1 || tickerText.length > 4 )
if ( tickerText.length < 1 || tickerText.length > 4 ) $('videoProgressTicker').set( 'text', '.' );
$('videoProgressTicker').set( 'text', '.' ); else
else $('videoProgressTicker').appendText( '.' );
$('videoProgressTicker').appendText( '.' );
} }
function generateVideoResponse( respObj, respText ) function generateVideoResponse( respObj, respText ) {
{ window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&generated='+((respObj.result=='Ok')?1:0) );
window.location.replace( thisUrl+'?view='+currentView+'&eid='+eventId+'&generated='+((respObj.result=='Ok')?1:0) );
} }
function generateVideo( form ) function generateVideo( form ) {
{ var parms = 'view=request&request=event&action=video';
var parms = 'view=request&request=event&action=video'; parms += '&'+$(form).toQueryString();
parms += '&'+$(form).toQueryString(); var query = new Request.JSON( { url: thisUrl, method: 'post', data: parms, onSuccess: generateVideoResponse } );
var query = new Request.JSON( { url: thisUrl, method: 'post', data: parms, onSuccess: generateVideoResponse } ); query.send();
query.send(); $('videoProgress').removeClass( 'hidden' );
$('videoProgress').removeClass( 'hidden' ); $('videoProgress').setProperty( 'class', 'warnText' );
$('videoProgress').setProperty( 'class', 'warnText' ); $('videoProgressText').set( 'text', videoGenProgressString );
$('videoProgressText').set( 'text', videoGenProgressString ); generateVideoProgress();
generateVideoProgress(); generateVideoTimer = generateVideoProgress.periodical( 500 );
generateVideoTimer = generateVideoProgress.periodical( 500 );
} }

View File

@ -1,4 +1,3 @@
<<<<<<< HEAD
function setButtonState( element, butClass ) { function setButtonState( element, butClass ) {
element.className = butClass; element.className = butClass;
element.disabled = (butClass != 'inactive'); element.disabled = (butClass != 'inactive');
@ -37,58 +36,10 @@ function changeScale() {
streamImg.style.width = newWidth + "px"; streamImg.style.width = newWidth + "px";
streamImg.style.height = newHeight + "px"; streamImg.style.height = newHeight + "px";
streamImg.src = streamImg.src.replace(/scale=\d+/i,'scale='+scale); streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+scale);
} else { } else {
console.error("No element found for liveStream."); console.error("No element found for liveStream.");
} }
=======
function setButtonState( element, butClass )
{
element.className = butClass;
element.disabled = (butClass != 'inactive');
}
function showEvents()
{
$('ptzControls').addClass( 'hidden' );
$('events').removeClass( 'hidden' );
if ( $('eventsControl') )
$('eventsControl').addClass('hidden');
if ( $('controlControl') )
$('controlControl').removeClass('hidden');
showMode = "events";
}
function showPtzControls()
{
$('events').addClass( 'hidden' );
$('ptzControls').removeClass( 'hidden' );
if ( $('eventsControl') )
$('eventsControl').removeClass('hidden');
if ( $('controlControl') )
$('controlControl').addClass('hidden');
showMode = "control";
}
function changeScale()
{
var scale = $('scale').get('value');
var newWidth = ( monitorWidth * scale ) / SCALE_BASE;
var newHeight = ( monitorHeight * scale ) / SCALE_BASE;
Cookie.write( 'zmWatchScale'+monitorId, scale, { duration: 10*365 } );
/*Stream could be an applet so can't use moo tools*/
var streamImg = document.getElementById('liveStream');
if ( streamImg ) {
streamImg.style.width = newWidth + "px";
streamImg.style.height = newHeight + "px";
streamImg.src = streamImg.src.replace(/scale=\d+/i, 'scale='+scale);
} else {
console.error("No element found for liveStream.");
}
>>>>>>> master
} }
var alarmState = STATE_IDLE; var alarmState = STATE_IDLE;
@ -192,64 +143,10 @@ function getStreamCmdResponse( respObj, respText ) {
if ( streamStatus.rate < 1 ) if ( streamStatus.rate < 1 )
streamCmdSlowFwd( false ); streamCmdSlowFwd( false );
else else
<<<<<<< HEAD
streamCmdFastFwd( false ); streamCmdFastFwd( false );
} else { } else {
if ( streamStatus.rate > -1 ) if ( streamStatus.rate > -1 )
streamCmdSlowRev( false ); streamCmdSlowRev( false );
=======
$('levelValue').className = "ok";
var delayString = secsToTime( streamStatus.delay );
if ( streamStatus.paused == true )
{
$('modeValue').set( 'text', "Paused" );
$('rate').addClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
streamCmdPause( false );
}
else if ( streamStatus.delayed == true )
{
$('modeValue').set( 'text', "Replay" );
$('rateValue').set( 'text', streamStatus.rate );
$('rate').removeClass( 'hidden' );
$('delayValue').set( 'text', delayString );
$('delay').removeClass( 'hidden' );
$('level').removeClass( 'hidden' );
if ( streamStatus.rate == 1 )
{
streamCmdPlay( false );
}
else if ( streamStatus.rate > 0 )
{
if ( streamStatus.rate < 1 )
streamCmdSlowFwd( false );
else
streamCmdFastFwd( false );
}
else
{
if ( streamStatus.rate > -1 )
streamCmdSlowRev( false );
else
streamCmdFastRev( false );
}
}
else
{
$('modeValue').set( 'text', "Live" );
$('rate').addClass( 'hidden' );
$('delay').addClass( 'hidden' );
$('level').addClass( 'hidden' );
streamCmdPlay( false );
}
$('zoomValue').set( 'text', streamStatus.zoom );
if ( streamStatus.zoom == "1.0" )
setButtonState( $('zoomOutBtn'), 'unavail' );
>>>>>>> master
else else
streamCmdFastRev( false ); streamCmdFastRev( false );
} // rate } // rate
@ -304,29 +201,13 @@ function getStreamCmdResponse( respObj, respText ) {
} else { } else {
console.log("Unable to find streamImg liveStream"); console.log("Unable to find streamImg liveStream");
} }
<<<<<<< HEAD
} }
var streamCmdTimeout = statusRefreshTimeout; var streamCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
streamCmdTimeout = streamCmdTimeout/5; streamCmdTimeout = streamCmdTimeout/5;
streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout ); streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout );
}
=======
else {
checkStreamForErrors("getStreamCmdResponse", respObj);//log them
// Try to reload the image stream.
var streamImg = document.getElementById('liveStream');
if ( streamImg )
streamImg.src = streamImg.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
}
var streamCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
streamCmdTimeout = streamCmdTimeout/5;
streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout );
} }
>>>>>>> master
function streamCmdPause( action ) { function streamCmdPause( action ) {
setButtonState( $('pauseBtn'), 'active' ); setButtonState( $('pauseBtn'), 'active' );
@ -355,7 +236,6 @@ function streamCmdPlay( action ) {
setButtonState( $('slowFwdBtn'), 'unavail' ); setButtonState( $('slowFwdBtn'), 'unavail' );
setButtonState( $('slowRevBtn'), 'unavail' ); setButtonState( $('slowRevBtn'), 'unavail' );
setButtonState( $('fastRevBtn'), 'unavail' ); setButtonState( $('fastRevBtn'), 'unavail' );
<<<<<<< HEAD
} }
if ( action ) if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_PLAY ); streamCmdReq.send( streamCmdParms+"&command="+CMD_PLAY );
@ -445,169 +325,43 @@ function streamCmdPan( x, y ) {
function streamCmdQuery() { function streamCmdQuery() {
streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY ); streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY );
}
=======
if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_STOP );
setButtonState( $('stopBtn'), 'unavail' );
setButtonState( $('playBtn'), 'active' );
} }
function streamCmdFastFwd( action )
{
setButtonState( $('pauseBtn'), 'inactive' );
setButtonState( $('playBtn'), 'inactive' );
setButtonState( $('stopBtn'), 'inactive' );
setButtonState( $('fastFwdBtn'), 'inactive' );
setButtonState( $('slowFwdBtn'), 'inactive' );
setButtonState( $('slowRevBtn'), 'inactive' );
setButtonState( $('fastRevBtn'), 'inactive' );
if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_FASTFWD );
}
function streamCmdSlowFwd( action )
{
setButtonState( $('pauseBtn'), 'inactive' );
setButtonState( $('playBtn'), 'inactive' );
setButtonState( $('stopBtn'), 'inactive' );
setButtonState( $('fastFwdBtn'), 'inactive' );
setButtonState( $('slowFwdBtn'), 'active' );
setButtonState( $('slowRevBtn'), 'inactive' );
setButtonState( $('fastRevBtn'), 'inactive' );
if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_SLOWFWD );
setButtonState( $('pauseBtn'), 'active' );
setButtonState( $('slowFwdBtn'), 'inactive' );
}
function streamCmdSlowRev( action )
{
setButtonState( $('pauseBtn'), 'inactive' );
setButtonState( $('playBtn'), 'inactive' );
setButtonState( $('stopBtn'), 'inactive' );
setButtonState( $('fastFwdBtn'), 'inactive' );
setButtonState( $('slowFwdBtn'), 'inactive' );
setButtonState( $('slowRevBtn'), 'active' );
setButtonState( $('fastRevBtn'), 'inactive' );
if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_SLOWREV );
setButtonState( $('pauseBtn'), 'active' );
setButtonState( $('slowRevBtn'), 'inactive' );
}
function streamCmdFastRev( action )
{
setButtonState( $('pauseBtn'), 'inactive' );
setButtonState( $('playBtn'), 'inactive' );
setButtonState( $('stopBtn'), 'inactive' );
setButtonState( $('fastFwdBtn'), 'inactive' );
setButtonState( $('slowFwdBtn'), 'inactive' );
setButtonState( $('slowRevBtn'), 'inactive' );
setButtonState( $('fastRevBtn'), 'inactive' );
if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_FASTREV );
}
function streamCmdZoomIn( x, y )
{
streamCmdReq.send( streamCmdParms+"&command="+CMD_ZOOMIN+"&x="+x+"&y="+y );
}
function streamCmdZoomOut()
{
streamCmdReq.send( streamCmdParms+"&command="+CMD_ZOOMOUT );
}
function streamCmdScale( scale )
{
streamCmdReq.send( streamCmdParms+"&command="+CMD_SCALE+"&scale="+scale );
}
function streamCmdPan( x, y )
{
streamCmdReq.send( streamCmdParms+"&command="+CMD_PAN+"&x="+x+"&y="+y );
}
function streamCmdQuery()
{
streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY );
}
>>>>>>> master
var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate"; var statusCmdParms = "view=request&request=status&entity=monitor&id="+monitorId+"&element[]=Status&element[]=FrameRate";
if ( auth_hash ) if ( auth_hash )
statusCmdParms += '&auth='+auth_hash; statusCmdParms += '&auth='+auth_hash;
var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'get', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } ); var statusCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'get', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse } );
var statusCmdTimer = null; var statusCmdTimer = null;
<<<<<<< HEAD
function getStatusCmdResponse( respObj, respText ) { function getStatusCmdResponse( respObj, respText ) {
console.log("Got statusCmdQuery");
watchdogOk("status"); watchdogOk("status");
if ( statusCmdTimer ) if ( statusCmdTimer )
statusCmdTimer = clearTimeout( statusCmdTimer ); statusCmdTimer = clearTimeout( statusCmdTimer );
if ( respObj.result == 'Ok' ) { if ( respObj.result == 'Ok' ) {
console.log("Got ok for status");
$('fpsValue').set( 'text', respObj.monitor.FrameRate ); $('fpsValue').set( 'text', respObj.monitor.FrameRate );
setAlarmState( respObj.monitor.Status ); setAlarmState( respObj.monitor.Status );
} else { } else
console.log("Got bad response for status"); checkStreamForErrors("getStatusCmdResponse", respObj);
checkStreamForErrors("getStatusCmdResponse",respObj);
}
var statusCmdTimeout = statusRefreshTimeout; var statusCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
statusCmdTimeout = statusCmdTimeout/5; statusCmdTimeout = statusCmdTimeout/5;
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout ); statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
} }
function statusCmdQuery() { function statusCmdQuery() {
console.log("Sending statusCmdQuery");
statusCmdReq.send(); statusCmdReq.send();
}
=======
function getStatusCmdResponse( respObj, respText )
{
watchdogOk("status");
if ( statusCmdTimer )
statusCmdTimer = clearTimeout( statusCmdTimer );
if ( respObj.result == 'Ok' )
{
$('fpsValue').set( 'text', respObj.monitor.FrameRate );
setAlarmState( respObj.monitor.Status );
}
else
checkStreamForErrors("getStatusCmdResponse", respObj);
var statusCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
statusCmdTimeout = statusCmdTimeout/5;
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
} }
function statusCmdQuery()
{
statusCmdReq.send();
}
>>>>>>> master
var alarmCmdParms = "view=request&request=alarm&id="+monitorId; var alarmCmdParms = "view=request&request=alarm&id="+monitorId;
if ( auth_hash ) if ( auth_hash )
alarmCmdParms += '&auth='+auth_hash; alarmCmdParms += '&auth='+auth_hash;
var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } ); var alarmCmdReq = new Request.JSON( { url: monitorUrl+thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getAlarmCmdResponse, onTimeout: streamCmdQuery } );
var alarmCmdFirst = true; var alarmCmdFirst = true;
<<<<<<< HEAD
function getAlarmCmdResponse( respObj, respText ) { function getAlarmCmdResponse( respObj, respText ) {
checkStreamForErrors("getAlarmCmdResponse",respObj); checkStreamForErrors("getAlarmCmdResponse", respObj);
=======
function getAlarmCmdResponse( respObj, respText )
{
checkStreamForErrors("getAlarmCmdResponse", respObj);
>>>>>>> master
} }
function cmdDisableAlarms() { function cmdDisableAlarms() {
@ -649,7 +403,6 @@ var eventCmdReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJA
var eventCmdTimer = null; var eventCmdTimer = null;
var eventCmdFirst = true; var eventCmdFirst = true;
<<<<<<< HEAD
function highlightRow( row ) { function highlightRow( row ) {
$(row).toggleClass( 'highlight' ); $(row).toggleClass( 'highlight' );
} }
@ -712,87 +465,6 @@ function getEventCmdResponse( respObj, respText ) {
row.inject( $(eventListBody), 'top' ); row.inject( $(eventListBody), 'top' );
if ( !eventCmdFirst ) if ( !eventCmdFirst )
row.addClass( 'recent' ); row.addClass( 'recent' );
=======
function highlightRow( row )
{
$(row).toggleClass( 'highlight' );
}
function getEventCmdResponse( respObj, respText )
{
watchdogOk("event");
if ( eventCmdTimer )
eventCmdTimer = clearTimeout( eventCmdTimer );
if ( respObj.result == 'Ok' )
{
var dbEvents = respObj.events.reverse();
var eventList = $('eventList');
var eventListBody = $(eventList).getElement( 'tbody' );
var eventListRows = $(eventListBody).getElements( 'tr' );
eventListRows.each( function( row ) { row.removeClass( 'updated' ); } );
for ( var i = 0; i < dbEvents.length; i++ )
{
var event = dbEvents[i];
var row = $('event'+event.Id);
var newEvent = (row == null ? true : false);
if ( newEvent )
{
row = new Element( 'tr', { 'id': 'event'+event.Id } );
new Element( 'td', { 'class': 'colId' } ).inject( row );
new Element( 'td', { 'class': 'colName' } ).inject( row );
new Element( 'td', { 'class': 'colTime' } ).inject( row );
new Element( 'td', { 'class': 'colSecs' } ).inject( row );
new Element( 'td', { 'class': 'colFrames' } ).inject( row );
new Element( 'td', { 'class': 'colScore' } ).inject( row );
new Element( 'td', { 'class': 'colDelete' } ).inject( row );
var cells = row.getElements( 'td' );
var link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height] ) } });
link.set( 'text', event.Id );
link.inject( row.getElement( 'td.colId' ) );
link = new Element( 'a', { 'href': '#', 'events': { 'click': createEventPopup.pass( [event.Id, '&trms=1&attr1=MonitorId&op1=%3d&val1='+monitorId+'&page=1', event.Width, event.Height] ) } });
link.set( 'text', event.Name );
link.inject( row.getElement( 'td.colName' ) );
row.getElement( 'td.colTime' ).set( 'text', event.StartTime );
row.getElement( 'td.colSecs' ).set( 'text', event.Length );
link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramesPopup.pass( [event.Id, event.Width, event.Height] ) } });
link.set( 'text', event.Frames+'/'+event.AlarmFrames );
link.inject( row.getElement( 'td.colFrames' ) );
link = new Element( 'a', { 'href': '#', 'events': { 'click': createFramePopup.pass( [event.Id, '0', event.Width, event.Height] ) } });
link.set( 'text', event.AvgScore+'/'+event.MaxScore );
link.inject( row.getElement( 'td.colScore' ) );
link = new Element( 'a', { 'href': '#', 'title': deleteString, 'events': { 'click': function( e ) { deleteEvent( e, event.Id ); }, 'mouseover': highlightRow.pass( row ), 'mouseout': highlightRow.pass( row ) } });
link.set( 'text', 'X' );
link.inject( row.getElement( 'td.colDelete' ) );
if ( i == 0 )
row.inject( $(eventListBody) );
else
{
row.inject( $(eventListBody), 'top' );
if ( !eventCmdFirst )
row.addClass( 'recent' );
}
}
else
{
row.getElement( 'td.colName a' ).set( 'text', event.Name );
row.getElement( 'td.colSecs' ).set( 'text', event.Length );
row.getElement( 'td.colFrames a' ).set( 'text', event.Frames+'/'+event.AlarmFrames );
row.getElement( 'td.colScore a' ).set( 'text', event.AvgScore+'/'+event.MaxScore );
row.removeClass( 'recent' );
}
row.addClass( 'updated' );
>>>>>>> master
} }
} else { } else {
row.getElement( 'td.colName a' ).set( 'text', event.Name ); row.getElement( 'td.colName a' ).set( 'text', event.Name );
@ -812,17 +484,12 @@ function getEventCmdResponse( respObj, respText )
i--; i--;
} }
} }
<<<<<<< HEAD
while ( rows.length > maxDisplayEvents ) { while ( rows.length > maxDisplayEvents ) {
rows[rows.length-1].destroy(); rows[rows.length-1].destroy();
rows.length--; rows.length--;
} }
} else } else
checkStreamForErrors("getEventCmdResponse",respObj); checkStreamForErrors("getEventCmdResponse", respObj);
=======
else
checkStreamForErrors("getEventCmdResponse", respObj);
>>>>>>> master
var eventCmdTimeout = eventsRefreshTimeout; var eventCmdTimeout = eventsRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
@ -863,7 +530,7 @@ function controlCmd( control, event, xtell, ytell ) {
var x = xEvent.page.x - l; var x = xEvent.page.x - l;
var y = xEvent.page.y - t; var y = xEvent.page.y - t;
if ( xtell ) { if ( xtell ) {
var xge = parseInt( (x*100)/coords.width ); var xge = parseInt( (x*100)/coords.width );
if ( xtell == -1 ) if ( xtell == -1 )
xge = 100 - xge; xge = 100 - xge;
@ -871,7 +538,6 @@ function controlCmd( control, event, xtell, ytell ) {
xge = 2*(50 - xge); xge = 2*(50 - xge);
locParms += "&xge="+xge; locParms += "&xge="+xge;
} }
<<<<<<< HEAD
if ( ytell ) { if ( ytell ) {
var yge = parseInt( (y*100)/coords.height ); var yge = parseInt( (y*100)/coords.height );
if ( ytell == -1 ) if ( ytell == -1 )
@ -879,42 +545,6 @@ function controlCmd( control, event, xtell, ytell ) {
else if ( ytell == 2 ) else if ( ytell == 2 )
yge = 2*(50 - yge); yge = 2*(50 - yge);
locParms += "&yge="+yge; locParms += "&yge="+yge;
=======
}
function controlCmd( control, event, xtell, ytell )
{
var locParms = "";
if ( event && (xtell || ytell) )
{
var xEvent = new Event( event );
var target = xEvent.target;
var coords = $(target).getCoordinates();
var l = coords.left;
var t = coords.top;
var x = xEvent.page.x - l;
var y = xEvent.page.y - t;
if ( xtell )
{
var xge = parseInt( (x*100)/coords.width );
if ( xtell == -1 )
xge = 100 - xge;
else if ( xtell == 2 )
xge = 2*(50 - xge);
locParms += "&xge="+xge;
}
if ( ytell )
{
var yge = parseInt( (y*100)/coords.height );
if ( ytell == -1 )
yge = 100 - yge;
else if ( ytell == 2 )
yge = 2*(50 - yge);
locParms += "&yge="+yge;
}
>>>>>>> master
} }
} }
controlReq.send( controlParms+"&control="+control+locParms ); controlReq.send( controlParms+"&control="+control+locParms );
@ -927,7 +557,6 @@ function controlCmdImage( x, y ) {
imageControlParms += "&scale="+scale; imageControlParms += "&scale="+scale;
imageControlParms += "&control="+imageControlMode; imageControlParms += "&control="+imageControlMode;
<<<<<<< HEAD
controlReq.send( imageControlParms+"&x="+x+"&y="+y ); controlReq.send( imageControlParms+"&x="+x+"&y="+y );
if ( streamMode == "single" ) if ( streamMode == "single" )
fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 ); fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 );
@ -935,40 +564,6 @@ function controlCmdImage( x, y ) {
function fetchImage( streamImage ) { function fetchImage( streamImage ) {
streamImage.src = streamImage.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); streamImage.src = streamImage.src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
=======
controlReq.send( imageControlParms+"&x="+x+"&y="+y );
if ( streamMode == "single" )
fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 );
}
var tempImage = null;
function fetchImage( streamImage )
{
var now = new Date();
if ( !tempImage )
tempImage = new Element( 'img' );
tempImage.setProperty( 'src', streamSrc+'&'+now.getTime() );
$(streamImage).setProperty( 'src', tempImage.getProperty( 'src' ) );
}
function handleClick( event )
{
var target = event.target;
var x = event.page.x - $(target).getLeft();
var y = event.page.y - $(target).getTop();
if ( showMode == "events" || !imageControlMode )
{
if ( event.shift )
streamCmdPan( x, y );
else
streamCmdZoomIn( x, y );
}
else
{
controlCmdImage( x, y );
}
>>>>>>> master
} }
function handleClick( event ) { function handleClick( event ) {
@ -1017,7 +612,6 @@ function watchdogCheck( type ) {
console.log( "Detected streamWatch of type: " + type + " stopped, restarting" ); console.log( "Detected streamWatch of type: " + type + " stopped, restarting" );
watchdogFunctions[type](); watchdogFunctions[type]();
watchdogInactive[type] = false; watchdogInactive[type] = false;
<<<<<<< HEAD
} else { } else {
watchdogInactive[type] = true; watchdogInactive[type] = true;
} }
@ -1052,42 +646,6 @@ function initPage() {
if ( refreshApplet && appletRefreshTime ) if ( refreshApplet && appletRefreshTime )
appletRefresh.delay( appletRefreshTime*1000 ); appletRefresh.delay( appletRefreshTime*1000 );
=======
}
function initPage()
{
if ( streamMode == "single" )
{
statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
watchdogCheck.pass('status').periodical(statusRefreshTimeout*2);
}
else
{
streamCmdTimer = streamCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
watchdogCheck.pass('stream').periodical(statusRefreshTimeout*2);
}
eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2);
if ( canStreamNative || streamMode == "single" )
{
var streamImg = $('imageFeed').getElement('img');
if ( !streamImg )
streamImg = $('imageFeed').getElement('object');
if ( streamMode == "single" )
{
streamImg.addEvent( 'click', fetchImage.pass( streamImg ) );
fetchImage.pass( streamImg ).periodical( imageRefreshTimeout );
}
else
streamImg.addEvent( 'click', function( event ) { handleClick( event ); } );
}
if ( refreshApplet && appletRefreshTime )
appletRefresh.delay( appletRefreshTime*1000 );
>>>>>>> master
} }
// Kick everything off // Kick everything off

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,6 @@
var presets = new Object(); var presets = new Object();
<?php <?php
foreach ( $presets as $preset ) foreach ( $presets as $preset ) {
{
?> ?>
presets[<?php echo $preset['Id'] ?>] = { presets[<?php echo $preset['Id'] ?>] = {
'UnitsIndex': <?php echo $preset['UnitsIndex'] ?>, 'UnitsIndex': <?php echo $preset['UnitsIndex'] ?>,
@ -38,8 +37,7 @@ var zone = {
zone['Points'] = new Array(); zone['Points'] = new Array();
<?php <?php
for ( $i = 0; $i < count($newZone['Points']); $i++ ) for ( $i = 0; $i < count($newZone['Points']); $i++ ) {
{
?> ?>
zone['Points'][<?php echo $i ?>] = { 'x': <?php echo $newZone['Points'][$i]['x'] ?>, 'y': <?php echo $newZone['Points'][$i]['y'] ?> }; zone['Points'][<?php echo $i ?>] = { 'x': <?php echo $newZone['Points'][$i]['x'] ?>, 'y': <?php echo $newZone['Points'][$i]['y'] ?> };
<?php <?php

View File

@ -18,12 +18,12 @@
// //
if ( !canView( 'Events' ) ) { if ( !canView( 'Events' ) ) {
$view = 'error'; $view = 'error';
return; return;
} }
foreach ( getSkinIncludes( 'includes/timeline_functions.php' ) as $includeFile ) foreach ( getSkinIncludes( 'includes/timeline_functions.php' ) as $includeFile )
require_once $includeFile; require_once $includeFile;
// //
// Date/time formats used in charts // Date/time formats used in charts
@ -64,11 +64,11 @@ define( "STRF_TL_AXIS_LABEL_SECOND", "%S" );
$mouseover = true; $mouseover = true;
if ( !isset($mouseover) ) if ( !isset($mouseover) )
$mouseover = true; $mouseover = true;
$mode = "overlay"; $mode = 'overlay';
if ( !isset($mode) ) if ( !isset($mode) )
$mode = "overlay"; $mode = 'overlay';
$minEventWidth = 3; $minEventWidth = 3;
$maxEventWidth = 6; $maxEventWidth = 6;
@ -77,74 +77,75 @@ $chart = array(
"width"=>700, "width"=>700,
"height"=>460, "height"=>460,
"image" => array( "image" => array(
"width"=>264, "width"=>264,
"height"=>220, "height"=>220,
"topOffset"=>20, "topOffset"=>20,
), ),
"imageText" => array( "imageText" => array(
"width"=>400, "width"=>400,
"height"=>30, "height"=>30,
"topOffset"=>20, "topOffset"=>20,
), ),
"graph" => array( "graph" => array(
"width"=>600, "width"=>600,
"height"=>160, "height"=>160,
"topOffset"=>30, "topOffset"=>30,
), ),
"title" => array( "title" => array(
"topOffset"=>50 "topOffset"=>50
), ),
"key" => array( "key" => array(
"topOffset"=>50 "topOffset"=>50
), ),
"axes" => array( "axes" => array(
"x" => array( "x" => array(
"height" => 20, "height" => 20,
), ),
"y" => array( "y" => array(
"width" => 30, "width" => 30,
),
), ),
),
"grid" => array( "grid" => array(
"x" => array( "x" => array(
"major" => array( "major" => array(
"max" => 12, "max" => 12,
"min" => 4, "min" => 4,
), ),
"minor" => array( "minor" => array(
"max" => 48, "max" => 48,
"min" => 12, "min" => 12,
), ),
), ),
"y" => array( "y" => array(
"major" => array( "major" => array(
"max" => 8, "max" => 8,
"min" => 1, "min" => 1,
), ),
"minor" => array( "minor" => array(
"max" => 0, "max" => 0,
"min" => 0, "min" => 0,
), ),
),
), ),
),
); );
$monitors = array(); $monitors = array();
$monitorsSql = "select * from Monitors order by Sequence asc"; $monitorsSql = 'SELECT * FROM Monitors ORDER BY Sequence ASC';
//srand( 97981 ); //srand( 97981 );
foreach( dbFetchAll( $monitorsSql ) as $row ) { foreach( dbFetchAll( $monitorsSql ) as $row ) {
//if ( empty($row['WebColour']) ) //if ( empty($row['WebColour']) )
//{ //{
//$row['WebColour'] = sprintf( "#%02x%02x%02x", rand( 0, 255 ), rand( 0, 255), rand( 0, 255 ) ); //$row['WebColour'] = sprintf( "#%02x%02x%02x", rand( 0, 255 ), rand( 0, 255), rand( 0, 255 ) );
//} //}
$monitors[$row['Id']] = $row; $monitors[$row['Id']] = $row;
} }
$rangeSql = 'SELECT min(StartTime) AS MinTime, max(EndTime) AS MaxTime FROM Events WHERE NOT isnull(StartTime) AND NOT isnull(EndTime)'; # The as E, and joining with Monitors is required for the filterSQL filters.
$eventsSql = 'SELECT * FROM Events WHERE NOT isnull(StartTime)'; $rangeSql = 'SELECT min(E.StartTime) AS MinTime, max(E.EndTime) AS MaxTime FROM Events AS E INNER JOIN Monitors AS M ON (E.MonitorId = M.Id) WHERE NOT isnull(E.StartTime) AND NOT isnull(E.EndTime)';
$eventsSql = 'SELECT * FROM Events AS E WHERE NOT isnull(StartTime)';
if ( !empty($user['MonitorIds']) ) { if ( !empty($user['MonitorIds']) ) {
$monFilterSql = ' AND MonitorId IN ('.$user['MonitorIds'].')'; $monFilterSql = ' AND MonitorId IN ('.$user['MonitorIds'].')';
$rangeSql .= $monFilterSql; $rangeSql .= $monFilterSql;
$eventsSql .= $monFilterSql; $eventsSql .= $monFilterSql;
@ -351,12 +352,12 @@ foreach( dbFetchAll( $eventsSql ) as $event ) {
} }
if ( $event['MaxScore'] > 0 ) { if ( $event['MaxScore'] > 0 ) {
if ( $startIndex == $endIndex ) { if ( $startIndex == $endIndex ) {
$framesSql = "select FrameId,Score from Frames where EventId = ? and Score > 0 order by Score desc limit 1"; $framesSql = 'SELECT FrameId,Score FROM Frames WHERE EventId = ? AND Score > 0 ORDER BY Score DESC LIMIT 1';
$frame = dbFetchOne( $framesSql, NULL, array($event['Id']) ); $frame = dbFetchOne( $framesSql, NULL, array($event['Id']) );
$i = $startIndex; $i = $startIndex;
if ( !isset($currFrameSlots[$i]) ) { if ( !isset($currFrameSlots[$i]) ) {
$currFrameSlots[$i] = array( "count"=>1, "value"=>$event['MaxScore'], "event"=>$event, "frame"=>$frame ); $currFrameSlots[$i] = array( 'count'=>1, 'value'=>$event['MaxScore'], 'event'=>$event, 'frame'=>$frame );
} else { } else {
$currFrameSlots[$i]['count']++; $currFrameSlots[$i]['count']++;
if ( $event['MaxScore'] > $currFrameSlots[$i]['value'] ) { if ( $event['MaxScore'] > $currFrameSlots[$i]['value'] ) {
@ -369,7 +370,7 @@ foreach( dbFetchAll( $eventsSql ) as $event ) {
$chart['data']['y']['hi'] = $event['MaxScore']; $chart['data']['y']['hi'] = $event['MaxScore'];
} }
} else { } else {
$framesSql = "select FrameId,Delta,unix_timestamp(TimeStamp) as TimeT,Score from Frames where EventId = ? and Score > 0"; $framesSql = 'SELECT FrameId,Delta,unix_timestamp(TimeStamp) AS TimeT,Score FROM Frames WHERE EventId = ? AND Score > 0';
$result = dbQuery( $framesSql, array( $event['Id'] ) ); $result = dbQuery( $framesSql, array( $event['Id'] ) );
while( $frame = dbFetchNext( $result ) ) { while( $frame = dbFetchNext( $result ) ) {
if ( $frame['Score'] == 0 ) if ( $frame['Score'] == 0 )
@ -383,7 +384,7 @@ foreach( dbFetchAll( $eventsSql ) as $event ) {
continue; continue;
if ( !isset($currFrameSlots[$frameIndex]) ) { if ( !isset($currFrameSlots[$frameIndex]) ) {
$currFrameSlots[$frameIndex] = array( "count"=>1, "value"=>$frame['Score'], "event"=>$event, "frame"=>$frame ); $currFrameSlots[$frameIndex] = array( 'count'=>1, 'value'=>$frame['Score'], 'event'=>$event, 'frame'=>$frame );
} else { } else {
$currFrameSlots[$frameIndex]['count']++; $currFrameSlots[$frameIndex]['count']++;
if ( $frame['Score'] > $currFrameSlots[$frameIndex]['value'] ) { if ( $frame['Score'] > $currFrameSlots[$frameIndex]['value'] ) {
@ -496,7 +497,7 @@ for ( $i = 0; $i < $chart['graph']['width']; $i++ ) {
$frameSlots[$i][] = &$currFrameSlots[$i]; $frameSlots[$i][] = &$currFrameSlots[$i];
} }
} }
} } # end foreach MonitorId
} }
//print_r( $monEventSlots ); //print_r( $monEventSlots );
@ -505,7 +506,7 @@ for ( $i = 0; $i < $chart['graph']['width']; $i++ ) {
$graphHeight = $chart['graph']['height']; $graphHeight = $chart['graph']['height'];
if ( $mode == "overlay" ) { if ( $mode == 'overlay' ) {
$minEventBarHeight = 10; $minEventBarHeight = 10;
$maxEventBarHeight = 40; $maxEventBarHeight = 40;
@ -527,7 +528,7 @@ if ( $mode == "overlay" ) {
$chart['eventBars'][$monitorId] = array( 'top' => $top ); $chart['eventBars'][$monitorId] = array( 'top' => $top );
$top += $chart['graph']['eventBarHeight']+1; $top += $chart['graph']['eventBarHeight']+1;
} }
} elseif ( $mode == "split" ) { } else if ( $mode == 'split' ) {
$minActivityBarHeight = 30; $minActivityBarHeight = 30;
$minEventBarHeight = 10; $minEventBarHeight = 10;
$maxEventBarHeight = 40; $maxEventBarHeight = 40;
@ -547,14 +548,11 @@ if ( $mode == "overlay" ) {
} }
$chart['data']['y']['density'] = $chart['data']['y']['range']/$chart['graph']['activityBarHeight']; $chart['data']['y']['density'] = $chart['data']['y']['range']/$chart['graph']['activityBarHeight'];
?> $chart['activityBars'] = array();
<?php
$chart['activityBars'] = array();
$chart['eventBars'] = array(); $chart['eventBars'] = array();
$top = 0; $top = 0;
$barCount = 1; $barCount = 1;
foreach ( array_keys($monitorIds) as $monitorId ) foreach ( array_keys($monitorIds) as $monitorId ) {
{
$chart['eventBars'][$monitorId] = array( 'top' => $top ); $chart['eventBars'][$monitorId] = array( 'top' => $top );
$chart['eventBars'][$monitorId] = array( 'top' => $top+$chart['graph']['activityBarHeight']+1 ); $chart['eventBars'][$monitorId] = array( 'top' => $top+$chart['graph']['activityBarHeight']+1 );
$top += $chart['graph']['activityBarHeight']+1+$chart['graph']['eventBarHeight']+1; $top += $chart['graph']['activityBarHeight']+1+$chart['graph']['eventBarHeight']+1;
@ -565,123 +563,124 @@ preg_match( '/^(\d+)-(\d+)-(\d+) (\d+):(\d+)/', $minTime, $startMatches );
preg_match( '/^(\d+)-(\d+)-(\d+) (\d+):(\d+)/', $maxTime, $endMatches ); preg_match( '/^(\d+)-(\d+)-(\d+) (\d+):(\d+)/', $maxTime, $endMatches );
if ( $startMatches[1] != $endMatches[1] ) { if ( $startMatches[1] != $endMatches[1] ) {
// Different years // Different years
$title = strftime( STRF_TL_AXIS_RANGE_YEAR1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_YEAR2, $chart['data']['x']['hi'] ); $title = strftime( STRF_TL_AXIS_RANGE_YEAR1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_YEAR2, $chart['data']['x']['hi'] );
} elseif ( $startMatches[2] != $endMatches[2] ) { } elseif ( $startMatches[2] != $endMatches[2] ) {
// Different months // Different months
$title = strftime( STRF_TL_AXIS_RANGE_MONTH1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_MONTH2, $chart['data']['x']['hi'] ); $title = strftime( STRF_TL_AXIS_RANGE_MONTH1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_MONTH2, $chart['data']['x']['hi'] );
} elseif ( $startMatches[3] != $endMatches[3] ) { } elseif ( $startMatches[3] != $endMatches[3] ) {
// Different dates // Different dates
$title = strftime( STRF_TL_AXIS_RANGE_DAY1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_DAY2, $chart['data']['x']['hi'] ); $title = strftime( STRF_TL_AXIS_RANGE_DAY1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_DAY2, $chart['data']['x']['hi'] );
} else { } else {
// Different times // Different times
$title = strftime( STRF_TL_AXIS_RANGE_TIME1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_TIME2, $chart['data']['x']['hi'] ); $title = strftime( STRF_TL_AXIS_RANGE_TIME1, $chart['data']['x']['lo'] )." - ".strftime( STRF_TL_AXIS_RANGE_TIME2, $chart['data']['x']['hi'] );
} }
function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomClass=false ) { function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomClass=false ) {
ob_start(); $html = '';
$labelCount = 0; ob_start();
$lastTick = 0; $labelCount = 0;
unset( $lastLabel ); $lastTick = 0;
$labelCheck = isset($scale['labelCheck'])?$scale['labelCheck']:$scale['label']; unset( $lastLabel );
$labelCheck = isset($scale['labelCheck'])?$scale['labelCheck']:$scale['label'];
?> ?>
<div id="xScale"> <div id="xScale">
<?php <?php
for ( $i = 0; $i < $chart['graph']['width']; $i++ ) { for ( $i = 0; $i < $chart['graph']['width']; $i++ ) {
$x = $i - 1; $x = $i - 1;
$timeOffset = (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])); $timeOffset = (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density']));
if ( $scale['align'] > 1 ) { if ( $scale['align'] > 1 ) {
$label = (int)(strftime( $labelCheck, $timeOffset )/$scale['align']); $label = (int)(strftime( $labelCheck, $timeOffset )/$scale['align']);
} else { } else {
$label = strftime( $labelCheck, $timeOffset ); $label = strftime( $labelCheck, $timeOffset );
}
if ( !isset($lastLabel) || ($lastLabel != $label) ) {
$labelCount++;
}
if ( $labelCount >= $scale['divisor'] ) {
$labelCount = 0;
if ( isset($lastLabel) ) {
if ( $labelClass ) {
?>
<div class="<?php echo $labelClass ?>" style="left: <?php echo $x-25 ?>px;"><?php echo strftime( $scale['label'], $timeOffset ); ?></div>
<?php
}
if ( $tickClass ) {
?>
<div class="<?php echo $tickClass ?>" style="left: <?php echo $x ?>px;"></div>
<?php
}
if ( $gridClass ) {
?>
<div class="<?php echo $gridClass ?>" style="left: <?php echo $x ?>px;"></div>
<?php
}
if ( $scale['name'] != 'second' && $zoomClass ) {
$zoomMinTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($lastTick * $chart['data']['x']['density'])) );
$zoomMaxTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?php echo $zoomClass ?>" style="left: <?php echo $lastTick-1 ?>px; width: <?php echo $i-$lastTick ?>px;" title="<?php echo translate('ZoomIn') ?>" onclick="tlZoomBounds( '<?php echo $zoomMinTime ?>', '<?php echo $zoomMaxTime ?>' )"></div>
<?php
}
$lastTick = $i;
}
}
$lastLabel = $label;
} }
if ( $zoomClass ) { if ( !isset($lastLabel) || ($lastLabel != $label) ) {
$zoomMinTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($lastTick * $chart['data']['x']['density'])) ); $labelCount++;
$zoomMaxTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?php echo $zoomClass ?>" style="left: <?php echo $lastTick-1 ?>px; width: <?php echo $i-$lastTick ?>px;" title="<?php echo translate('ZoomIn') ?>" onclick="tlZoomBounds( '<?php echo $zoomMinTime ?>', '<?php echo $zoomMaxTime ?>' )"></div>
<?php
} }
?> if ( $labelCount >= $scale['divisor'] ) {
</div> $labelCount = 0;
<?php if ( isset($lastLabel) ) {
return( ob_get_clean() );
}
function drawYGrid( $chart, $scale, $labelClass, $tickClass, $gridClass ) {
ob_start();
?>
<div id="yScale">
<?php
for ( $i = 0; $i < $scale['lines']; $i++ ) {
$label = (int)($i * $scale['divisor']);
$y = $chart['graph']['eventsHeight']+(int)(($i * $scale['divisor'])/$chart['data']['y']['density'])-1;
if ( $labelClass ) { if ( $labelClass ) {
?> ?>
<div class="<?php echo $labelClass ?>" style="top: <?php echo $chart['graph']['height']-($y+8) ?>px;"><?php echo $label ?></div> <div class="<?php echo $labelClass ?>" style="left: <?php echo $x-25 ?>px;"><?php echo strftime( $scale['label'], $timeOffset ); ?></div>
<?php <?php
} }
if ( $tickClass ) { if ( $tickClass ) {
?> ?>
<div class="<?php echo $tickClass ?>" style="top: <?php echo $chart['graph']['height']-($y+2) ?>px;"></div> <div class="<?php echo $tickClass ?>" style="left: <?php echo $x ?>px;"></div>
<?php <?php
} }
if ( $gridClass ) { if ( $gridClass ) {
?> ?>
<div class="<?php echo $gridClass ?>" style="top: <?php echo $chart['graph']['height']-($y+2) ?>px;<?php echo $i <= 0?' border-top: solid 1px black;':'' ?>"></div> <div class="<?php echo $gridClass ?>" style="left: <?php echo $x ?>px;"></div>
<?php <?php
} }
if ( $scale['name'] != 'second' && $zoomClass ) {
$zoomMinTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($lastTick * $chart['data']['x']['density'])) );
$zoomMaxTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?php echo $zoomClass ?>" style="left: <?php echo $lastTick-1 ?>px; width: <?php echo $i-$lastTick ?>px;" title="<?php echo translate('ZoomIn') ?>" onclick="tlZoomBounds( '<?php echo $zoomMinTime ?>', '<?php echo $zoomMaxTime ?>' )"></div>
<?php
}
$lastTick = $i;
} # end if $lastLabel
} }
$lastLabel = $label;
} # end foreach width segment
if ( $zoomClass ) {
$zoomMinTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($lastTick * $chart['data']['x']['density'])) );
$zoomMaxTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
?>
<div class="<?php echo $zoomClass ?>" style="left: <?php echo $lastTick-1 ?>px; width: <?php echo $i-$lastTick ?>px;" title="<?php echo translate('ZoomIn') ?>" onclick="tlZoomBounds( '<?php echo $zoomMinTime ?>', '<?php echo $zoomMaxTime ?>' )"></div>
<?php
}
?> ?>
</div> </div>
<?php <?php
return( ob_get_clean() );
} # end function drawXGrid
return( ob_get_clean() ); function drawYGrid( $chart, $scale, $labelClass, $tickClass, $gridClass ) {
} ob_start();
?>
<div id="yScale">
<?php
for ( $i = 0; $i < $scale['lines']; $i++ ) {
$label = (int)($i * $scale['divisor']);
$y = $chart['graph']['eventsHeight']+(int)(($i * $scale['divisor'])/$chart['data']['y']['density'])-1;
if ( $labelClass ) {
?>
<div class="<?php echo $labelClass ?>" style="top: <?php echo $chart['graph']['height']-($y+8) ?>px;"><?php echo $label ?></div>
<?php
}
if ( $tickClass ) {
?>
<div class="<?php echo $tickClass ?>" style="top: <?php echo $chart['graph']['height']-($y+2) ?>px;"></div>
<?php
}
if ( $gridClass ) {
?>
<div class="<?php echo $gridClass ?>" style="top: <?php echo $chart['graph']['height']-($y+2) ?>px;<?php echo $i <= 0?' border-top: solid 1px black;':'' ?>"></div>
<?php
}
} # end foreach line segment
?>
</div>
<?php
return( ob_get_clean() );
} # end function drawYGrid
function getSlotPreviewEventBehaviour( $slot ) { function getSlotPreviewEventBehaviour( $slot ) {
return( "previewEvent( '".$slot['event']['Id']."', '".getSlotFrame( $slot )."' )" ); return( "previewEvent( '".$slot['event']['Id']."', '".getSlotFrame( $slot )."' )" );
} }
function getSlotShowEventBehaviour( $slot ) { function getSlotShowEventBehaviour( $slot ) {
global $monitors; global $monitors;
$monitor = &$monitors[$slot['event']['MonitorId']]; $monitor = &$monitors[$slot['event']['MonitorId']];
return( "showEvent( '".$slot['event']['Id']."', '".getSlotFrame( $slot )."', '".reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE )."', '".reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE )."' )" ); return( "showEvent( '".$slot['event']['Id']."', '".getSlotFrame( $slot )."', '".reScale( $monitor['Width'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE )."', '".reScale( $monitor['Height'], $monitor['DefaultScale'], ZM_WEB_DEFAULT_SCALE )."' )" );
} }
$focusWindow = true; $focusWindow = true;
@ -713,7 +712,7 @@ Your browser does not support the video tag.
</video> </video>
o--> o-->
</div> </div>
</div> </div>
<div id="dataPanel"> <div id="dataPanel">
<div id="textPanel"> <div id="textPanel">
@ -736,102 +735,102 @@ o-->
<div id="chartPanel"> <div id="chartPanel">
<div id="chart" class="graphSize"> <div id="chart" class="graphSize">
<?php <?php
if ( $mode == "overlay" ) { if ( $mode == 'overlay' ) {
echo drawYGrid( $chart, $majYScale, "majLabelY", "majTickY", "majGridY graphWidth" ); echo drawYGrid( $chart, $majYScale, 'majLabelY', 'majTickY', 'majGridY graphWidth' );
} }
echo drawXGrid( $chart, $majXScale, "majLabelX", "majTickX", "majGridX graphHeight", "zoom graphHeight" ); echo drawXGrid( $chart, $majXScale, 'majLabelX', 'majTickX', 'majGridX graphHeight', 'zoom graphHeight' );
if ( $mode == "overlay" ) { if ( $mode == 'overlay' ) {
?> ?>
<div id="activity" class="activitySize"> <div id="activity" class="activitySize">
<?php <?php
foreach ( $frameSlots as $index=>$slots ) { foreach ( $frameSlots as $index=>$slots ) {
foreach ( $slots as $slot ) { foreach ( $slots as $slot ) {
$slotHeight = (int)($slot['value']/$chart['data']['y']['density']); $slotHeight = (int)($slot['value']/$chart['data']['y']['density']);
if ( $slotHeight <= 0 ) if ( $slotHeight <= 0 )
continue; continue;
if ( $mouseover ) { if ( $mouseover ) {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotShowEventBehaviour( $slot ).'"', 'onclick="'.getSlotShowEventBehaviour( $slot ).'"',
'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} else { } else {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} }
?> ?>
<div class="activity monitorColour<?php echo $slot['event']['MonitorId'] ?>" style="left: <?php echo $index ?>px; height: <?php echo $slotHeight ?>px;" <?php echo join( " ", $behaviours ) ?>></div> <div class="activity monitorColour<?php echo $slot['event']['MonitorId'] ?>" style="left: <?php echo $index ?>px; height: <?php echo $slotHeight ?>px;" <?php echo join( " ", $behaviours ) ?>></div>
<?php <?php
} }
} }
?> ?>
</div> </div>
<?php <?php
} elseif ( $mode == "split" ) { } elseif ( $mode == 'split' ) {
foreach( array_keys($monFrameSlots) as $monitorId ) { foreach( array_keys($monFrameSlots) as $monitorId ) {
?> ?>
<div id="activity<?php echo $monitorId ?>"> <div id="activity<?php echo $monitorId ?>">
<?php <?php
unset( $currFrameSlots ); unset( $currFrameSlots );
$currFrameSlots = &$monFrameSlots[$monitorId]; $currFrameSlots = &$monFrameSlots[$monitorId];
foreach ( $currFrameSlots as $index=>$slot ) { foreach ( $currFrameSlots as $index=>$slot ) {
$slotHeight = (int)($slot['value']/$chart['data']['y']['density']); $slotHeight = (int)($slot['value']/$chart['data']['y']['density']);
if ( $slotHeight <= 0 ) if ( $slotHeight <= 0 )
continue; continue;
if ( $mouseover ) { if ( $mouseover ) {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotShowEventBehaviour( $slot ).'"', 'onclick="'.getSlotShowEventBehaviour( $slot ).'"',
'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} else { } else {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} }
?>
<div class="activity activity<?php echo $slot['event']['MonitorId'] ?>" style="left: <?php echo $index ?>px; height: <?php echo $slotHeight ?>px;" <?php echo join( " ", $behaviours ) ?>></div>
<?php
}
?> ?>
</div> <div class="activity activity<?php echo $slot['event']['MonitorId'] ?>" style="left: <?php echo $index ?>px; height: <?php echo $slotHeight ?>px;" <?php echo join( " ", $behaviours ) ?>></div>
<?php <?php
} } # end foreach $currFrameSlots
?>
</div>
<?php
} # end foreach $MonitorId
} }
foreach( array_keys($monEventSlots) as $monitorId ) { foreach( array_keys($monEventSlots) as $monitorId ) {
?> ?>
<div id="events<?php echo $monitorId ?>" class="events eventsSize eventsPos<?php echo $monitorId ?>"> <div id="events<?php echo $monitorId ?>" class="events eventsSize eventsPos<?php echo $monitorId ?>">
<?php <?php
unset( $currEventSlots ); unset( $currEventSlots );
$currEventSlots = &$monEventSlots[$monitorId]; $currEventSlots = &$monEventSlots[$monitorId];
$monitorMouseover = $mouseover; $monitorMouseover = $mouseover;
if ($monitors[$monitorId]['SaveJPEGs'] == 2) { if ($monitors[$monitorId]['SaveJPEGs'] == 2) {
$monitorMouseover = false; $monitorMouseover = false;
} }
for ( $i = 0; $i < $chart['graph']['width']; $i++ ) { for ( $i = 0; $i < $chart['graph']['width']; $i++ ) {
if ( isset($currEventSlots[$i]) ) { if ( isset($currEventSlots[$i]) ) {
unset( $slot ); unset( $slot );
$slot = &$currEventSlots[$i]; $slot = &$currEventSlots[$i];
if ( $monitorMouseover ) { if ( $monitorMouseover ) {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotShowEventBehaviour( $slot ).'"', 'onclick="'.getSlotShowEventBehaviour( $slot ).'"',
'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onmouseover="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} else { } else {
$behaviours = array( $behaviours = array(
'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"' 'onclick="'.getSlotPreviewEventBehaviour( $slot ).'"'
); );
} }
?> ?>
<div class="event eventsHeight monitorColour<?php echo $monitorId ?>" style="left: <?php echo $i ?>px; width: <?php echo $slot['width'] ?>px;" <?php echo join( " ", $behaviours ) ?>></div> <div class="event eventsHeight monitorColour<?php echo $monitorId ?>" style="left: <?php echo $i ?>px; width: <?php echo $slot['width'] ?>px;" <?php echo join( " ", $behaviours ) ?>></div>
<?php <?php
} } # end if isset($currEventSlots[$i])
} } # end foreach width segment
?> ?>
</div> </div>
<?php <?php

View File

@ -34,6 +34,7 @@ if ( ! visibleMonitor( $mid ) ) {
$monitor = new Monitor( $mid ); $monitor = new Monitor( $mid );
#Whether to show the controls button
$showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView( 'Control' ) ); $showPtzControls = ( ZM_OPT_CONTROL && $monitor->Controllable() && canView( 'Control' ) );
if ( isset( $_REQUEST['scale'] ) ) { if ( isset( $_REQUEST['scale'] ) ) {

View File

@ -92,7 +92,7 @@ if ( empty($_REQUEST['path']) ) {
$output = array(); $output = array();
$retval = 0; $retval = 0;
exec( $command, $output, $retval ); exec( $command, $output, $retval );
Logger::Debug("Retval: $retval, output: " . implode("\n", $output)); Logger::Debug("Command: $command, retval: $retval, output: " . implode("\n", $output));
if ( ! file_exists( $path ) ) { if ( ! file_exists( $path ) ) {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');
Fatal("Can't create frame images from video for this event (".$Event->DefaultVideo() ); Fatal("Can't create frame images from video for this event (".$Event->DefaultVideo() );

View File

@ -40,7 +40,7 @@ $Event = null;
if ( ! empty($_REQUEST['eid'] ) ) { if ( ! empty($_REQUEST['eid'] ) ) {
$Event = new Event( $_REQUEST['eid'] ); $Event = new Event( $_REQUEST['eid'] );
$path = $Event->Path().'/'.$Event->DefaultVideo(); $path = $Event->Path().'/'.$Event->DefaultVideo();
Debug("Path: $path"); Logger::Debug("Path: $path");
} else { } else {
$errorText = 'No video path'; $errorText = 'No video path';
} }
@ -64,14 +64,14 @@ $end = $size-1;
$length = $size; $length = $size;
if ( isset( $_SERVER['HTTP_RANGE'] ) ) { if ( isset( $_SERVER['HTTP_RANGE'] ) ) {
Debug("Using Range " . $_SERVER['HTTP_RANGE'] ); Logger::Debug("Using Range " . $_SERVER['HTTP_RANGE'] );
if ( preg_match( '/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) { if ( preg_match( '/bytes=\h*(\d+)-(\d*)[\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches) ) {
$begin = intval( $matches[1] ); $begin = intval( $matches[1] );
if ( ! empty( $matches[2]) ) { if ( ! empty( $matches[2]) ) {
$end = intval( $matches[2] ); $end = intval( $matches[2] );
} }
$length = $end - $begin + 1; $length = $end - $begin + 1;
Debug("Using Range $begin $end size: $size, length: $length"); Logger::Debug("Using Range $begin $end size: $size, length: $length");
} }
} # end if HTTP_RANGE } # end if HTTP_RANGE