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[*/
@ -102,10 +99,8 @@ var $j = jQuery.noConflict();
<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

@ -73,7 +73,7 @@ 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();
@ -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,14 +170,14 @@ 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
?> ?>
@ -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,16 +1,12 @@
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].type == "checkbox" ) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
if ( checked++ > 1 ) if ( checked++ > 1 )
break; break;
} }
@ -23,20 +19,15 @@ function setButtonStates( element )
form.deleteBtn.disabled = (checked==0); form.deleteBtn.disabled = (checked==0);
} }
function addMonitor( element) function addMonitor( element) {
{
var form = element.form; var form = element.form;
var dupParam; var dupParam;
var monitorId=-1; var monitorId=-1;
if (form.addBtn.value == jsTranslatedCloneText) if (form.addBtn.value == jsTranslatedCloneText) {
{
// get the value of the first checkbox // get the value of the first checkbox
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].type == "checkbox" ) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
monitorId = form.elements[i].value; monitorId = form.elements[i].value;
break; break;
} }
@ -47,15 +38,11 @@ function addMonitor( element)
createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' ); createPopup( '?view=monitor'+dupParam, 'zmMonitor0', 'monitor' );
} }
function editMonitor( element ) function editMonitor( element ) {
{
var form = element.form; var form = element.form;
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].type == "checkbox" ) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
var monitorId = form.elements[i].value; var monitorId = form.elements[i].value;
createPopup( '?view=monitor&mid='+monitorId, 'zmMonitor'+monitorId, 'monitor' ); createPopup( '?view=monitor&mid='+monitorId, 'zmMonitor'+monitorId, 'monitor' );
form.elements[i].checked = false; form.elements[i].checked = false;
@ -67,23 +54,19 @@ function editMonitor( element )
} }
} }
function deleteMonitor( element ) 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?' ) ) {
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;
form.elements['action'].value = 'delete'; form.elements['action'].value = 'delete';
form.submit(); form.submit();
} }
} }
function reloadWindow() function reloadWindow() {
{
window.location.replace( thisUrl ); window.location.replace( thisUrl );
} }
function initPage() function initPage() {
{
jsTranslatedAddText = translatedAddText; jsTranslatedAddText = translatedAddText;
jsTranslatedCloneText = translatedCloneText; jsTranslatedCloneText = translatedCloneText;
reloadWindow.periodical( consoleRefreshTimeout ); reloadWindow.periodical( consoleRefreshTimeout );

View File

@ -1,23 +1,15 @@
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 ) {
elseif ( ZM_DYN_SHOW_DONATE_REMINDER ) if ( canEdit('System') ) {
{ if ( ZM_DYN_DONATE_REMINDER_TIME > 0 ) {
if ( canEdit('System') ) if ( ZM_DYN_DONATE_REMINDER_TIME < time() ) {
{
if ( ZM_DYN_DONATE_REMINDER_TIME > 0 )
{
if ( ZM_DYN_DONATE_REMINDER_TIME < time() )
{
$showDonatePopup = true; $showDonatePopup = true;
} }
} } else {
else
{
$nextReminder = time() + 30*24*60*60; $nextReminder = time() + 30*24*60*60;
dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_DONATE_REMINDER_TIME'" ); dbQuery( "update Config set Value = '".$nextReminder."' where Name = 'ZM_DYN_DONATE_REMINDER_TIME'" );
} }

View File

@ -1,22 +1,18 @@
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 xEvent = new Event( event );
var target = xEvent.target; var target = xEvent.target;
var coords = $(target).getCoordinates(); var coords = $(target).getCoordinates();
@ -26,8 +22,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;
@ -35,8 +30,7 @@ function controlCmd( control, event, xtell, ytell )
xge = 2*(50 - xge); xge = 2*(50 - xge);
locParms += "&xge="+xge; locParms += "&xge="+xge;
} }
if ( ytell ) if ( ytell ) {
{
var yge = parseInt( (y*100)/coords.height ); var yge = parseInt( (y*100)/coords.height );
if ( ytell == -1 ) if ( ytell == -1 )
yge = 100 - yge; yge = 100 - yge;

View File

@ -1,12 +1,8 @@
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]; $('contentForm').newLabel.value = labels[presetIndex];
} } else {
else
{
$('contentForm').newLabel.value = ""; $('contentForm').newLabel.value = "";
} }
} }

View File

@ -1,10 +1,8 @@
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 );
} }

View File

@ -1,5 +1,4 @@
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';
@ -8,8 +7,7 @@ function switchDeviceOn( element, 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';
@ -18,24 +16,19 @@ function switchDeviceOff( element, 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].name.indexOf(name) == 0) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
checked = true; checked = true;
break; break;
} }

View File

@ -1,5 +1,4 @@
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;
@ -8,7 +7,6 @@ function submitForm( element )
form.submit(); form.submit();
} }
if ( action == "donate" && option == "go" ) if ( action == "donate" && option == "go" ) {
{
zmWindow(); zmWindow();
} }

View File

@ -1,13 +1,11 @@
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++)
@ -21,18 +19,13 @@ function toggleCheckbox( element, name )
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++) {
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)
{
if ( form.elements[i].checked )
{
checked = true; checked = true;
break; break;
} }
@ -49,41 +42,31 @@ function configureButton( element, name )
form.deleteBtn.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].name.indexOf(name) == 0) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
count++; count++;
break; 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].name.indexOf(name) == 0) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
eids[eids.length] = 'eids[]='+form.elements[i].value; eids[eids.length] = 'eids[]='+form.elements[i].value;
} }
} }
@ -91,16 +74,12 @@ function editEvents( element, name )
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].name.indexOf(name) == 0) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
eids[eids.length] = 'eids[]='+form.elements[i].value; eids[eids.length] = 'eids[]='+form.elements[i].value;
} }
} }
@ -108,42 +87,34 @@ function exportEvents( element, name )
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].name.indexOf(name) == 0) if ( form.elements[i].checked ) {
{
if ( form.elements[i].checked )
{
events[events.length] = form.elements[i].value; events[events.length] = form.elements[i].value;
} }
} }
} }
if ( events.length > 0 ) 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 ); 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,26 +1,24 @@
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', '.' );
@ -28,13 +26,11 @@ function exportProgress()
$('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 } );
@ -46,11 +42,9 @@ function exportEvent( form )
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 );
} }
} }

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,11 +1,9 @@
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;
@ -25,15 +23,13 @@ function updateButtons( element )
} }
} }
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';
@ -41,11 +37,9 @@ function submitToFilter( element, reload )
form.submit(); form.submit();
} }
function submitToEvents( element ) function submitToEvents( element ) {
{
var form = element.form; var form = element.form;
if ( validateForm( form ) ) if ( validateForm( form ) ) {
{
form.target = 'zmEvents'; form.target = 'zmEvents';
form.view.value = 'events'; form.view.value = 'events';
form.action.value = ''; form.action.value = '';
@ -54,11 +48,9 @@ function submitToEvents( element )
} }
} }
function executeFilter( element ) function executeFilter( element ) {
{
var form = element.form; var form = element.form;
if ( validateForm( form ) ) if ( validateForm( form ) ) {
{
form.target = 'zmEvents'; form.target = 'zmEvents';
form.view.value = 'events'; form.view.value = 'events';
form.action.value = 'filter'; form.action.value = 'filter';
@ -67,8 +59,7 @@ function executeFilter( element )
} }
} }
function saveFilter( element ) function saveFilter( element ) {
{
var form = element.form; var form = element.form;
var popupName = 'zmEventsFilterSave'; var popupName = 'zmEventsFilterSave';
@ -79,18 +70,16 @@ function saveFilter( element )
form.submit(); form.submit();
} }
function deleteFilter( element, id, name ) function deleteFilter( element, name ) {
{ if ( confirm( deleteSavedFilterString+" '"+name+"'" ) ) {
if ( confirm( deleteSavedFilterString+" '"+name+"'?" ) )
{
var form = element.form; var form = element.form;
form.action.value = 'delete'; form.action.value = 'delete';
submitToFilter( element, 0 ); form.fid.value = name;
submitToFilter( element, 1 );
} }
} }
function addTerm( element, line ) function addTerm( element, line ) {
{
var form = element.form; var form = element.form;
form.target = window.name; form.target = window.name;
form.view.value = currentView; form.view.value = currentView;
@ -100,8 +89,7 @@ function addTerm( element, line )
form.submit(); form.submit();
} }
function delTerm( element, line ) function delTerm( element, line ) {
{
var form = element.form; var form = element.form;
form.target = window.name; form.target = window.name;
form.view.value = currentView; form.view.value = currentView;
@ -111,8 +99,7 @@ function delTerm( element, line )
form.submit(); form.submit();
} }
function init() function init() {
{
updateButtons( $('executeButton') ); updateButtons( $('executeButton') );
} }

View File

@ -1,14 +1,11 @@
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]'];
@ -17,8 +14,7 @@ for ( $i = 0; $i < count($_REQUEST['filter']['terms']); $i++ )
<?php <?php
} }
?> ?>
if ( bracket_count ) if ( bracket_count ) {
{
alert( "<?php echo translate('ErrorBrackets') ?>" ); alert( "<?php echo translate('ErrorBrackets') ?>" );
return( false ); return( false );
} }
@ -26,12 +22,10 @@ for ( $i = 0; $i < count($_REQUEST['filter']['terms']); $i++ )
} }
?> ?>
<?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 );
} }
@ -41,8 +35,7 @@ for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['term
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,10 +1,8 @@
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);
} }

View File

@ -1,43 +1,34 @@
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 ) {
if ( form.gid[i].checked )
{
createPopup( '?view=group&gid='+form.gid[i].value, 'zmGroup', 'group' ); createPopup( '?view=group&gid='+form.gid[i].value, 'zmGroup', 'group' );
return; return;
} }
} }
} }
function deleteGroup( element ) function deleteGroup( 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 ) function configureButtons( element ) {
{ if ( canEditGroups ) {
if ( canEditGroups )
{
var form = element.form; var form = element.form;
if ( element.checked ) if ( element.checked ) {
{
form.editBtn.disabled = (element.value == 0); form.editBtn.disabled = (element.value == 0);
form.deleteBtn.disabled = (element.value == 0); form.deleteBtn.disabled = (element.value == 0);
} }

View File

@ -25,45 +25,37 @@ 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; logTimeout = minSampleTime;
logCount += respObj.logs.length; logCount += respObj.logs.length;
try { try {
respObj.logs.each( respObj.logs.each(
function( log ) function( log ) {
{
if ( !maxLogTime || log.TimeKey > maxLogTime ) if ( !maxLogTime || log.TimeKey > maxLogTime )
maxLogTime = log.TimeKey; maxLogTime = log.TimeKey;
if ( !minLogTime || log.TimeKey < minLogTime ) if ( !minLogTime || log.TimeKey < minLogTime )
@ -79,8 +71,7 @@ function logResponse( respObj )
row.tr.addClass( 'log-war' ); row.tr.addClass( 'log-war' );
else if ( log.Level > 0 ) else if ( log.Level > 0 )
row.tr.addClass( 'log-dbg' ); row.tr.addClass( 'log-dbg' );
if ( !firstLoad ) if ( !firstLoad ) {
{
var color = document.defaultView.getComputedStyle(row.tr, null).getPropertyValue('color'); var color = document.defaultView.getComputedStyle(row.tr, null).getPropertyValue('color');
var colorParts = color.match(/^rgb.*\((\d+),\s*(\d+),\s*(\d+)/); 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); rowOrigColor = '#' + parseInt(colorParts[1]).toString(16) + parseInt(colorParts[2]).toString(16) + parseInt(colorParts[3]).toString(16);
@ -99,23 +90,18 @@ function logResponse( respObj )
$('totalLogs').set('text', respObj.total); $('totalLogs').set('text', respObj.total);
$('availLogs').set('text', respObj.available); $('availLogs').set('text', respObj.available);
$('displayLogs').set('text', logCount); $('displayLogs').set('text', logCount);
if ( firstLoad ) if ( firstLoad ) {
{
if ( logCount < displayLimit ) if ( logCount < displayLimit )
fetchPrevLogs(); fetchPrevLogs();
} }
logTable.reSort(); logTable.reSort();
} } catch( e ) {
catch( e )
{
console.error( e ); console.error( e );
} }
logTimeout /= 2; logTimeout /= 2;
if ( logTimeout < minSampleTime ) if ( logTimeout < minSampleTime )
logTimeout = minSampleTime; logTimeout = minSampleTime;
} } else {
else
{
firstLoad = false; firstLoad = false;
logTimeout *= 2; logTimeout *= 2;
if ( logTimeout > maxSampleTime ) if ( logTimeout > maxSampleTime )
@ -125,8 +111,7 @@ function logResponse( respObj )
logTimer = fetchNextLogs.delay( logTimeout ); logTimer = fetchNextLogs.delay( logTimeout );
} }
function refreshLog() function refreshLog() {
{
options = {}; options = {};
logTable.empty(); logTable.empty();
firstLoad = true; firstLoad = true;
@ -138,14 +123,12 @@ function refreshLog()
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;
@ -156,12 +139,10 @@ function clearLog()
logTable.empty(); logTable.empty();
} }
function filterLog() function filterLog() {
{
filter = {}; filter = {};
filterFields.each( filterFields.each(
function( field ) function( field ) {
{
var selector = $('filter['+field+']'); var selector = $('filter['+field+']');
if ( ! selector ) { if ( ! selector ) {
if ( window.console && window.console.log ) { if ( window.console && window.console.log ) {
@ -177,62 +158,51 @@ function filterLog()
refreshLog(); 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 ) function exportFail( request ) {
{
$('exportLog').unspin(); $('exportLog').unspin();
$('exportErrorText').set('text', request.status+" / "+request.statusText ); $('exportErrorText').set('text', request.status+" / "+request.statusText );
$('exportError').show(); $('exportError').show();
Error( "Export request failed: "+request.status+" / "+request.statusText ); Error( "Export request failed: "+request.status+" / "+request.statusText );
} }
function exportRequest() function exportRequest() {
{
var form = $('exportForm'); var form = $('exportForm');
$('exportErrorText').set('text', "" ); $('exportErrorText').set('text', "" );
$('exportError').hide(); $('exportError').hide();
if ( form.validate() ) if ( form.validate() ) {
{
var exportParms = "view=request&request=log&task=export"; var exportParms = "view=request&request=log&task=export";
var exportReq = new Request.JSON( { url: thisUrl, method: 'post', link: 'cancel', onSuccess: exportResponse, onFailure: exportFail } ); 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'); var selection = form.getElement('input[name=selector]:checked').get('value');
if ( selection == 'filter' || selection == 'current' ) if ( selection == 'filter' || selection == 'current' ) {
{
$$('#filters select').each( $$('#filters select').each(
function( select ) function( select ) {
{
exportParms += "&"+select.get('id')+"="+select.get('value'); exportParms += "&"+select.get('id')+"="+select.get('value');
} }
); );
} }
if ( selection == 'current' ) if ( selection == 'current' ) {
{
var tbody = $(logTable).getElement( 'tbody' ); var tbody = $(logTable).getElement( 'tbody' );
var rows = tbody.getElements( 'tr' ); var rows = tbody.getElements( 'tr' );
if ( rows ) if ( rows ) {
{
var minTime = rows[0].getElement('td').get('text'); var minTime = rows[0].getElement('td').get('text');
exportParms += "&minTime="+encodeURIComponent(minTime); exportParms += "&minTime="+encodeURIComponent(minTime);
var maxTime = rows[rows.length-1].getElement('td').get('text'); var maxTime = rows[rows.length-1].getElement('td').get('text');
@ -244,11 +214,9 @@ function exportRequest()
} }
} }
function updateFilterSelectors() function updateFilterSelectors() {
{
Object.each(options, Object.each(options,
function( values, key ) function( values, key ) {
{
var selector = $('filter['+key+']'); var selector = $('filter['+key+']');
if ( ! selector ) { if ( ! selector ) {
if ( window.console && window.console.log ) { if ( window.console && window.console.log ) {
@ -257,29 +225,21 @@ function updateFilterSelectors()
return; return;
} }
selector.options.length = 1; selector.options.length = 1;
if ( key == 'Level' ) if ( key == 'Level' ) {
{
Object.each(values, Object.each(values,
function( value, label ) function( value, label ) {
{
selector.options[selector.options.length] = new Option( value, label ); selector.options[selector.options.length] = new Option( value, label );
} }
); );
} } else if ( key == 'ServerId' ) {
else if ( key == 'ServerId' )
{
Object.each(values, Object.each(values,
function( value, label ) function( value, label ) {
{
selector.options[selector.options.length] = new Option( value, label ); selector.options[selector.options.length] = new Option( value, label );
} }
); );
} } else {
else
{
values.each( values.each(
function( value ) function( value ) {
{
selector.options[selector.options.length] = new Option( value ); selector.options[selector.options.length] = new Option( value );
} }
); );
@ -290,39 +250,35 @@ function updateFilterSelectors()
); );
} }
function initPage() function initPage() {
{
displayLimit = initialDisplayLimit; displayLimit = initialDisplayLimit;
for ( var i = 1; i <= 9; i++ ) for ( var i = 1; i <= 9; i++ )
logCodes[''+i] = 'DB'+i; logCodes[''+i] = 'DB'+i;
logTable = new HtmlTable( $('logTable'), logTable = new HtmlTable( $('logTable'),
{ {
zebra: true, zebra: true,
sortable: true, sortable: true,
sortReverse: true sortReverse: true
} }
); );
logTable.addEvent( 'sort', function( tbody, index ) logTable.addEvent( 'sort', function( tbody, index ) {
{
var header = tbody.getParent( 'table' ).getElement( 'thead' ); var header = tbody.getParent( 'table' ).getElement( 'thead' );
var columns = header.getElement( 'tr' ).getElements( 'th' ); var columns = header.getElement( 'tr' ).getElements( 'th' );
var column = columns[index]; var column = columns[index];
sortReversed = column.hasClass( 'table-th-sort-rev' ); sortReversed = column.hasClass( 'table-th-sort-rev' );
if ( logCount > displayLimit ) if ( logCount > displayLimit ) {
{
var rows = tbody.getElements( 'tr' ); var rows = tbody.getElements( 'tr' );
var startIndex; var startIndex;
if ( sortReversed ) if ( sortReversed )
startIndex = displayLimit; startIndex = displayLimit;
else else
startIndex = 0; startIndex = 0;
for ( var i = startIndex; logCount > displayLimit; i++ ) for ( var i = startIndex; logCount > displayLimit; i++ ) {
{
rows[i].destroy(); rows[i].destroy();
logCount--; logCount--;
} }
$('displayLogs').set('text', logCount); $('displayLogs').set('text', logCount);
} } // end if loCount > displayLimit
} }
); );
exportFormValidator = new Form.Validator.Inline($('exportForm'), { exportFormValidator = new Form.Validator.Inline($('exportForm'), {

View File

@ -1,15 +1,12 @@
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]': case 'newMonitor[Width]':
if ( monitorWidth >= 0 ) if ( monitorWidth >= 0 )
form.elements['newMonitor[Height]'].value = Math.round((monitorWidth * heightFactor) / widthFactor); form.elements['newMonitor[Height]'].value = Math.round((monitorWidth * heightFactor) / widthFactor);
@ -27,8 +24,7 @@ function updateMonitorDimensions( element )
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]'];
@ -37,17 +33,14 @@ function loadLocations( element )
//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) );

View File

@ -2,36 +2,30 @@ 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
@ -41,13 +35,11 @@ controlOptions[<?php echo $row['Id'] ?>][<?php echo $i ?>] = '<?php echo transla
?> ?>
<?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
@ -55,8 +47,7 @@ monitorNames['<?php echo validJsStr($name) ?>'] = true;
} }
?> ?>
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 )
@ -72,8 +63,7 @@ function validateForm( form )
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 )
@ -82,18 +72,14 @@ function validateForm( form )
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' ) {
else if ( form.elements['newMonitor[Type]'].value == 'Remote' )
{
//if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) ) //if ( !form.elements['newMonitor[Host]'].value || !form.elements['newMonitor[Host]'].value.match( /^[0-9a-zA-Z_.:@-]+$/ ) )
//errors[errors.length] = "<?php echo translate('BadHost') ?>"; //errors[errors.length] = "<?php echo translate('BadHost') ?>";
if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) ) if ( form.elements['newMonitor[Port]'].value && !form.elements['newMonitor[Port]'].value.match( /^\d+$/ ) )
errors[errors.length] = "<?php echo translate('BadPort') ?>"; errors[errors.length] = "<?php echo translate('BadPort') ?>";
//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' ) {
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') ?>";
} }
@ -135,16 +121,14 @@ function validateForm( form )
if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) ) if ( !form.elements['newMonitor[WebColour]'].value || !form.elements['newMonitor[WebColour]'].value.match( /^[#0-9a-zA-Z]+$/ ) )
errors[errors.length] = "<?php echo translate('BadWebColour') ?>"; 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++ )
@ -153,41 +137,37 @@ function updateLinkedMonitors( element )
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;
} }
} }

View File

@ -1,5 +1,4 @@
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';
@ -7,8 +6,7 @@ function submitPreset( element )
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,5 +1,4 @@
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';
@ -7,8 +6,7 @@ function submitCamera( element )
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,7 +1,6 @@
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;
@ -11,15 +10,12 @@ function Monitor( monitorData )
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' ) if ( stateClass != 'alarm' )
element.removeClass( 'alarm' ); element.removeClass( 'alarm' );
if ( stateClass != 'alert' ) if ( stateClass != 'alert' )
@ -30,14 +26,12 @@ function Monitor( monitorData )
} }
}; };
this.getStreamCmdResponse = function( respObj, respText ) this.getStreamCmdResponse = function( respObj, respText ) {
{
if ( this.streamCmdTimer ) if ( this.streamCmdTimer )
this.streamCmdTimer = clearTimeout( this.streamCmdTimer ); this.streamCmdTimer = clearTimeout( this.streamCmdTimer );
var stream = document.getElementById( "liveStream"+this.id ); var stream = document.getElementById( "liveStream"+this.id );
if ( respObj.result == 'Ok' ) if ( respObj.result == 'Ok' ) {
{
this.status = respObj.status; this.status = respObj.status;
this.alarmState = this.status.state; this.alarmState = this.status.state;
@ -49,8 +43,7 @@ function Monitor( monitorData )
else else
stateClass = "idle"; stateClass = "idle";
if ( !COMPACT_MONTAGE ) if ( !COMPACT_MONTAGE ) {
{
$('fpsValue'+this.id).set( 'text', this.status.fps ); $('fpsValue'+this.id).set( 'text', this.status.fps );
$('stateValue'+this.id).set( 'text', stateStrings[this.alarmState] ); $('stateValue'+this.id).set( 'text', stateStrings[this.alarmState] );
this.setStateClass( $('monitorState'+this.id), stateClass ); this.setStateClass( $('monitorState'+this.id), stateClass );
@ -66,22 +59,17 @@ function Monitor( monitorData )
var newAlarm = ( isAlarmed && !wasAlarmed ); var newAlarm = ( isAlarmed && !wasAlarmed );
var oldAlarm = ( !isAlarmed && wasAlarmed ); var oldAlarm = ( !isAlarmed && wasAlarmed );
if ( newAlarm ) if ( newAlarm ) {
{ if ( false && SOUND_ON_ALARM ) {
if ( false && SOUND_ON_ALARM )
{
// Enable the alarm sound // Enable the alarm sound
$('alarmSound').removeClass( 'hidden' ); $('alarmSound').removeClass( 'hidden' );
} }
if ( POPUP_ON_ALARM ) if ( POPUP_ON_ALARM ) {
{
windowToFront(); windowToFront();
} }
} }
if ( false && SOUND_ON_ALARM ) if ( false && SOUND_ON_ALARM ) {
{ if ( oldAlarm ) {
if ( oldAlarm )
{
// Disable alarm sound // Disable alarm sound
$('alarmSound').addClass( 'hidden' ); $('alarmSound').addClass( 'hidden' );
} }
@ -92,9 +80,7 @@ function Monitor( monitorData )
stream.src = stream.src.replace( /auth=\w+/i, 'auth='+this.status.auth ); stream.src = stream.src.replace( /auth=\w+/i, 'auth='+this.status.auth );
console.log("Changed auth to " + this.status.auth ); console.log("Changed auth to " + this.status.auth );
} // end if haev a new auth hash } // end if haev a new auth hash
} } else {
else
{
console.error( respObj.message ); console.error( respObj.message );
// Try to reload the image stream. // Try to reload the image stream.
if ( stream ) if ( stream )
@ -107,8 +93,7 @@ function Monitor( monitorData )
this.lastAlarmState = this.alarmState; 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();
@ -120,8 +105,7 @@ function Monitor( monitorData )
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();
@ -195,10 +179,8 @@ function changeScale() {
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] ); monitors[i] = new Monitor( monitorData[i] );
var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout ); var delay = Math.round( (Math.random()+0.5)*statusRefreshTimeout );
monitors[i].start( delay ); monitors[i].start( delay );

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,5 +1,4 @@
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';
@ -7,8 +6,7 @@ function submitCamera( element )
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';
@ -16,8 +14,7 @@ function gotoStep1( element )
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';
@ -25,10 +22,9 @@ function gotoStep2( element )
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);

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,28 +1,21 @@
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; field.value = minValue;
} } else if ( parseInt(field.value) > parseInt(maxValue) ) {
else if ( parseInt(field.value) > parseInt(maxValue) )
{
field.value = maxValue; field.value = maxValue;
} }
} }
function initPage() function initPage() {
{
return( true ); return( true );
} }

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,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,34 +1,24 @@
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.elements['newUser[Password]'].value ) {
{ if ( !form.conf_password.value ) {
if ( !form.conf_password.value )
{
errors[errors.length] = "You must confirm the password"; errors[errors.length] = "You must confirm the password";
} } else if ( form.elements['newUser[Password]'].value != form.conf_password.value ) {
else if ( form.elements['newUser[Password]'].value != form.conf_password.value )
{
errors[errors.length] = "The new and confirm passwords are different"; errors[errors.length] = "The new and confirm passwords are different";
} }
} } else if ( newUser ) {
else if ( newUser )
{
errors[errors.length] = "You must supply a password"; errors[errors.length] = "You must supply a password";
} }
var monitorIds = new Array(); var monitorIds = new Array();
for ( var i = 0; i < form.elements['monitorIds'].options.length; i++ ) for ( var i = 0; i < form.elements['monitorIds'].options.length; i++ ) {
{
if ( form.elements['monitorIds'].options[i].selected ) if ( form.elements['monitorIds'].options[i].selected )
monitorIds[monitorIds.length] = form.elements['monitorIds'].options[i].value; monitorIds[monitorIds.length] = form.elements['monitorIds'].options[i].value;
} }
form.elements['newUser[MonitorIds]'].value = monitorIds.join( ',' ); form.elements['newUser[MonitorIds]'].value = monitorIds.join( ',' );
if ( errors.length ) if ( errors.length ) {
{
alert( errors.join( "\n" ) ); alert( errors.join( "\n" ) );
return( false ); return( false );
} }

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; form.view.value = currentView;
} } else {
else
{
form.view.value = 'none'; form.view.value = 'none';
} }
} }
if ( openZmWindow ) if ( openZmWindow ) {
{
zmWindow(); zmWindow();
} }

View File

@ -1,17 +1,14 @@
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', '.' );
@ -19,13 +16,11 @@ function generateVideoProgress()
$('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 } );

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);
} else {
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); 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.");
} }
>>>>>>> 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,7 +201,6 @@ 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;
@ -312,21 +208,6 @@ function getStreamCmdResponse( respObj, respText ) {
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 );
@ -446,94 +326,6 @@ 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 )
@ -541,45 +333,15 @@ if ( 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);
}
var statusCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
statusCmdTimeout = statusCmdTimeout/5;
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
}
function statusCmdQuery() {
console.log("Sending statusCmdQuery");
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); checkStreamForErrors("getStatusCmdResponse", respObj);
var statusCmdTimeout = statusRefreshTimeout; var statusCmdTimeout = statusRefreshTimeout;
@ -588,11 +350,9 @@ function getStatusCmdResponse( respObj, respText )
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout ); statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
} }
function statusCmdQuery() function statusCmdQuery() {
{
statusCmdReq.send(); 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 )
@ -600,14 +360,8 @@ if ( 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);
=======
function getAlarmCmdResponse( respObj, respText )
{
checkStreamForErrors("getAlarmCmdResponse", respObj); 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);
=======
else
checkStreamForErrors("getEventCmdResponse", respObj); checkStreamForErrors("getEventCmdResponse", respObj);
>>>>>>> master
var eventCmdTimeout = eventsRefreshTimeout; var eventCmdTimeout = eventsRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
@ -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

View File

@ -319,12 +319,7 @@ function delPoint( index ) {
drawZonePoints(); drawZonePoints();
} }
<<<<<<< HEAD
function limitPointValue( point, loVal, hiVal ) { function limitPointValue( point, loVal, hiVal ) {
=======
function limitPointValue( point, loVal, hiVal )
{
>>>>>>> master
point.value = constrainValue(point.value, loVal, hiVal); point.value = constrainValue(point.value, loVal, hiVal);
} }
@ -454,10 +449,8 @@ function setAlarmState( currentAlarmState ) {
var newAlarm = ( isAlarmed && !wasAlarmed ); var newAlarm = ( isAlarmed && !wasAlarmed );
var oldAlarm = ( !isAlarmed && wasAlarmed ); var oldAlarm = ( !isAlarmed && wasAlarmed );
if ( newAlarm ) if ( newAlarm ) {
{ if ( SOUND_ON_ALARM ) {
if ( SOUND_ON_ALARM )
{
// Enable the alarm sound // Enable the alarm sound
if ( !canPlayPauseAudio ) if ( !canPlayPauseAudio )
$('alarmSound').removeClass( 'hidden' ); $('alarmSound').removeClass( 'hidden' );
@ -465,10 +458,8 @@ function setAlarmState( currentAlarmState ) {
$('MediaPlayer').Play(); $('MediaPlayer').Play();
} }
} }
if ( SOUND_ON_ALARM ) if ( SOUND_ON_ALARM ) {
{ if ( oldAlarm ) {
if ( oldAlarm )
{
// Disable alarm sound // Disable alarm sound
if ( !canPlayPauseAudio ) if ( !canPlayPauseAudio )
$('alarmSound').addClass( 'hidden' ); $('alarmSound').addClass( 'hidden' );
@ -498,8 +489,7 @@ function getStreamCmdResponse( respObj, respText ) {
var delayString = secsToTime( streamStatus.delay ); var delayString = secsToTime( streamStatus.delay );
if ( streamStatus.paused == true ) if ( streamStatus.paused == true ) {
{
streamCmdPause( false ); streamCmdPause( false );
} else if ( streamStatus.delayed == true && streamStatus.rate == 1 ) { } else if ( streamStatus.delayed == true && streamStatus.rate == 1 ) {
streamCmdPlay( false ); streamCmdPlay( false );
@ -537,8 +527,7 @@ function streamCmdPause( action ) {
streamCmdReq.send( streamCmdParms+"&command="+CMD_PAUSE ); streamCmdReq.send( streamCmdParms+"&command="+CMD_PAUSE );
} }
function streamCmdPlay( action ) function streamCmdPlay( action ) {
{
if ( action ) if ( action )
streamCmdReq.send( streamCmdParms+"&command="+CMD_PLAY ); streamCmdReq.send( streamCmdParms+"&command="+CMD_PLAY );
} }
@ -561,12 +550,10 @@ function getStatusCmdResponse( respObj, respText ) {
if ( statusCmdTimer ) if ( statusCmdTimer )
statusCmdTimer = clearTimeout( statusCmdTimer ); statusCmdTimer = clearTimeout( statusCmdTimer );
if ( respObj.result == 'Ok' ) if ( respObj.result == 'Ok' ) {
{
$('fpsValue').set( 'text', respObj.monitor.FrameRate ); $('fpsValue').set( 'text', respObj.monitor.FrameRate );
setAlarmState( respObj.monitor.Status ); setAlarmState( respObj.monitor.Status );
} } else
else
checkStreamForErrors("getStatusCmdResponse", respObj); checkStreamForErrors("getStatusCmdResponse", respObj);
var statusCmdTimeout = statusRefreshTimeout; var statusCmdTimeout = statusRefreshTimeout;
@ -655,9 +642,9 @@ function initPage() {
applyCheckMethod(); applyCheckMethod();
drawZonePoints(); drawZonePoints();
// //
// Imported from watch.js and modified for new zone edit view // Imported from watch.js and modified for new zone edit view
// //
if ( streamMode == "single" ) { if ( streamMode == "single" ) {
statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout ); statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );

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

@ -66,9 +66,9 @@ $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;
@ -130,7 +130,7 @@ $chart = array(
); );
$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']) )
@ -140,8 +140,9 @@ foreach( dbFetchAll( $monitorsSql ) as $row ) {
$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'].')';
@ -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'];
?>
<?php
$chart['activityBars'] = array(); $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;
@ -579,6 +577,7 @@ if ( $startMatches[1] != $endMatches[1] ) {
} }
function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomClass=false ) { function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomClass=false ) {
$html = '';
ob_start(); ob_start();
$labelCount = 0; $labelCount = 0;
$lastTick = 0; $lastTick = 0;
@ -624,10 +623,11 @@ function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomCl
<?php <?php
} }
$lastTick = $i; $lastTick = $i;
} } # end if $lastLabel
} }
$lastLabel = $label; $lastLabel = $label;
} } # end foreach width segment
if ( $zoomClass ) { if ( $zoomClass ) {
$zoomMinTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($lastTick * $chart['data']['x']['density'])) ); $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'])) ); $zoomMaxTime = strftime( STRF_FMT_DATETIME_DB, (int)($chart['data']['x']['lo'] + ($i * $chart['data']['x']['density'])) );
@ -639,7 +639,7 @@ function drawXGrid( $chart, $scale, $labelClass, $tickClass, $gridClass, $zoomCl
</div> </div>
<?php <?php
return( ob_get_clean() ); return( ob_get_clean() );
} } # end function drawXGrid
function drawYGrid( $chart, $scale, $labelClass, $tickClass, $gridClass ) { function drawYGrid( $chart, $scale, $labelClass, $tickClass, $gridClass ) {
ob_start(); ob_start();
@ -664,13 +664,12 @@ function drawYGrid( $chart, $scale, $labelClass, $tickClass, $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="top: <?php echo $chart['graph']['height']-($y+2) ?>px;<?php echo $i <= 0?' border-top: solid 1px black;':'' ?>"></div>
<?php <?php
} }
} } # end foreach line segment
?> ?>
</div> </div>
<?php <?php
return( ob_get_clean() ); 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 )."' )" );
@ -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,12 +735,12 @@ 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
@ -770,7 +769,7 @@ if ( $mode == "overlay" ) {
?> ?>
</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 ?>">
@ -793,14 +792,14 @@ if ( $mode == "overlay" ) {
'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> <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> </div>
<?php <?php
} } # end foreach $MonitorId
} }
foreach( array_keys($monEventSlots) as $monitorId ) { foreach( array_keys($monEventSlots) as $monitorId ) {
?> ?>
@ -830,8 +829,8 @@ foreach( array_keys($monEventSlots) as $monitorId ) {
?> ?>
<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