simplify some code, pass around zm_event json objects instead of event_id. Each monitor has it's own image so when loading event data put it into a div/img referenced by monitor Id

This commit is contained in:
Isaac Connor 2020-01-05 17:32:27 -05:00
parent 4cc82e24f3
commit 3250e0edfe
1 changed files with 23 additions and 23 deletions

View File

@ -67,17 +67,20 @@ function frameDataResponse( respObj, respText ) {
zm_event['frames'][frame.FrameId] = frame; zm_event['frames'][frame.FrameId] = frame;
zm_event['frames'][frame.FrameId]['html'] = createEventHtml( zm_event, frame ); zm_event['frames'][frame.FrameId]['html'] = createEventHtml( zm_event, frame );
showEventData(frame.EventId, frame.FrameId); showEventData(zm_event, frame.FrameId);
} }
function showEventData(eventId, frameId) { function showEventData(zm_event, frameId) {
if ( events[eventId] ) { if ( zm_event ) {
var zm_event = events[eventId];
if ( zm_event['frames'] ) { if ( zm_event['frames'] ) {
if ( zm_event['frames'][frameId] ) { if ( zm_event['frames'][frameId] ) {
showEventDetail( zm_event['frames'][frameId]['html'] ); $('instruction').addClass('hidden');
eventData = $('eventData'+zm_event.MonitorId);
eventData.empty();
eventData.adopt(zm_event['frames'][frameId]['html']);
eventData.removeClass('hidden');
var imagePath = 'index.php?view=image&eid='+eventId+'&fid='+frameId; var imagePath = 'index.php?view=image&eid='+eventId+'&fid='+frameId;
loadEventImage(imagePath, eventId, frameId); loadEventImage(imagePath, zm_event, frameId);
return; return;
} else { } else {
console.log('No frames for ' + frameId); console.log('No frames for ' + frameId);
@ -86,7 +89,7 @@ function showEventData(eventId, frameId) {
console.log('No frames'); console.log('No frames');
} }
} else { } else {
console.log('No event for ' + eventId); console.log('No event');
} }
} }
@ -125,25 +128,22 @@ function previewEvent(slot) {
} }
} }
function loadEventImage( imagePath, eid, fid ) { function loadEventImage( imagePath, zm_event, fid ) {
var eventData = $j('#eventData'); var imageSrc = $('imageSrc'+zm_event.MonitorId);
var imageSrc = $j('#imageSrc');
imageSrc.show(); imageSrc.show();
imageSrc.attr('src', imagePath); imageSrc.setProperty('src', imagePath);
imageSrc.attr('data-event-id', eid); imageSrc.setAttribute('data-event-id', zm_event.Id);
imageSrc.attr('data-frame-id', fid); imageSrc.setAttribute('data-frame-id', fid);
imageSrc.off('click'); imageSrc.onclick=window['showEvent'].bind(imageSrc, imageSrc);
imageSrc.click(function() {
showEvent(this);
});
eventData.attr('data-event-id', eid); var eventData = $('eventData'.zm_event.MonitorId);
eventData.attr('data-frame-id', fid); if ( eventData ) {
eventData.off('click'); eventData.removeEvent('click');
eventData.click(function() { eventData.addEvent('click', showEvent.pass());
showEvent(this); } else {
}); console.log("No eventdata area found for monitor " + zm_event.MonitorId);
}
} }
function tlZoomBounds(event) { function tlZoomBounds(event) {