quotes, fix status ajax call using old auth_hash
This commit is contained in:
parent
d0e70fc501
commit
a9e3d0691f
|
@ -1,33 +1,33 @@
|
|||
|
||||
function showEvents() {
|
||||
$('ptzControls').addClass( 'hidden' );
|
||||
$('events').removeClass( 'hidden' );
|
||||
$('ptzControls').addClass('hidden');
|
||||
$('events').removeClass('hidden');
|
||||
if ( $('eventsControl') ) {
|
||||
$('eventsControl').addClass('hidden');
|
||||
}
|
||||
if ( $('controlControl') ) {
|
||||
$('controlControl').removeClass('hidden');
|
||||
}
|
||||
showMode = "events";
|
||||
showMode = 'events';
|
||||
}
|
||||
|
||||
function showPtzControls() {
|
||||
$('events').addClass( 'hidden' );
|
||||
$('ptzControls').removeClass( 'hidden' );
|
||||
$('events').addClass('hidden');
|
||||
$('ptzControls').removeClass('hidden');
|
||||
if ( $('eventsControl') ) {
|
||||
$('eventsControl').removeClass('hidden');
|
||||
}
|
||||
if ( $('controlControl') ) {
|
||||
$('controlControl').addClass('hidden');
|
||||
}
|
||||
showMode = "control";
|
||||
showMode = 'control';
|
||||
}
|
||||
|
||||
function changeScale() {
|
||||
var scale = $('scale').get('value');
|
||||
var newWidth;
|
||||
var newHeight;
|
||||
if (scale == "0") {
|
||||
if ( scale == '0' || scale == 'auto' ) {
|
||||
var newSize = scaleToFit(monitorWidth, monitorHeight, $j('#liveStream'+monitorId), $j('#replayStatus'));
|
||||
newWidth = newSize.width;
|
||||
newHeight = newSize.height;
|
||||
|
@ -81,7 +81,7 @@ function setAlarmState( currentAlarmState ) {
|
|||
if ( SOUND_ON_ALARM ) {
|
||||
// Enable the alarm sound
|
||||
if ( !canPlayPauseAudio ) {
|
||||
$('alarmSound').removeClass( 'hidden' );
|
||||
$('alarmSound').removeClass('hidden');
|
||||
} else {
|
||||
$('MediaPlayer').Play();
|
||||
}
|
||||
|
@ -90,22 +90,20 @@ function setAlarmState( currentAlarmState ) {
|
|||
window.focus();
|
||||
}
|
||||
}
|
||||
if ( SOUND_ON_ALARM ) {
|
||||
if ( oldAlarm ) {
|
||||
if ( oldAlarm ) { // done with an event do a refresh
|
||||
if ( SOUND_ON_ALARM ) {
|
||||
// Disable alarm sound
|
||||
if ( !canPlayPauseAudio ) {
|
||||
$('alarmSound').addClass( 'hidden' );
|
||||
$('alarmSound').addClass('hidden');
|
||||
} else {
|
||||
$('MediaPlayer').Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldAlarm) { // done with an event do a refresh
|
||||
eventCmdQuery();
|
||||
}
|
||||
|
||||
lastAlarmState = alarmState;
|
||||
}
|
||||
} // end function setAlarmState( currentAlarmState )
|
||||
|
||||
if ( monitorType != 'WebSite' ) {
|
||||
var streamCmdParms = 'view=request&request=stream&connkey='+connKey;
|
||||
|
@ -149,11 +147,11 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
|
||||
$('levelValue').set('text', streamStatus.level);
|
||||
if ( streamStatus.level > 95 ) {
|
||||
$('levelValue').className = "alarm";
|
||||
$('levelValue').className = 'alarm';
|
||||
} else if ( streamStatus.level > 80 ) {
|
||||
$('levelValue').className = "alert";
|
||||
$('levelValue').className = 'alert';
|
||||
} else {
|
||||
$('levelValue').className = "ok";
|
||||
$('levelValue').className = 'ok';
|
||||
}
|
||||
|
||||
var delayString = secsToTime(streamStatus.delay);
|
||||
|
@ -188,7 +186,7 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
}
|
||||
} // rate
|
||||
} else {
|
||||
$('modeValue').set( 'text', "Live" );
|
||||
$('modeValue').set( 'text', 'Live' );
|
||||
$('rate').addClass( 'hidden' );
|
||||
$('delay').addClass( 'hidden' );
|
||||
$('level').addClass( 'hidden' );
|
||||
|
@ -224,7 +222,6 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
|
||||
if ( streamStatus.auth ) {
|
||||
auth_hash = streamStatus.auth;
|
||||
console.log("Have a new auth hash" + streamStatus.auth);
|
||||
// Try to reload the image stream.
|
||||
var streamImg = $('liveStream');
|
||||
if ( streamImg ) {
|
||||
|
@ -237,7 +234,7 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
} // end if have a new auth hash
|
||||
} // end if respObj.status
|
||||
} else {
|
||||
checkStreamForErrors("getStreamCmdResponse", respObj);//log them
|
||||
checkStreamForErrors('getStreamCmdResponse', respObj);//log them
|
||||
// Try to reload the image stream.
|
||||
// If it's an auth error, we should reload the whole page.
|
||||
window.location.reload();
|
||||
|
@ -245,9 +242,9 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
var streamImg = $('liveStream'+monitorId);
|
||||
if ( streamImg ) {
|
||||
streamImg.src = streamImg.src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
|
||||
console.log("Changing livestream src to " + streamImg.src);
|
||||
console.log('Changing livestream src to ' + streamImg.src);
|
||||
} else {
|
||||
console.log("Unable to find streamImg liveStream");
|
||||
console.log('Unable to find streamImg liveStream');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +253,7 @@ function getStreamCmdResponse(respObj, respText) {
|
|||
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) {
|
||||
streamCmdTimeout = streamCmdTimeout/5;
|
||||
}
|
||||
streamCmdTimer = streamCmdQuery.delay( streamCmdTimeout );
|
||||
streamCmdTimer = streamCmdQuery.delay(streamCmdTimeout);
|
||||
}
|
||||
|
||||
function streamCmdPause( action ) {
|
||||
|
@ -268,7 +265,7 @@ function streamCmdPause( action ) {
|
|||
setButtonState('slowRevBtn', 'inactive');
|
||||
setButtonState('fastRevBtn', 'inactive');
|
||||
if ( action ) {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_PAUSE );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_PAUSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,23 +362,23 @@ function streamCmdFastRev( action ) {
|
|||
}
|
||||
|
||||
function streamCmdZoomIn( x, y ) {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_ZOOMIN+"&x="+x+"&y="+y );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_ZOOMIN+"&x="+x+"&y="+y);
|
||||
}
|
||||
|
||||
function streamCmdZoomOut() {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_ZOOMOUT );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_ZOOMOUT);
|
||||
}
|
||||
|
||||
function streamCmdScale( scale ) {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_SCALE+"&scale="+scale );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_SCALE+"&scale="+scale);
|
||||
}
|
||||
|
||||
function streamCmdPan( x, y ) {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_PAN+"&x="+x+"&y="+y );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_PAN+"&x="+x+"&y="+y);
|
||||
}
|
||||
|
||||
function streamCmdQuery() {
|
||||
streamCmdReq.send( streamCmdParms+"&command="+CMD_QUERY );
|
||||
streamCmdReq.send(streamCmdParms+"&command="+CMD_QUERY);
|
||||
}
|
||||
|
||||
if ( monitorType != 'WebSite' ) {
|
||||
|
@ -389,12 +386,18 @@ if ( monitorType != 'WebSite' ) {
|
|||
if ( auth_hash ) {
|
||||
statusCmdParms += '&auth='+auth_hash;
|
||||
}
|
||||
var statusCmdReq = new Request.JSON( {url: monitorUrl, method: 'get', data: statusCmdParms, timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getStatusCmdResponse} );
|
||||
var statusCmdReq = new Request.JSON( {
|
||||
url: monitorUrl,
|
||||
method: 'get',
|
||||
timeout: AJAX_TIMEOUT,
|
||||
link: 'cancel',
|
||||
onSuccess: getStatusCmdResponse
|
||||
} );
|
||||
var statusCmdTimer = null;
|
||||
}
|
||||
|
||||
function getStatusCmdResponse(respObj, respText) {
|
||||
watchdogOk("status");
|
||||
watchdogOk('status');
|
||||
if ( statusCmdTimer ) {
|
||||
statusCmdTimer = clearTimeout(statusCmdTimer);
|
||||
}
|
||||
|
@ -403,22 +406,22 @@ function getStatusCmdResponse(respObj, respText) {
|
|||
$('fpsValue').set('text', respObj.monitor.FrameRate);
|
||||
setAlarmState(respObj.monitor.Status);
|
||||
} else {
|
||||
checkStreamForErrors("getStatusCmdResponse", respObj);
|
||||
checkStreamForErrors('getStatusCmdResponse', respObj);
|
||||
}
|
||||
|
||||
var statusCmdTimeout = statusRefreshTimeout;
|
||||
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) {
|
||||
statusCmdTimeout = statusCmdTimeout/5;
|
||||
}
|
||||
statusCmdTimer = statusCmdQuery.delay( statusCmdTimeout );
|
||||
statusCmdTimer = statusCmdQuery.delay(statusCmdTimeout);
|
||||
}
|
||||
|
||||
function statusCmdQuery() {
|
||||
statusCmdReq.send();
|
||||
statusCmdReq.send(statusCmdParms);
|
||||
}
|
||||
|
||||
if ( monitorType != 'WebSite' ) {
|
||||
var alarmCmdParms = "view=request&request=alarm&id="+monitorId;
|
||||
var alarmCmdParms = 'view=request&request=alarm&id='+monitorId;
|
||||
if ( auth_hash ) {
|
||||
alarmCmdParms += '&auth='+auth_hash;
|
||||
}
|
||||
|
@ -433,8 +436,8 @@ if ( monitorType != 'WebSite' ) {
|
|||
var alarmCmdFirst = true;
|
||||
}
|
||||
|
||||
function getAlarmCmdResponse( respObj, respText ) {
|
||||
checkStreamForErrors("getAlarmCmdResponse", respObj);
|
||||
function getAlarmCmdResponse(respObj, respText) {
|
||||
checkStreamForErrors('getAlarmCmdResponse', respObj);
|
||||
}
|
||||
|
||||
function cmdDisableAlarms() {
|
||||
|
@ -447,14 +450,14 @@ function cmdEnableAlarms() {
|
|||
|
||||
function cmdForceAlarm() {
|
||||
alarmCmdReq.send(alarmCmdParms+"&command=forceAlarm");
|
||||
if (window.event) {
|
||||
if ( window.event ) {
|
||||
window.event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function cmdCancelForcedAlarm() {
|
||||
alarmCmdReq.send(alarmCmdParms+"&command=cancelForcedAlarm");
|
||||
if (window.event) {
|
||||
if ( window.event ) {
|
||||
window.event.preventDefault();
|
||||
}
|
||||
return false;
|
||||
|
@ -470,8 +473,8 @@ function getActResponse( respObj, respText ) {
|
|||
eventCmdQuery();
|
||||
}
|
||||
|
||||
function deleteEvent( event, eventId ) {
|
||||
var actParms = "view=request&request=event&action=delete&id="+eventId;
|
||||
function deleteEvent(event, eventId) {
|
||||
var actParms = 'view=request&request=event&action=delete&id='+eventId;
|
||||
if ( auth_hash ) {
|
||||
actParms += '&auth='+auth_hash;
|
||||
}
|
||||
|
@ -479,10 +482,9 @@ function deleteEvent( event, eventId ) {
|
|||
url: thisUrl,
|
||||
method: 'post',
|
||||
timeout: 3000,
|
||||
data: actParms,
|
||||
onSuccess: getActResponse
|
||||
} );
|
||||
actReq.send();
|
||||
actReq.send(actParms);
|
||||
event.stop();
|
||||
}
|
||||
|
||||
|
@ -495,7 +497,6 @@ if ( monitorType != 'WebSite' ) {
|
|||
url: monitorUrl,
|
||||
method: 'get',
|
||||
timeout: AJAX_TIMEOUT,
|
||||
data: eventCmdParms,
|
||||
link: 'cancel',
|
||||
onSuccess: getEventCmdResponse,
|
||||
onTimeout: eventCmdQuery
|
||||
|
@ -509,19 +510,19 @@ function highlightRow( row ) {
|
|||
}
|
||||
|
||||
function getEventCmdResponse( respObj, respText ) {
|
||||
watchdogOk("event");
|
||||
watchdogOk('event');
|
||||
if ( eventCmdTimer ) {
|
||||
eventCmdTimer = clearTimeout( 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' );
|
||||
var eventListBody = $(eventList).getElement('tbody');
|
||||
var eventListRows = $(eventListBody).getElements('tr');
|
||||
|
||||
eventListRows.each( function( row ) {
|
||||
row.removeClass( 'updated' );
|
||||
eventListRows.each( function(row) {
|
||||
row.removeClass('updated');
|
||||
} );
|
||||
|
||||
for ( var i = 0; i < dbEvents.length; i++ ) {
|
||||
|
@ -575,30 +576,30 @@ function getEventCmdResponse( respObj, respText ) {
|
|||
'mouseout': highlightRow.pass(row)
|
||||
}
|
||||
});
|
||||
link.set( 'text', 'X' );
|
||||
link.inject( row.getElement( 'td.colDelete' ) );
|
||||
link.set('text', 'X');
|
||||
link.inject(row.getElement('td.colDelete'));
|
||||
|
||||
if ( i == 0 ) {
|
||||
row.inject( $(eventListBody) );
|
||||
row.inject($(eventListBody));
|
||||
} else {
|
||||
row.inject( $(eventListBody), 'top' );
|
||||
row.inject($(eventListBody), 'top');
|
||||
if ( !eventCmdFirst ) {
|
||||
row.addClass( 'recent' );
|
||||
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.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' );
|
||||
row.addClass('updated');
|
||||
}
|
||||
|
||||
var rows = $(eventListBody).getElements( 'tr' );
|
||||
var rows = $(eventListBody).getElements('tr');
|
||||
for ( var i = 0; i < rows.length; i++ ) {
|
||||
if ( !rows[i].hasClass( 'updated' ) ) {
|
||||
if ( !rows[i].hasClass('updated') ) {
|
||||
rows[i].destroy();
|
||||
rows.splice( i, 1 );
|
||||
i--;
|
||||
|
@ -609,39 +610,45 @@ function getEventCmdResponse( respObj, respText ) {
|
|||
rows.length--;
|
||||
}
|
||||
} else {
|
||||
checkStreamForErrors("getEventCmdResponse", respObj);
|
||||
checkStreamForErrors('getEventCmdResponse', respObj);
|
||||
}
|
||||
|
||||
var eventCmdTimeout = eventsRefreshTimeout;
|
||||
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) {
|
||||
eventCmdTimeout = eventCmdTimeout/5;
|
||||
}
|
||||
eventCmdTimer = eventCmdQuery.delay( eventCmdTimeout );
|
||||
eventCmdTimer = eventCmdQuery.delay(eventCmdTimeout);
|
||||
eventCmdFirst = false;
|
||||
}
|
||||
|
||||
function eventCmdQuery() {
|
||||
if ( eventCmdTimer ) { // avoid firing another if we are firing one
|
||||
eventCmdTimer = clearTimeout( eventCmdTimer );
|
||||
eventCmdTimer = clearTimeout(eventCmdTimer);
|
||||
}
|
||||
eventCmdReq.send();
|
||||
eventCmdReq.send(eventCmdParms);
|
||||
}
|
||||
|
||||
if ( monitorType != 'WebSite' ) {
|
||||
var controlParms = "view=request&request=control&id="+monitorId;
|
||||
var controlParms = 'view=request&request=control&id='+monitorId;
|
||||
if ( auth_hash ) {
|
||||
controlParms += '&auth='+auth_hash;
|
||||
}
|
||||
var controlReq = new Request.JSON( {url: monitorUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getControlResponse} );
|
||||
var controlReq = new Request.JSON( {
|
||||
url: monitorUrl,
|
||||
method: 'post',
|
||||
timeout: AJAX_TIMEOUT,
|
||||
link: 'cancel',
|
||||
onSuccess: getControlResponse
|
||||
} );
|
||||
}
|
||||
|
||||
function getControlResponse( respObj, respText ) {
|
||||
function getControlResponse(respObj, respText) {
|
||||
if ( !respObj ) {
|
||||
return;
|
||||
}
|
||||
//console.log( respText );
|
||||
if ( respObj.result != 'Ok' ) {
|
||||
alert( "Control response was status = "+respObj.status+"\nmessage = "+respObj.message );
|
||||
alert("Control response was status = "+respObj.status+"\nmessage = "+respObj.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -674,19 +681,19 @@ function controlCmd( control, event, xtell, ytell ) {
|
|||
locParms += "&yge="+yge;
|
||||
}
|
||||
}
|
||||
controlReq.send( controlParms+"&control="+control+locParms );
|
||||
if ( streamMode == "single" ) {
|
||||
fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 );
|
||||
controlReq.send(controlParms+"&control="+control+locParms);
|
||||
if ( streamMode == 'single' ) {
|
||||
fetchImage.pass($('imageFeed').getElement('img')).delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
function controlCmdImage( x, y ) {
|
||||
var imageControlParms = controlParms;
|
||||
imageControlParms += "&scale="+scale;
|
||||
imageControlParms += "&control="+imageControlMode;
|
||||
imageControlParms += '&scale='+scale;
|
||||
imageControlParms += '&control='+imageControlMode;
|
||||
|
||||
controlReq.send( imageControlParms+"&x="+x+"&y="+y );
|
||||
if ( streamMode == "single" ) {
|
||||
if ( streamMode == 'single' ) {
|
||||
fetchImage.pass( $('imageFeed').getElement('img') ).delay( 1000 );
|
||||
}
|
||||
}
|
||||
|
@ -700,7 +707,7 @@ function handleClick( event ) {
|
|||
var x = event.page.x - $(target).getLeft();
|
||||
var y = event.page.y - $(target).getTop();
|
||||
|
||||
if ( showMode == "events" || !imageControlMode ) {
|
||||
if ( showMode == 'events' || !imageControlMode ) {
|
||||
if ( event.shift ) {
|
||||
streamCmdPan( x, y );
|
||||
} else if ( event.event.ctrlKey ) {
|
||||
|
@ -760,7 +767,7 @@ function reloadWebSite() {
|
|||
|
||||
function initPage() {
|
||||
if ( monitorType != 'WebSite' ) {
|
||||
if ( streamMode == "single" ) {
|
||||
if ( streamMode == 'single' ) {
|
||||
statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
|
||||
watchdogCheck.pass('status').periodical(statusRefreshTimeout*2);
|
||||
} else {
|
||||
|
@ -771,12 +778,12 @@ function initPage() {
|
|||
eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.1)*statusRefreshTimeout );
|
||||
watchdogCheck.pass('event').periodical(eventsRefreshTimeout*2);
|
||||
|
||||
if ( canStreamNative || streamMode == "single" ) {
|
||||
if ( canStreamNative || streamMode == 'single' ) {
|
||||
var streamImg = $('imageFeed').getElement('img');
|
||||
if ( !streamImg ) {
|
||||
streamImg = $('imageFeed').getElement('object');
|
||||
}
|
||||
if ( streamMode == "single" ) {
|
||||
if ( streamMode == 'single' ) {
|
||||
streamImg.addEvent('click', fetchImage.pass(streamImg));
|
||||
fetchImage.pass(streamImg).periodical(imageRefreshTimeout);
|
||||
} else {
|
||||
|
@ -789,7 +796,7 @@ function initPage() {
|
|||
if ( refreshApplet && appletRefreshTime ) {
|
||||
appletRefresh.delay(appletRefreshTime*1000);
|
||||
}
|
||||
if ( scale == "auto" ) changeScale();
|
||||
if ( scale == 'auto' ) changeScale();
|
||||
if ( window.history.length == 1 ) {
|
||||
$j('#closeControl').html('');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue