spacing, code style, code comments

This commit is contained in:
Isaac Connor 2021-05-22 11:34:09 -04:00
parent 2e12bc08cd
commit bc384d6fbe
1 changed files with 139 additions and 130 deletions

View File

@ -215,14 +215,14 @@ function changeReplayMode() {
function changeRate() { function changeRate() {
var rate = parseInt($j('select[name="rate"]').val()); var rate = parseInt($j('select[name="rate"]').val());
if ( ! rate ) { if (!rate) {
pauseClicked(); pauseClicked();
} else if ( rate < 0 ) { } else if (rate < 0) {
if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back. if (vid) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back.
revSpeed = rates[rates.indexOf(-1*rate)-1]/100; revSpeed = rates[rates.indexOf(-1*rate)-1]/100;
clearInterval(intervalRewind); clearInterval(intervalRewind);
intervalRewind = setInterval(function() { intervalRewind = setInterval(function() {
if ( vid.currentTime() <= 0 ) { if (vid.currentTime() <= 0) {
clearInterval(intervalRewind); clearInterval(intervalRewind);
vid.pause(); vid.pause();
} else { } else {
@ -254,26 +254,24 @@ function getCmdResponse(respObj, respText) {
zmsBroke = false; zmsBroke = false;
if ( streamCmdTimer ) { if (streamCmdTimer) streamCmdTimer = clearTimeout(streamCmdTimer);
streamCmdTimer = clearTimeout(streamCmdTimer);
}
streamStatus = respObj.status; streamStatus = respObj.status;
if (!streamStatus) { if (!streamStatus) {
console.log('No status in respObj'); console.log('No status in respObj');
console.log(respObj); console.log(respObj);
return; return;
} else if ( streamStatus.duration && ( streamStatus.duration != parseFloat(eventData.Length) ) ) { } else if (streamStatus.duration && ( streamStatus.duration != parseFloat(eventData.Length) )) {
eventData.Length = streamStatus.duration; eventData.Length = streamStatus.duration;
} }
if ( streamStatus.progress > parseFloat(eventData.Length) ) { if (streamStatus.progress > parseFloat(eventData.Length)) {
console.log("Limiting progress to " + streamStatus.progress + ' >= ' + parseFloat(eventData.Length) ); console.log("Limiting progress to " + streamStatus.progress + ' >= ' + parseFloat(eventData.Length) );
streamStatus.progress = parseFloat(eventData.Length); streamStatus.progress = parseFloat(eventData.Length);
} //Limit progress to reality } //Limit progress to reality
var eventId = streamStatus.event; var eventId = streamStatus.event;
if ( lastEventId ) { if (lastEventId) {
if ( eventId != lastEventId ) { if (eventId != lastEventId) {
//Doesn't run on first load, prevents a double hit on event and nearEvents ajax //Doesn't run on first load, prevents a double hit on event and nearEvents ajax
eventQuery(eventId); eventQuery(eventId);
initialAlarmCues(eventId); //zms uses this instead of a page reload, must call ajax+render initialAlarmCues(eventId); //zms uses this instead of a page reload, must call ajax+render
@ -283,7 +281,7 @@ function getCmdResponse(respObj, respText) {
lastEventId = eventId; //Only fires on first load. lastEventId = eventId; //Only fires on first load.
} }
if ( streamStatus.paused == true ) { if (streamStatus.paused == true) {
streamPause( ); streamPause( );
} else { } else {
$j('select[name="rate"]').val(streamStatus.rate*100); $j('select[name="rate"]').val(streamStatus.rate*100);
@ -292,19 +290,19 @@ function getCmdResponse(respObj, respText) {
} }
$j('#progressValue').html(secsToTime(parseInt(streamStatus.progress))); $j('#progressValue').html(secsToTime(parseInt(streamStatus.progress)));
$j('#zoomValue').html(streamStatus.zoom); $j('#zoomValue').html(streamStatus.zoom);
if ( streamStatus.zoom == "1.0" ) { if (streamStatus.zoom == '1.0') {
setButtonState( 'zoomOutBtn', 'unavail' ); setButtonState('zoomOutBtn', 'unavail');
} else { } else {
setButtonState( 'zoomOutBtn', 'inactive' ); setButtonState('zoomOutBtn', 'inactive');
} }
updateProgressBar(); updateProgressBar();
if ( streamStatus.auth ) { if (streamStatus.auth) {
// Try to reload the image stream. // Try to reload the image stream.
var streamImg = $j('#evtStream'); var streamImg = $j('#evtStream');
if ( streamImg ) { if (streamImg) {
streamImg.src = streamImg.src.replace( /auth=\w+/i, 'auth='+streamStatus.auth ); streamImg.src = streamImg.src.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
} }
} // end if haev a new auth hash } // end if haev a new auth hash
@ -312,8 +310,8 @@ function getCmdResponse(respObj, respText) {
} // end function getCmdResponse( respObj, respText ) } // end function getCmdResponse( respObj, respText )
function pauseClicked() { function pauseClicked() {
if ( vid ) { if (vid) {
if ( intervalRewind ) { if (intervalRewind) {
stopFastRev(); stopFastRev();
} }
vid.pause(); vid.pause();
@ -325,22 +323,22 @@ function pauseClicked() {
function streamPause() { function streamPause() {
$j('#modeValue').html('Paused'); $j('#modeValue').html('Paused');
setButtonState( 'pauseBtn', 'active' ); setButtonState('pauseBtn', 'active');
setButtonState( 'playBtn', 'inactive' ); setButtonState('playBtn', 'inactive');
setButtonState( 'fastFwdBtn', 'unavail' ); setButtonState('fastFwdBtn', 'unavail');
setButtonState( 'slowFwdBtn', 'inactive' ); setButtonState('slowFwdBtn', 'inactive');
setButtonState( 'slowRevBtn', 'inactive' ); setButtonState('slowRevBtn', 'inactive');
setButtonState( 'fastRevBtn', 'unavail' ); setButtonState('fastRevBtn', 'unavail');
} }
function playClicked( ) { function playClicked( ) {
var rate_select = $j('select[name="rate"]'); var rate_select = $j('select[name="rate"]');
if ( ! rate_select.val() ) { if (!rate_select.val()) {
$j('select[name="rate"]').val(100); $j('select[name="rate"]').val(100);
} }
if ( vid ) { if (vid) {
if ( vid.paused() ) { if (vid.paused()) {
vid.play(); vid.play();
} else { } else {
vjsPlay(); //handles fast forward and rewind vjsPlay(); //handles fast forward and rewind
@ -352,7 +350,7 @@ function playClicked( ) {
} }
function vjsPlay() { //catches if we change mode programatically function vjsPlay() { //catches if we change mode programatically
if ( intervalRewind ) { if (intervalRewind) {
stopFastRev(); stopFastRev();
} }
$j('select[name="rate"]').val(vid.playbackRate()*100); $j('select[name="rate"]').val(vid.playbackRate()*100);
@ -361,25 +359,25 @@ function vjsPlay() { //catches if we change mode programatically
} }
function streamPlay( ) { function streamPlay( ) {
setButtonState( 'pauseBtn', 'inactive' ); setButtonState('pauseBtn', 'inactive');
setButtonState( 'playBtn', 'active' ); setButtonState('playBtn', 'active');
setButtonState( 'fastFwdBtn', 'inactive' ); setButtonState('fastFwdBtn', 'inactive');
setButtonState( 'slowFwdBtn', 'unavail' ); setButtonState('slowFwdBtn', 'unavail');
setButtonState( 'slowRevBtn', 'unavail' ); setButtonState('slowRevBtn', 'unavail');
setButtonState( 'fastRevBtn', 'inactive' ); setButtonState('fastRevBtn', 'inactive');
} }
function streamFastFwd( action ) { function streamFastFwd( action ) {
setButtonState( 'pauseBtn', 'inactive' ); setButtonState('pauseBtn', 'inactive');
setButtonState( 'playBtn', 'inactive' ); setButtonState('playBtn', 'inactive');
setButtonState( 'fastFwdBtn', 'active' ); setButtonState('fastFwdBtn', 'active');
setButtonState( 'slowFwdBtn', 'unavail' ); setButtonState('slowFwdBtn', 'unavail');
setButtonState( 'slowRevBtn', 'unavail' ); setButtonState('slowRevBtn', 'unavail');
setButtonState( 'fastRevBtn', 'inactive' ); setButtonState('fastRevBtn', 'inactive');
if ( vid ) { if (vid) {
if ( revSpeed != .5 ) stopFastRev(); if (revSpeed != .5) stopFastRev();
vid.playbackRate(rates[rates.indexOf(vid.playbackRate()*100)-1]/100); vid.playbackRate(rates[rates.indexOf(vid.playbackRate()*100)-1]/100);
if ( rates.indexOf(vid.playbackRate()*100)-1 == -1 ) { if (rates.indexOf(vid.playbackRate()*100)-1 == -1) {
setButtonState('fastFwdBtn', 'unavail'); setButtonState('fastFwdBtn', 'unavail');
} }
$j('select[name="rate"]').val(vid.playbackRate()*100); $j('select[name="rate"]').val(vid.playbackRate()*100);
@ -389,17 +387,16 @@ function streamFastFwd( action ) {
} }
} }
function streamSlowFwd(action) {
function streamSlowFwd( action ) { if (vid) {
if ( vid ) {
vid.currentTime(vid.currentTime() + spf); vid.currentTime(vid.currentTime() + spf);
} else { } else {
streamReq({command: CMD_SLOWFWD}); streamReq({command: CMD_SLOWFWD});
} }
} }
function streamSlowRev( action ) { function streamSlowRev(action) {
if ( vid ) { if (vid) {
vid.currentTime(vid.currentTime() - spf); vid.currentTime(vid.currentTime() - spf);
} else { } else {
streamReq({command: CMD_SLOWREV}); streamReq({command: CMD_SLOWREV});
@ -414,17 +411,20 @@ function stopFastRev() {
revSpeed = .5; revSpeed = .5;
} }
function streamFastRev( action ) { /* Called when rewind button is clicked
setButtonState( 'pauseBtn', 'inactive' ); * should cycle through the reverse rates including pause
setButtonState( 'playBtn', 'inactive' ); */
setButtonState( 'fastFwdBtn', 'inactive' ); function streamFastRev(action) {
setButtonState( 'slowFwdBtn', 'unavail' ); setButtonState('pauseBtn', 'inactive');
setButtonState( 'slowRevBtn', 'unavail' ); setButtonState('playBtn', 'inactive');
setButtonState( 'fastRevBtn', 'active' ); setButtonState('fastFwdBtn', 'inactive');
if ( vid ) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back. setButtonState('slowFwdBtn', 'unavail');
setButtonState('slowRevBtn', 'unavail');
setButtonState('fastRevBtn', 'active');
if (vid) { //There is no reverse play with mp4. Set the speed to 0 and manually set the time back.
revSpeed = rates[rates.indexOf(revSpeed*100)-1]/100; revSpeed = rates[rates.indexOf(revSpeed*100)-1]/100;
if ( rates.indexOf(revSpeed*100) == 0 ) { if (rates.indexOf(revSpeed*100) == 0) {
setButtonState( 'fastRevBtn', 'unavail' ); setButtonState('fastRevBtn', 'unavail');
} }
clearInterval(intervalRewind); clearInterval(intervalRewind);
$j('select[name="rate"]').val(-revSpeed*100); $j('select[name="rate"]').val(-revSpeed*100);
@ -444,11 +444,12 @@ function streamFastRev( action ) {
} }
function streamPrev(action) { function streamPrev(action) {
if ( action ) { if (action) {
$j(".vjsMessage").remove(); $j(".vjsMessage").remove();
location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery); location.replace(thisUrl + '?view=event&eid=' + prevEventId + filterQuery + sortQuery);
return; return;
/* Ideally I'd like to get back to this style
if ( vid && PrevEventDefVideoPath.indexOf("view_video") > 0 ) { if ( vid && PrevEventDefVideoPath.indexOf("view_video") > 0 ) {
CurEventDefVideoPath = PrevEventDefVideoPath; CurEventDefVideoPath = PrevEventDefVideoPath;
eventQuery(prevEventId); eventQuery(prevEventId);
@ -458,36 +459,44 @@ function streamPrev(action) {
streamReq({command: CMD_PREV}); streamReq({command: CMD_PREV});
streamPlay(); streamPlay();
} }
*/
} }
} }
function streamNext(action) { function streamNext(action) {
if ( action ) { if (!action) {
$j(".vjsMessage").remove();//This shouldn't happen
if ( nextEventId == 0 ) { //handles deleting last event.
pauseClicked();
var hideContainer = $j('#eventVideo');
var hideStream = $j(vid ? "#videoobj" : "#evtStream").height() + (vid ? 0 :$j("#progressBar").height());
hideContainer.prepend('<p class="vjsMessage" style="height: ' + hideStream + 'px; line-height: ' + hideStream + 'px;">No more events</p>');
if ( vid == null ) zmsBroke = true;
return;
}
// We used to try to dynamically update all the bits in the page, which is really complex
// How about we just reload the page?
//
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
return; return;
if ( vid && ( NextEventDefVideoPath.indexOf('view_video') > 0 ) ) { //on and staying with videojs
CurEventDefVideoPath = NextEventDefVideoPath;
eventQuery(nextEventId);
} else if ( zmsBroke || (vid && NextEventDefVideoPath.indexOf("view_video") < 0) || NextEventDefVideoPath.indexOf("view_video") > 0) {//reload zms, leaving vjs, moving to vjs
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
} else {
streamReq({command: CMD_NEXT});
streamPlay();
}
} }
}
$j(".vjsMessage").remove();//This shouldn't happen
if (nextEventId == 0) { //handles deleting last event.
pauseClicked();
var hideContainer = $j('#eventVideo');
var hideStream = $j(vid ? "#videoobj" : "#evtStream").height() + (vid ? 0 :$j("#progressBar").height());
hideContainer.prepend('<p class="vjsMessage" style="height: ' + hideStream + 'px; line-height: ' + hideStream + 'px;">No more events</p>');
if (vid == null) zmsBroke = true;
return;
}
// We used to try to dynamically update all the bits in the page, which is really complex
// How about we just reload the page?
//
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
return;
if (vid && ( NextEventDefVideoPath.indexOf('view_video') > 0 )) {
// on and staying with videojs
CurEventDefVideoPath = NextEventDefVideoPath;
eventQuery(nextEventId);
} else if (
zmsBroke ||
(vid && NextEventDefVideoPath.indexOf("view_video") < 0) ||
NextEventDefVideoPath.indexOf("view_video") > 0
) {//reload zms, leaving vjs, moving to vjs
location.replace(thisUrl + '?view=event&eid=' + nextEventId + filterQuery + sortQuery);
} else {
streamReq({command: CMD_NEXT});
streamPlay();
}
} // end function streamNext(action)
function vjsPanZoom(action, x, y) { //Pan and zoom with centering where the click occurs function vjsPanZoom(action, x, y) { //Pan and zoom with centering where the click occurs
var outer = $j('#videoobj'); var outer = $j('#videoobj');
@ -530,7 +539,7 @@ function vjsPanZoom(action, x, y) { //Pan and zoom with centering where the clic
video.css('transform', 'matrix('+zoom+', 0, 0, '+zoom+', '+x+', '+y+')'); video.css('transform', 'matrix('+zoom+', 0, 0, '+zoom+', '+x+', '+y+')');
} }
function streamZoomIn( x, y ) { function streamZoomIn(x, y) {
if (vid) { if (vid) {
vjsPanZoom('zoom', x, y); vjsPanZoom('zoom', x, y);
} else { } else {
@ -546,11 +555,11 @@ function streamZoomOut() {
} }
} }
function streamScale( scale ) { function streamScale(scale) {
streamReq({command: CMD_SCALE, scale: scale}); streamReq({command: CMD_SCALE, scale: scale});
} }
function streamPan( x, y ) { function streamPan(x, y) {
if (vid) { if (vid) {
vjsPanZoom('pan', x, y); vjsPanZoom('pan', x, y);
} else { } else {
@ -558,7 +567,7 @@ function streamPan( x, y ) {
} }
} }
function streamSeek( offset ) { function streamSeek(offset) {
streamReq({command: CMD_SEEK, offset: offset}); streamReq({command: CMD_SEEK, offset: offset});
} }
@ -619,7 +628,7 @@ function getEventResponse(respObj, respText) {
function eventQuery(eventId) { function eventQuery(eventId) {
var data = {}; var data = {};
data.id = eventId; data.id = eventId;
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
$j.getJSON(thisUrl + '?view=request&request=status&entity=event', data) $j.getJSON(thisUrl + '?view=request&request=status&entity=event', data)
.done(getEventResponse) .done(getEventResponse)
@ -627,7 +636,7 @@ function eventQuery(eventId) {
} }
function getNearEventsResponse(respObj, respText) { function getNearEventsResponse(respObj, respText) {
if ( checkStreamForErrors('getNearEventsResponse', respObj) ) { if (checkStreamForErrors('getNearEventsResponse', respObj)) {
return; return;
} }
console.log(respObj); console.log(respObj);
@ -649,25 +658,25 @@ function nearEventsQuery(eventId) {
} }
function getFrameResponse(respObj, respText) { function getFrameResponse(respObj, respText) {
if ( checkStreamForErrors('getFrameResponse', respObj) ) { if (checkStreamForErrors('getFrameResponse', respObj)) {
return; return;
} }
var frame = respObj.frameimage; var frame = respObj.frameimage;
if ( !eventData ) { if (!eventData) {
console.error('No event '+frame.EventId+' found'); console.error('No event '+frame.EventId+' found');
return; return;
} }
if ( !eventData['frames'] ) { if (!eventData['frames']) {
eventData['frames'] = {}; eventData['frames'] = {};
} }
eventData['frames'][frame.FrameId] = frame; eventData['frames'][frame.FrameId] = frame;
} }
function frameQuery( eventId, frameId, loadImage ) { function frameQuery(eventId, frameId, loadImage) {
var data = {}; var data = {};
data.loopback = loadImage; data.loopback = loadImage;
data.id = {eventId, frameId}; data.id = {eventId, frameId};
@ -678,33 +687,33 @@ function frameQuery( eventId, frameId, loadImage ) {
} }
function prevEvent() { function prevEvent() {
if ( prevEventId ) { if (prevEventId) {
eventQuery( prevEventId ); eventQuery(prevEventId);
streamPrev( true ); streamPrev(true);
} }
} }
function nextEvent() { function nextEvent() {
if ( nextEventId ) { if (nextEventId) {
eventQuery( nextEventId ); eventQuery(nextEventId);
streamNext( true ); streamNext(true);
} }
} }
function getActResponse( respObj, respText ) { function getActResponse(respObj, respText) {
if ( checkStreamForErrors( "getActResponse", respObj ) ) { if (checkStreamForErrors('getActResponse', respObj)) {
return; return;
} }
if ( respObj.refreshEvent ) { if (respObj.refreshEvent) {
eventQuery( eventData.Id ); eventQuery(eventData.Id);
} }
} }
function actQuery(action, parms) { function actQuery(action, parms) {
var data = {}; var data = {};
if ( parms ) data = parms; if (parms) data = parms;
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.id = eventData.Id; data.id = eventData.Id;
data.action = action; data.action = action;
@ -740,7 +749,7 @@ function drawProgressBar() {
// Shows current stream progress. // Shows current stream progress.
function updateProgressBar() { function updateProgressBar() {
if ( ! ( eventData && streamStatus ) ) { if (!(eventData && streamStatus)) {
return; return;
} // end if ! eventData && streamStatus } // end if ! eventData && streamStatus
var curWidth = (streamStatus.progress / parseFloat(eventData.Length)) * 100; var curWidth = (streamStatus.progress / parseFloat(eventData.Length)) * 100;
@ -756,10 +765,10 @@ function progressBarNav() {
}); });
} }
function handleClick( event ) { function handleClick(event) {
var target = event.target; var target = event.target;
var rect = target.getBoundingClientRect(); var rect = target.getBoundingClientRect();
if ( vid ) { if (vid) {
if (target.id != 'videoobj') return; // ignore clicks on control bar if (target.id != 'videoobj') return; // ignore clicks on control bar
var x = event.offsetX; var x = event.offsetX;
var y = event.offsetY; var y = event.offsetY;
@ -768,9 +777,9 @@ function handleClick( event ) {
var y = event.page.y - rect.top; var y = event.page.y - rect.top;
} }
if ( event.shift || event.shiftKey ) { // handle both jquery and mootools if (event.shift || event.shiftKey) { // handle both jquery and mootools
streamPan(x, y); streamPan(x, y);
} else if ( vid && event.ctrlKey ) { // allow zoom out by control click. useful in fullscreen } else if (vid && event.ctrlKey) { // allow zoom out by control click. useful in fullscreen
vjsPanZoom('zoomOut', x, y); vjsPanZoom('zoomOut', x, y);
} else { } else {
streamZoomIn(x, y); streamZoomIn(x, y);
@ -803,7 +812,7 @@ function getEvtStatsCookie() {
var cookie = 'zmEventStats'; var cookie = 'zmEventStats';
var stats = getCookie(cookie); var stats = getCookie(cookie);
if ( !stats ) { if (!stats) {
stats = 'on'; stats = 'on';
setCookie(cookie, stats, 10*365); setCookie(cookie, stats, 10*365);
} }
@ -845,7 +854,7 @@ function onStatsResize(vidWidth) {
var minWidth = 300; // An arbitrary value in pixels used to hide the stats table var minWidth = 300; // An arbitrary value in pixels used to hide the stats table
var scale = $j('#scale').val(); var scale = $j('#scale').val();
if ( parseInt(scale) ) { if (parseInt(scale)) {
vidWidth = vidWidth * (scale/100); vidWidth = vidWidth * (scale/100);
} }
@ -853,14 +862,14 @@ function onStatsResize(vidWidth) {
//console.log("Width: " + width + " = window.width " + $j(window).width() + "- vidWidth" + vidWidth); //console.log("Width: " + width + " = window.width " + $j(window).width() + "- vidWidth" + vidWidth);
// Hide the stats table if we have run out of room to show it properly // Hide the stats table if we have run out of room to show it properly
if ( width < minWidth ) { if (width < minWidth) {
statsBtn.prop('disabled', true); statsBtn.prop('disabled', true);
if ( table.is(':visible') ) { if (table.is(':visible')) {
table.toggle(false); table.toggle(false);
wasHidden = true; wasHidden = true;
} }
// Show the stats table if we hid it previously and sufficient room becomes available // Show the stats table if we hid it previously and sufficient room becomes available
} else if ( width >= minWidth ) { } else if (width >= minWidth) {
statsBtn.prop('disabled', false); statsBtn.prop('disabled', false);
if ( !table.is(':visible') && wasHidden ) { if ( !table.is(':visible') && wasHidden ) {
table.toggle(true); table.toggle(true);
@ -873,14 +882,14 @@ function initPage() {
// Load the event stats // Load the event stats
getStat(); getStat();
if ( getEvtStatsCookie() != 'on' ) { if (getEvtStatsCookie() != 'on') {
table.toggle(false); table.toggle(false);
} else { } else {
onStatsResize(eventData.Width); onStatsResize(eventData.Width);
} }
//FIXME prevent blocking...not sure what is happening or best way to unblock //FIXME prevent blocking...not sure what is happening or best way to unblock
if ( $j('#videoobj').length ) { if ($j('#videoobj').length) {
vid = videojs('videoobj'); vid = videojs('videoobj');
addVideoTimingTrack(vid, LabelFormat, eventData.MonitorName, eventData.Length, eventData.StartDateTime); addVideoTimingTrack(vid, LabelFormat, eventData.MonitorName, eventData.Length, eventData.StartDateTime);
$j('.vjs-progress-control').append('<div class="alarmCue"></div>');//add a place for videojs only on first load $j('.vjs-progress-control').append('<div class="alarmCue"></div>');//add a place for videojs only on first load
@ -894,26 +903,26 @@ function initPage() {
setCookie('volume', vid.volume(), 3600); setCookie('volume', vid.volume(), 3600);
}); });
var cookie = getCookie('volume'); var cookie = getCookie('volume');
if ( cookie ) vid.volume(cookie); if (cookie) vid.volume(cookie);
vid.on('timeupdate', function() { vid.on('timeupdate', function() {
$j('#progressValue').html(secsToTime(Math.floor(vid.currentTime()))); $j('#progressValue').html(secsToTime(Math.floor(vid.currentTime())));
}); });
// rate is in % so 100 would be 1x // rate is in % so 100 would be 1x
if ( rate > 0 ) { if (rate > 0) {
// rate should be 100 = 1x, etc. // rate should be 100 = 1x, etc.
vid.playbackRate(rate/100); vid.playbackRate(rate/100);
} }
} else { } else {
progressBarNav(); progressBarNav();
streamCmdTimer = setTimeout(streamQuery, 500); streamCmdTimer = setTimeout(streamQuery, 500);
if ( canStreamNative ) { if (canStreamNative) {
if ( !$j('#imageFeed') ) { if (!$j('#imageFeed')) {
console.log('No element with id tag imageFeed found.'); console.log('No element with id tag imageFeed found.');
} else { } else {
var streamImg = $j('#imageFeed img'); var streamImg = $j('#imageFeed img');
if ( !streamImg ) { if (!streamImg) {
streamImg = $j('#imageFeed object'); streamImg = $j('#imageFeed object');
} }
$j(streamImg).click(function(event) { $j(streamImg).click(function(event) {
@ -921,10 +930,10 @@ function initPage() {
}); });
} }
} }
} } // end if videojs or mjpeg stream
nearEventsQuery(eventData.Id); nearEventsQuery(eventData.Id);
initialAlarmCues(eventData.Id); //call ajax+renderAlarmCues initialAlarmCues(eventData.Id); //call ajax+renderAlarmCues
if ( scale == '0' || scale == 'auto' ) changeScale(); if (scale == '0' || scale == 'auto') changeScale();
document.querySelectorAll('select[name="rate"]').forEach(function(el) { document.querySelectorAll('select[name="rate"]').forEach(function(el) {
el.onchange = window['changeRate']; el.onchange = window['changeRate'];
}); });
@ -995,7 +1004,7 @@ function initPage() {
// Manage the EDIT button // Manage the EDIT button
bindButton('#editBtn', 'click', null, function onEditClick(evt) { bindButton('#editBtn', 'click', null, function onEditClick(evt) {
if ( ! canEdit.Events ) { if (!canEdit.Events) {
enoperm(); enoperm();
return; return;
} }
@ -1039,7 +1048,7 @@ function initPage() {
var cookie = 'zmEventStats'; var cookie = 'zmEventStats';
// Toggle the visiblity of the stats table and write an appropriate cookie // Toggle the visiblity of the stats table and write an appropriate cookie
if ( table.is(':visible') ) { if (table.is(':visible')) {
setCookie(cookie, 'off', 10*365); setCookie(cookie, 'off', 10*365);
table.toggle(false); table.toggle(false);
} else { } else {
@ -1056,13 +1065,13 @@ function initPage() {
// Manage the DELETE button // Manage the DELETE button
bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) { bindButton('#deleteBtn', 'click', null, function onDeleteClick(evt) {
if ( !canEdit.Events ) { if (!canEdit.Events) {
enoperm(); enoperm();
return; return;
} }
evt.preventDefault(); evt.preventDefault();
if ( ! $j('#deleteConfirm').length ) { if (!$j('#deleteConfirm').length) {
// Load the delete confirmation modal into the DOM // Load the delete confirmation modal into the DOM
$j.getJSON(thisUrl + '?request=modal&modal=delconfirm') $j.getJSON(thisUrl + '?request=modal&modal=delconfirm')
.done(function(data) { .done(function(data) {