2011-06-21 17:19:10 +08:00
|
|
|
var events = new Object();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
function showEvent( eid, fid, width, height )
|
|
|
|
{
|
|
|
|
var url = '?view=event&eid='+eid+'&fid='+fid;
|
|
|
|
url += filterQuery;
|
|
|
|
createPopup( url, 'zmEvent', 'event', width, height );
|
|
|
|
}
|
|
|
|
|
|
|
|
function createEventHtml( event, frame )
|
|
|
|
{
|
|
|
|
var eventHtml = new Element( 'div' );
|
|
|
|
|
|
|
|
if ( event.Archived > 0 )
|
|
|
|
eventHtml.addClass( 'archived' );
|
|
|
|
|
2011-06-21 17:19:10 +08:00
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', monitorNames[event.MonitorId] );
|
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', event.Name+(frame?("("+frame.FrameId+")"):"") );
|
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', event.StartTime+" - "+event.Length+"s" );
|
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', event.Cause );
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( event.Notes )
|
2011-06-21 17:19:10 +08:00
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', event.Notes );
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( event.Archived > 0 )
|
2011-06-21 17:19:10 +08:00
|
|
|
new Element( 'p' ).inject( eventHtml ).set( 'text', archivedString );
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
return( eventHtml );
|
|
|
|
}
|
|
|
|
|
|
|
|
function showEventDetail( eventHtml )
|
|
|
|
{
|
|
|
|
$('instruction').addClass( 'hidden' );
|
|
|
|
$('eventData').empty();
|
|
|
|
$('eventData').adopt( eventHtml );
|
|
|
|
$('eventData').removeClass( 'hidden' );
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function eventDataResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
var event = respObj.event;
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( !event )
|
|
|
|
{
|
|
|
|
console.log( "Null event" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
events[event.Id] = event;
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
if ( respObj.loopback )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
requestFrameData( event.Id, respObj.loopback );
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-28 00:01:59 +08:00
|
|
|
function frameDataResponse( respObj, respText )
|
2008-07-14 21:54:50 +08:00
|
|
|
{
|
2009-03-28 00:01:59 +08:00
|
|
|
var frame = respObj.frameimage;
|
2008-07-14 21:54:50 +08:00
|
|
|
if ( !frame.FrameId )
|
|
|
|
{
|
|
|
|
console.log( "Null frame" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var event = events[frame.EventId];
|
|
|
|
if ( !event )
|
|
|
|
{
|
|
|
|
console.error( "No event "+frame.eventId+" found" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !event['frames'] )
|
2011-06-21 17:19:10 +08:00
|
|
|
event['frames'] = new Object();
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
event['frames'][frame.FrameId] = frame;
|
|
|
|
event['frames'][frame.FrameId]['html'] = createEventHtml( event, frame );
|
|
|
|
showEventDetail( event['frames'][frame.FrameId]['html'] );
|
|
|
|
loadEventImage( frame.Image.imagePath, event.Id, frame.FrameId, event.Width, event.Height );
|
|
|
|
}
|
|
|
|
|
2014-07-30 04:15:31 +08:00
|
|
|
var eventQuery = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: eventDataResponse } );
|
|
|
|
var frameQuery = new Request.JSON( { url: thisUrl, method: 'get', timeout: AJAX_TIMEOUT, link: 'cancel', onSuccess: frameDataResponse } );
|
2008-07-14 21:54:50 +08:00
|
|
|
|
|
|
|
function requestFrameData( eventId, frameId )
|
|
|
|
{
|
|
|
|
if ( !events[eventId] )
|
|
|
|
{
|
|
|
|
eventQuery.options.data = "view=request&request=status&entity=event&id="+eventId+"&loopback="+frameId;
|
2009-03-28 00:01:59 +08:00
|
|
|
eventQuery.send();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frameQuery.options.data = "view=request&request=status&entity=frameimage&id[0]="+eventId+"&id[1]="+frameId;
|
2009-03-28 00:01:59 +08:00
|
|
|
frameQuery.send();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function previewEvent( eventId, frameId )
|
|
|
|
{
|
|
|
|
if ( events[eventId] )
|
|
|
|
{
|
|
|
|
if ( events[eventId]['frames'] )
|
|
|
|
{
|
|
|
|
if ( events[eventId]['frames'][frameId] )
|
|
|
|
{
|
|
|
|
showEventDetail( events[eventId]['frames'][frameId]['html'] );
|
|
|
|
loadEventImage( events[eventId].frames[frameId].Image.imagePath, eventId, frameId, events[eventId].Width, events[eventId].Height );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
requestFrameData( eventId, frameId );
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadEventImage( imagePath, eid, fid, width, height )
|
|
|
|
{
|
|
|
|
var imageSrc = $('imageSrc');
|
2010-02-23 17:12:12 +08:00
|
|
|
imageSrc.setProperty( 'src', imagePrefix+imagePath );
|
2008-07-14 21:54:50 +08:00
|
|
|
imageSrc.removeEvent( 'click' );
|
|
|
|
imageSrc.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) );
|
|
|
|
var eventData = $('eventData');
|
|
|
|
eventData.removeEvent( 'click' );
|
|
|
|
eventData.addEvent( 'click', showEvent.pass( [ eid, fid, width, height ] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
function tlZoomBounds( minTime, maxTime )
|
|
|
|
{
|
|
|
|
console.log( "Zooming" );
|
|
|
|
window.location = '?view='+currentView+filterQuery+'&minTime='+minTime+'&maxTime='+maxTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
function tlZoomRange( midTime, range )
|
|
|
|
{
|
|
|
|
window.location = '?view='+currentView+filterQuery+'&midTime='+midTime+'&range='+range;
|
|
|
|
}
|
|
|
|
|
|
|
|
function tlPan( midTime, range )
|
|
|
|
{
|
|
|
|
window.location = '?view='+currentView+filterQuery+'&midTime='+midTime+'&range='+range;
|
|
|
|
}
|