2008-07-14 21:54:50 +08:00
|
|
|
function setButtonState( element, butClass )
|
|
|
|
{
|
|
|
|
element.className = butClass;
|
|
|
|
element.disabled = (butClass != 'inactive');
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeScale()
|
|
|
|
{
|
2009-03-31 22:06:13 +08:00
|
|
|
var scale = $('scale').get('value');
|
2008-07-14 21:54:50 +08:00
|
|
|
var baseWidth = event.Width;
|
|
|
|
var baseHeight = event.Height;
|
|
|
|
var newWidth = ( baseWidth * scale ) / SCALE_BASE;
|
|
|
|
var newHeight = ( baseHeight * scale ) / SCALE_BASE;
|
|
|
|
|
|
|
|
streamScale( scale );
|
|
|
|
|
2009-05-08 18:04:12 +08:00
|
|
|
/*Stream could be an applet so can't use moo tools*/
|
|
|
|
var streamImg = document.getElementById('evtStream');
|
|
|
|
streamImg.style.width = newWidth + "px";
|
|
|
|
streamImg.style.height = newHeight + "px";
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function changeReplayMode()
|
|
|
|
{
|
2009-03-31 22:06:13 +08:00
|
|
|
var replayMode = $('replayMode').get('value');
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2009-03-31 22:06:13 +08:00
|
|
|
Cookie.write( 'replayMode', replayMode, { duration: 10*365 })
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
refreshWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
var streamParms = "view=request&request=stream&connkey="+connKey;
|
|
|
|
var streamCmdTimer = null;
|
|
|
|
|
|
|
|
var streamStatus = null;
|
|
|
|
var lastEventId = 0;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function getCmdResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( checkStreamForErrors( "getCmdResponse" ,respObj ) )
|
|
|
|
return;
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( streamCmdTimer )
|
|
|
|
streamCmdTimer = $clear( streamCmdTimer );
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
streamStatus = respObj.status;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
var eventId = streamStatus.event;
|
|
|
|
if ( eventId != lastEventId )
|
|
|
|
{
|
|
|
|
eventQuery( eventId );
|
|
|
|
lastEventId = eventId;
|
|
|
|
}
|
|
|
|
if ( streamStatus.paused == true )
|
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
$('modeValue').set( 'text', "Paused" );
|
2008-07-14 21:54:50 +08:00
|
|
|
$('rate').addClass( 'hidden' );
|
|
|
|
streamPause( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
$('modeValue').set( 'text', "Replay" );
|
|
|
|
$('rateValue').set( 'text', streamStatus.rate );
|
2008-07-14 21:54:50 +08:00
|
|
|
$('rate').removeClass( 'hidden' );
|
|
|
|
streamPlay( false );
|
|
|
|
}
|
2009-03-28 00:01:59 +08:00
|
|
|
$('progressValue').set( 'text', secsToTime( parseInt(streamStatus.progress) ) );
|
|
|
|
$('zoomValue').set( 'text', streamStatus.zoom );
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( streamStatus.zoom == "1.0" )
|
|
|
|
setButtonState( $('zoomOutBtn'), 'unavail' );
|
|
|
|
else
|
|
|
|
setButtonState( $('zoomOutBtn'), 'inactive' );
|
|
|
|
|
|
|
|
updateProgressBar();
|
|
|
|
|
|
|
|
streamCmdTimer = streamQuery.delay( streamTimeout );
|
|
|
|
}
|
|
|
|
|
2010-03-01 03:16:40 +08:00
|
|
|
var streamReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getCmdResponse } );
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function streamPause( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'active' );
|
|
|
|
setButtonState( $('playBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'inactive' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'unavail' );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_PAUSE );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamPlay( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'inactive' );
|
2009-05-08 18:04:12 +08:00
|
|
|
if (streamStatus)
|
|
|
|
setButtonState( $('playBtn'), streamStatus.rate==1?'active':'inactive' );
|
2008-07-14 21:54:50 +08:00
|
|
|
setButtonState( $('fastFwdBtn'), 'inactive' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'unavail' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'inactive' );
|
|
|
|
if ( action )
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_PLAY );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function streamFastFwd( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'inactive' );
|
|
|
|
setButtonState( $('playBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastFwdBtn'), 'inactive' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'unavail' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'inactive' );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_FASTFWD );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamSlowFwd( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'inactive' );
|
|
|
|
setButtonState( $('playBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'active' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'unavail' );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_SLOWFWD );
|
2008-07-14 21:54:50 +08:00
|
|
|
setButtonState( $('pauseBtn'), 'active' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'inactive' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function streamSlowRev( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'inactive' );
|
|
|
|
setButtonState( $('playBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'inactive' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'active' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'unavail' );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_SLOWREV );
|
2008-07-14 21:54:50 +08:00
|
|
|
setButtonState( $('pauseBtn'), 'active' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'inactive' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function streamFastRev( action )
|
|
|
|
{
|
|
|
|
setButtonState( $('pauseBtn'), 'inactive' );
|
|
|
|
setButtonState( $('playBtn'), 'inactive' );
|
|
|
|
setButtonState( $('fastFwdBtn'), 'inactive' );
|
|
|
|
setButtonState( $('slowFwdBtn'), 'unavail' );
|
|
|
|
setButtonState( $('slowRevBtn'), 'unavail' );
|
|
|
|
setButtonState( $('fastRevBtn'), 'inactive' );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_FASTREV );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamPrev( action )
|
|
|
|
{
|
|
|
|
streamPlay( false );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_PREV );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamNext( action )
|
|
|
|
{
|
|
|
|
streamPlay( false );
|
|
|
|
if ( action )
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_NEXT );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamZoomIn( x, y )
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_ZOOMIN+"&x="+x+"&y="+y );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamZoomOut()
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_ZOOMOUT );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamScale( scale )
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_SCALE+"&scale="+scale );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamPan( x, y )
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_PAN+"&x="+x+"&y="+y );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamSeek( offset )
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_SEEK+"&offset="+offset );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamQuery()
|
|
|
|
{
|
2010-03-01 03:16:40 +08:00
|
|
|
streamReq.send( streamParms+"&command="+CMD_QUERY );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var slider = null;
|
|
|
|
var scroll = null;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function getEventResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( checkStreamForErrors( "getEventResponse", respObj ) )
|
|
|
|
return;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
event = respObj.event;
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( !$('eventStills').hasClass( 'hidden' ) && currEventId != event.Id )
|
|
|
|
resetEventStills();
|
|
|
|
currEventId = event.Id;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
$('dataId').set( 'text', event.Id );
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( event.Notes )
|
|
|
|
{
|
|
|
|
$('dataCause').setProperty( 'title', event.Notes );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('dataCause').setProperty( 'title', causeString );
|
|
|
|
}
|
2009-03-28 00:01:59 +08:00
|
|
|
$('dataCause').set( 'text', event.Cause );
|
|
|
|
$('dataTime').set( 'text', event.StartTime );
|
|
|
|
$('dataDuration').set( 'text', event.Length );
|
|
|
|
$('dataFrames').set( 'text', event.Frames+"/"+event.AlarmFrames );
|
|
|
|
$('dataScore').set( 'text', event.TotScore+"/"+event.AvgScore+"/"+event.MaxScore );
|
2008-07-14 21:54:50 +08:00
|
|
|
$('eventName').setProperty( 'value', event.Name );
|
|
|
|
|
2011-02-07 00:17:42 +08:00
|
|
|
if ( canEditEvents )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2011-02-07 00:17:42 +08:00
|
|
|
if ( parseInt(event.Archived) )
|
|
|
|
{
|
|
|
|
$('archiveEvent').addClass( 'hidden' );
|
|
|
|
$('unarchiveEvent').removeClass( 'hidden' );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('archiveEvent').removeClass( 'hidden' );
|
|
|
|
$('unarchiveEvent').addClass( 'hidden' );
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
//var eventImg = $('eventImage');
|
|
|
|
//eventImg.setStyles( { 'width': event.width, 'height': event.height } );
|
|
|
|
drawProgressBar();
|
|
|
|
nearEventsQuery( event.Id );
|
|
|
|
}
|
|
|
|
|
2010-03-01 03:16:40 +08:00
|
|
|
var eventReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getEventResponse } );
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function eventQuery( eventId )
|
|
|
|
{
|
|
|
|
var eventParms = "view=request&request=status&entity=event&id="+eventId;
|
2010-03-01 03:16:40 +08:00
|
|
|
eventReq.send( eventParms );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var prevEventId = 0;
|
|
|
|
var nextEventId = 0;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function getNearEventsResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( checkStreamForErrors( "getNearEventsResponse", respObj ) )
|
|
|
|
return;
|
2009-03-28 00:01:59 +08:00
|
|
|
prevEventId = respObj.nearevents.PrevEventId;
|
|
|
|
nextEventId = respObj.nearevents.NextEventId;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
$('prevEventBtn').disabled = !prevEventId;
|
|
|
|
$('nextEventBtn').disabled = !nextEventId;
|
|
|
|
}
|
|
|
|
|
2010-03-01 03:16:40 +08:00
|
|
|
var nearEventsReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getNearEventsResponse } );
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function nearEventsQuery( eventId )
|
|
|
|
{
|
|
|
|
var parms = "view=request&request=status&entity=nearevents&id="+eventId;
|
2010-03-01 03:16:40 +08:00
|
|
|
nearEventsReq.send( parms );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var frameBatch = 40;
|
|
|
|
|
|
|
|
function loadEventThumb( event, frame, loadImage )
|
|
|
|
{
|
|
|
|
var thumbImg = $('eventThumb'+frame.FrameId);
|
|
|
|
if ( !thumbImg )
|
|
|
|
{
|
|
|
|
console.error( "No holder found for frame "+frame.FrameId );
|
|
|
|
return;
|
|
|
|
}
|
2010-02-23 17:12:12 +08:00
|
|
|
var img = new Asset.image( imagePrefix+frame.Image.imagePath,
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
|
|
|
'onload': ( function( loadImage )
|
|
|
|
{
|
|
|
|
thumbImg.setProperty( 'src', img.getProperty( 'src' ) );
|
|
|
|
thumbImg.removeClass( 'placeholder' );
|
|
|
|
thumbImg.setProperty( 'class', frame.Type=='Alarm'?'alarm':'normal' );
|
|
|
|
thumbImg.setProperty( 'title', frame.FrameId+' / '+((frame.Type=='Alarm')?frame.Score:0) );
|
2009-05-08 19:21:28 +08:00
|
|
|
thumbImg.removeEvents( 'click' );
|
2008-07-14 21:54:50 +08:00
|
|
|
thumbImg.addEvent( 'click', function() { locateImage( frame.FrameId, true ); } );
|
|
|
|
if ( loadImage )
|
|
|
|
loadEventImage( event, frame );
|
|
|
|
} ).pass( loadImage )
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-05-08 18:04:12 +08:00
|
|
|
function updateStillsSizes( noDelay )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 19:21:28 +08:00
|
|
|
var containerDim = $('eventThumbs').getSize();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2009-05-08 19:21:28 +08:00
|
|
|
var containerWidth = containerDim.x;
|
|
|
|
var containerHeight = containerDim.y;
|
|
|
|
var popupWidth = parseInt($('eventImage').getStyle( 'width' ));
|
|
|
|
var popupHeight = parseInt($('eventImage').getStyle( 'height' ));
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
var left = (containerWidth - popupWidth)/2;
|
|
|
|
if ( left < 0 ) left = 0;
|
|
|
|
var top = (containerHeight - popupHeight)/2;
|
|
|
|
if ( top < 0 ) top = 0;
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( popupHeight == 0 && !noDelay ) // image not yet loaded lets give it another second
|
|
|
|
{
|
|
|
|
updateStillsSizes.pass( true ).delay( 50 );
|
|
|
|
return;
|
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
$('eventImagePanel').setStyles( {
|
|
|
|
'left': left,
|
|
|
|
'top': top
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadEventImage( event, frame )
|
|
|
|
{
|
2009-04-01 16:01:49 +08:00
|
|
|
console.debug( "Loading "+event.Id+"/"+frame.FrameId );
|
2008-07-14 21:54:50 +08:00
|
|
|
var eventImg = $('eventImage');
|
|
|
|
var thumbImg = $('eventThumb'+frame.FrameId);
|
|
|
|
if ( eventImg.getProperty( 'src' ) != thumbImg.getProperty( 'src' ) )
|
|
|
|
{
|
|
|
|
var eventImagePanel = $('eventImagePanel');
|
|
|
|
|
|
|
|
if ( eventImagePanel.getStyle( 'display' ) != 'none' )
|
|
|
|
{
|
|
|
|
var lastThumbImg = $('eventThumb'+eventImg.getProperty( 'alt' ));
|
|
|
|
lastThumbImg.removeClass('selected');
|
|
|
|
lastThumbImg.setOpacity( 1.0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
eventImg.setProperties( {
|
|
|
|
'class': frame.Type=='Alarm'?'alarm':'normal',
|
|
|
|
'src': thumbImg.getProperty( 'src' ),
|
|
|
|
'title': thumbImg.getProperty( 'title' ),
|
|
|
|
'alt': thumbImg.getProperty( 'alt' ),
|
|
|
|
'width': event.Width,
|
|
|
|
'height': event.Height
|
|
|
|
} );
|
2009-05-08 19:21:28 +08:00
|
|
|
$('eventImageBar').setStyle( 'width', event.Width );
|
2008-09-26 17:47:20 +08:00
|
|
|
if ( frame.Type=='Alarm' )
|
|
|
|
$('eventImageStats').removeClass( 'hidden' );
|
|
|
|
else
|
|
|
|
$('eventImageStats').addClass( 'hidden' );
|
2008-07-14 21:54:50 +08:00
|
|
|
thumbImg.addClass( 'selected' );
|
|
|
|
thumbImg.setOpacity( 0.5 );
|
|
|
|
|
|
|
|
if ( eventImagePanel.getStyle( 'display' ) == 'none' )
|
|
|
|
{
|
|
|
|
eventImagePanel.setOpacity( 0 );
|
|
|
|
updateStillsSizes();
|
|
|
|
eventImagePanel.setStyle( 'display', 'block' );
|
2009-04-01 16:01:49 +08:00
|
|
|
new Fx.Tween( eventImagePanel, { duration: 500, transition: Fx.Transitions.Sine } ).start( 'opacity', 0, 1 );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
$('eventImageNo').set( 'text', frame.FrameId );
|
2008-07-14 21:54:50 +08:00
|
|
|
$('prevImageBtn').disabled = (frame.FrameId==1);
|
|
|
|
$('nextImageBtn').disabled = (frame.FrameId==event.Frames);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideEventImageComplete()
|
|
|
|
{
|
|
|
|
var eventImg = $('eventImage');
|
|
|
|
var thumbImg = $('eventThumb'+$('eventImage').getProperty( 'alt' ));
|
|
|
|
thumbImg.removeClass('selected');
|
|
|
|
thumbImg.setOpacity( 1.0 );
|
|
|
|
$('prevImageBtn').disabled = true;
|
|
|
|
$('nextImageBtn').disabled = true;
|
|
|
|
$('eventImagePanel').setStyle( 'display', 'none' );
|
2008-09-26 17:47:20 +08:00
|
|
|
$('eventImageStats').addClass( 'hidden' );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function hideEventImage()
|
|
|
|
{
|
|
|
|
if ( $('eventImagePanel').getStyle( 'display' ) != 'none' )
|
2009-04-01 16:01:49 +08:00
|
|
|
new Fx.Tween( $('eventImagePanel'), { duration: 500, transition: Fx.Transitions.Sine, onComplete: hideEventImageComplete } ).start( 'opacity', 1, 0 );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetEventStills()
|
|
|
|
{
|
|
|
|
hideEventImage();
|
|
|
|
$('eventThumbs').empty();
|
|
|
|
if ( true || !slider )
|
|
|
|
{
|
|
|
|
slider = new Slider( $('thumbsSlider'), $('thumbsKnob'), {
|
2009-05-08 19:21:28 +08:00
|
|
|
/*steps: event.Frames,*/
|
2008-07-14 21:54:50 +08:00
|
|
|
onChange: function( step )
|
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( !step )
|
|
|
|
step = 0;
|
2009-05-08 19:21:28 +08:00
|
|
|
var fid = parseInt((step * event.Frames)/this.options.steps);
|
|
|
|
if ( fid < 1 )
|
|
|
|
fid = 1;
|
|
|
|
else if ( fid > event.Frames )
|
|
|
|
fid = event.Frames;
|
2008-07-14 21:54:50 +08:00
|
|
|
checkFrames( event.Id, fid );
|
|
|
|
scroll.toElement( 'eventThumb'+fid );
|
|
|
|
}
|
|
|
|
} ).set( 0 );
|
|
|
|
}
|
|
|
|
if ( $('eventThumbs').getStyle( 'height' ).match( /^\d+/ ) < (parseInt(event.Height)+80) )
|
|
|
|
$('eventThumbs').setStyle( 'height', (parseInt(event.Height)+80)+'px' );
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function getFrameResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( checkStreamForErrors( "getFrameResponse", respObj ) )
|
|
|
|
return;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
var frame = respObj.frameimage;
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
if ( !event )
|
|
|
|
{
|
|
|
|
console.error( "No event "+frame.EventId+" found" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !event['frames'] )
|
2009-03-31 21:00:20 +08:00
|
|
|
event['frames'] = new Hash();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
event['frames'][frame.FrameId] = frame;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
loadEventThumb( event, frame, respObj.loopback=="true" );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2010-03-01 03:16:40 +08:00
|
|
|
var frameReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'chain', onSuccess: getFrameResponse } );
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function frameQuery( eventId, frameId, loadImage )
|
|
|
|
{
|
|
|
|
var parms = "view=request&request=status&entity=frameimage&id[0]="+eventId+"&id[1]="+frameId+"&loopback="+loadImage;
|
2010-03-01 03:16:40 +08:00
|
|
|
frameReq.send( parms );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var currFrameId = null;
|
|
|
|
|
|
|
|
function checkFrames( eventId, frameId, loadImage )
|
|
|
|
{
|
|
|
|
if ( !event )
|
|
|
|
{
|
|
|
|
console.error( "No event "+eventId+" found" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !event['frames'] )
|
2009-03-31 21:00:20 +08:00
|
|
|
event['frames'] = new Hash();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
currFrameId = frameId;
|
|
|
|
|
|
|
|
var loFid = frameId - frameBatch/2;
|
|
|
|
if ( loFid < 1 )
|
|
|
|
loFid = 1;
|
|
|
|
var hiFid = loFid + (frameBatch-1);
|
|
|
|
if ( hiFid > event.Frames )
|
|
|
|
hiFid = event.Frames;
|
|
|
|
|
|
|
|
for ( var fid = loFid; fid <= hiFid; fid++ )
|
|
|
|
{
|
|
|
|
if ( !$('eventThumb'+fid) )
|
|
|
|
{
|
|
|
|
var img = new Element( 'img', { 'id': 'eventThumb'+fid, 'src': 'graphics/transparent.gif', 'alt': fid, 'class': 'placeholder' } );
|
2009-05-08 19:21:28 +08:00
|
|
|
img.addEvent( 'click', function () { event['frames'][fid] = null; checkFrames( eventId, fid ) } );
|
2008-07-14 21:54:50 +08:00
|
|
|
frameQuery( eventId, fid, loadImage && (fid == frameId) );
|
|
|
|
var imgs = $('eventThumbs').getElements( 'img' );
|
|
|
|
var injected = false;
|
|
|
|
if ( fid < imgs.length )
|
|
|
|
{
|
|
|
|
img.injectBefore( imgs[fid-1] );
|
|
|
|
injected = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
injected = imgs.some(
|
|
|
|
function( thumbImg, index )
|
|
|
|
{
|
|
|
|
if ( parseInt(img.getProperty( 'alt' )) < parseInt(thumbImg.getProperty( 'alt' )) )
|
|
|
|
{
|
|
|
|
img.injectBefore( thumbImg );
|
|
|
|
return( true );
|
|
|
|
}
|
|
|
|
return( false );
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if ( !injected )
|
|
|
|
{
|
|
|
|
img.injectInside( $('eventThumbs') );
|
|
|
|
}
|
2009-05-08 19:21:28 +08:00
|
|
|
var scale = parseInt(img.getStyle('height'));
|
|
|
|
img.setStyles( {
|
|
|
|
'width': parseInt((event.Width*scale)/100),
|
|
|
|
'height': parseInt((event.Height*scale)/100)
|
|
|
|
} );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
else if ( event['frames'][fid] )
|
|
|
|
{
|
|
|
|
if ( loadImage && (fid == frameId) )
|
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
loadEventImage( event, event['frames'][fid], loadImage );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('prevThumbsBtn').disabled = (frameId==1);
|
|
|
|
$('nextThumbsBtn').disabled = (frameId==event.Frames);
|
|
|
|
}
|
|
|
|
|
|
|
|
function locateImage( frameId, loadImage )
|
|
|
|
{
|
2009-05-08 19:21:28 +08:00
|
|
|
if ( slider )
|
|
|
|
slider.fireEvent( 'tick', slider.toPosition( parseInt((frameId-1)*slider.options.steps/event.Frames) ));
|
2008-07-14 21:54:50 +08:00
|
|
|
checkFrames( event.Id, frameId, loadImage );
|
|
|
|
scroll.toElement( 'eventThumb'+frameId );
|
|
|
|
}
|
|
|
|
|
|
|
|
function prevImage()
|
|
|
|
{
|
|
|
|
if ( currFrameId > 1 )
|
|
|
|
locateImage( parseInt(currFrameId)-1, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextImage()
|
|
|
|
{
|
|
|
|
if ( currFrameId < event.Frames )
|
|
|
|
locateImage( parseInt(currFrameId)+1, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
function prevThumbs()
|
|
|
|
{
|
|
|
|
if ( currFrameId > 1 )
|
2009-05-08 19:21:28 +08:00
|
|
|
locateImage( parseInt(currFrameId)>10?(parseInt(currFrameId)-10):1, $('eventImagePanel').getStyle('display')!="none" );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function nextThumbs()
|
|
|
|
{
|
|
|
|
if ( currFrameId < event.Frames )
|
2009-05-08 19:21:28 +08:00
|
|
|
locateImage( parseInt(currFrameId)<(event.Frames-10)?(parseInt(currFrameId)+10):event.Frames, $('eventImagePanel').getStyle('display')!="none" );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function prevEvent()
|
|
|
|
{
|
|
|
|
if ( prevEventId )
|
|
|
|
{
|
|
|
|
eventQuery( prevEventId );
|
|
|
|
streamPrev( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function nextEvent()
|
|
|
|
{
|
|
|
|
if ( nextEventId )
|
|
|
|
{
|
|
|
|
eventQuery( nextEventId );
|
|
|
|
streamNext( true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function getActResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-05-08 18:04:12 +08:00
|
|
|
if ( checkStreamForErrors( "getActResponse", respObj ) )
|
|
|
|
return;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
if ( respObj.refreshParent )
|
2008-07-14 21:54:50 +08:00
|
|
|
refreshParentWindow();
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
if ( respObj.refreshEvent )
|
2008-07-14 21:54:50 +08:00
|
|
|
eventQuery( event.Id );
|
|
|
|
}
|
|
|
|
|
2010-03-01 03:16:40 +08:00
|
|
|
var actReq = new Request.JSON( { url: thisUrl, method: 'post', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: getActResponse } );
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function actQuery( action, parms )
|
|
|
|
{
|
|
|
|
var actParms = "view=request&request=event&id="+event.Id+"&action="+action;
|
|
|
|
if ( parms != null )
|
2009-03-31 21:00:20 +08:00
|
|
|
actParms += "&"+Hash.toQueryString( parms );
|
2010-03-01 03:16:40 +08:00
|
|
|
actReq.send( actParms );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteEvent()
|
|
|
|
{
|
|
|
|
actQuery( 'delete' );
|
|
|
|
streamNext( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
function renameEvent()
|
|
|
|
{
|
2009-03-31 22:06:13 +08:00
|
|
|
var newName = $('eventName').get('value');
|
2008-07-14 21:54:50 +08:00
|
|
|
actQuery( 'rename', { eventName: newName } );
|
|
|
|
}
|
|
|
|
|
|
|
|
function editEvent()
|
|
|
|
{
|
|
|
|
createPopup( '?view=eventdetail&eid='+event.Id, 'zmEventDetail', 'eventdetail' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function exportEvent()
|
|
|
|
{
|
|
|
|
createPopup( '?view=export&eid='+event.Id, 'zmExport', 'export' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function archiveEvent()
|
|
|
|
{
|
|
|
|
actQuery( 'archive' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function unarchiveEvent()
|
|
|
|
{
|
|
|
|
actQuery( 'unarchive' );
|
|
|
|
}
|
|
|
|
|
2008-09-26 17:47:20 +08:00
|
|
|
function showEventFrames()
|
|
|
|
{
|
|
|
|
createPopup( '?view=frames&eid='+event.Id, 'zmFrames', 'frames' );
|
|
|
|
}
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function showStream()
|
|
|
|
{
|
|
|
|
$('eventStills').addClass( 'hidden' );
|
|
|
|
$('eventStream').removeClass( 'hidden' );
|
|
|
|
$('streamEvent').addClass( 'hidden' );
|
|
|
|
$('stillsEvent').removeClass( 'hidden' );
|
|
|
|
|
|
|
|
//$(window).removeEvent( 'resize', updateStillsSizes );
|
|
|
|
}
|
|
|
|
|
|
|
|
function showStills()
|
|
|
|
{
|
|
|
|
$('eventStream').addClass( 'hidden' );
|
|
|
|
$('eventStills').removeClass( 'hidden' );
|
|
|
|
$('stillsEvent').addClass( 'hidden' );
|
|
|
|
$('streamEvent').removeClass( 'hidden' );
|
|
|
|
streamPause( true );
|
|
|
|
if ( !scroll )
|
|
|
|
{
|
|
|
|
scroll = new Fx.Scroll( 'eventThumbs', {
|
|
|
|
wait: false,
|
|
|
|
duration: 500,
|
|
|
|
offset: { 'x': 0, 'y': 0 },
|
|
|
|
transition: Fx.Transitions.Quad.easeInOut
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
resetEventStills();
|
|
|
|
$(window).addEvent( 'resize', updateStillsSizes );
|
|
|
|
}
|
|
|
|
|
2008-09-26 17:47:20 +08:00
|
|
|
function showFrameStats()
|
|
|
|
{
|
2009-05-26 02:03:46 +08:00
|
|
|
var fid = $('eventImageNo').get('text');
|
2008-09-26 17:47:20 +08:00
|
|
|
createPopup( '?view=stats&eid='+event.Id+'&fid='+fid, 'zmStats', 'stats', event.Width, event.Height );
|
|
|
|
}
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
function videoEvent()
|
|
|
|
{
|
|
|
|
createPopup( '?view=video&eid='+event.Id, 'zmVideo', 'video', event.Width, event.Height );
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawProgressBar()
|
|
|
|
{
|
|
|
|
var barWidth = 0;
|
|
|
|
$('progressBar').addClass( 'invisible' );
|
|
|
|
var cells = $('progressBar').getElements( 'div' );
|
|
|
|
var cellWidth = parseInt( event.Width/$$(cells).length );
|
|
|
|
$$(cells).forEach(
|
|
|
|
function( cell, index )
|
|
|
|
{
|
|
|
|
if ( index == 0 )
|
|
|
|
$(cell).setStyles( { 'left': barWidth, 'width': cellWidth, 'borderLeft': 0 } );
|
|
|
|
else
|
|
|
|
$(cell).setStyles( { 'left': barWidth, 'width': cellWidth } );
|
|
|
|
var offset = parseInt((index*event.Length)/$$(cells).length);
|
|
|
|
$(cell).setProperty( 'title', '+'+secsToTime(offset)+'s' );
|
|
|
|
$(cell).removeEvent( 'click' );
|
|
|
|
$(cell).addEvent( 'click', function(){ streamSeek( offset ); } );
|
|
|
|
barWidth += $(cell).getCoordinates().width;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$('progressBar').setStyle( 'width', barWidth );
|
|
|
|
$('progressBar').removeClass( 'invisible' );
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateProgressBar()
|
|
|
|
{
|
|
|
|
if ( event && streamStatus )
|
|
|
|
{
|
|
|
|
var cells = $('progressBar').getElements( 'div' );
|
|
|
|
var completeIndex = parseInt((($$(cells).length+1)*streamStatus.progress)/event.Length);
|
|
|
|
$$(cells).forEach(
|
|
|
|
function( cell, index )
|
|
|
|
{
|
|
|
|
if ( index < completeIndex )
|
|
|
|
{
|
|
|
|
if ( !$(cell).hasClass( 'complete' ) )
|
|
|
|
{
|
|
|
|
$(cell).addClass( 'complete' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( $(cell).hasClass( 'complete' ) )
|
|
|
|
{
|
|
|
|
$(cell).removeClass( 'complete' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleClick( event )
|
|
|
|
{
|
|
|
|
var target = event.target;
|
|
|
|
var x = event.page.x - $(target).getLeft();
|
|
|
|
var y = event.page.y - $(target).getTop();
|
|
|
|
|
|
|
|
if ( event.shift )
|
|
|
|
streamPan( x, y );
|
|
|
|
else
|
|
|
|
streamZoomIn( x, y );
|
|
|
|
}
|
|
|
|
|
|
|
|
function initPage()
|
|
|
|
{
|
|
|
|
streamCmdTimer = streamQuery.delay( 250 );
|
|
|
|
eventQuery.pass( event.Id ).delay( 500 );
|
|
|
|
|
|
|
|
if ( canStreamNative )
|
|
|
|
{
|
|
|
|
var streamImg = $('imageFeed').getElement('img');
|
|
|
|
if ( !streamImg )
|
|
|
|
streamImg = $('imageFeed').getElement('object');
|
|
|
|
$(streamImg).addEvent( 'click', handleClick.bindWithEvent( $(streamImg) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kick everything off
|
|
|
|
window.addEvent( 'domready', initPage );
|