Handle errors returned from Ajax more gracefully.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2709 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
viseon 2008-12-05 23:58:58 +00:00
parent f2ad7cc770
commit 2419b6582e
1 changed files with 165 additions and 152 deletions

View File

@ -102,6 +102,9 @@ function getStreamCmdResponse( respText )
if ( !respText )
return;
var response = Json.evaluate( respText );
if ( response.result == 'Ok' )
{
streamStatus = response.status;
$('fpsValue').setText( streamStatus.fps );
@ -197,6 +200,7 @@ function getStreamCmdResponse( respText )
{
$('enableDisableAlarms').addClass( 'hidden' );
}
}
var streamCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
@ -349,9 +353,12 @@ function getStatusCmdResponse( respText )
if ( !respText )
return;
var response = Json.evaluate( respText );
$('fpsValue').setText( response.monitor.FrameRate );
if ( response.result == 'Ok' )
{
$('fpsValue').setText( response.monitor.FrameRate );
setAlarmState( response.monitor.Status );
}
var statusCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
@ -401,10 +408,13 @@ function getActResponse( respText )
return;
var response = Json.evaluate( respText );
if ( response.result == 'Ok' )
{
if ( response.refreshParent )
{
window.opener.location.reload();
}
}
eventCmdQuery();
}
@ -435,6 +445,8 @@ function getEventCmdResponse( respText )
return;
var response = Json.evaluate( respText );
if ( response.result == 'Ok' )
{
var dbEvents = response.events.reverse();
var eventList = $('eventList');
var eventListBody = $(eventList).getElement( 'tbody' );
@ -518,6 +530,8 @@ function getEventCmdResponse( respText )
rows[rows.length-1].remove();
rows.length--;
}
}
var eventCmdTimeout = eventsRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT )
eventCmdTimeout = eventCmdTimeout/5;
@ -539,8 +553,7 @@ function getControlResponse( respText )
return;
//console.log( respText );
var response = Json.evaluate( respText );
result = response.result;
if ( result != 'Ok' )
if ( response.result != 'Ok' )
{
alert( "Control response was status = "+response.status+"\nmessage = "+response.message );
}
@ -627,11 +640,11 @@ function handleClick( event )
function initPage()
{
if ( streamMode == "single" )
statusCmdTimer = statusCmdQuery.delay( 1000 );
statusCmdTimer = statusCmdQuery.delay( (Math.random()+0.5)*statusRefreshTimeout );
else
streamCmdTimer = streamCmdQuery.delay( 1000 );
streamCmdTimer = streamCmdQuery.delay( (Math.random()+0.5)*statusRefreshTimeout );
eventCmdTimer = eventCmdQuery.delay( 1500 );
eventCmdTimer = eventCmdQuery.delay( (Math.random()+0.5)*eventsRefreshTimeout );
if ( canStreamNative || streamMode == "single" )
{