spacing remove dead code

This commit is contained in:
Isaac Connor 2021-08-18 18:40:25 -04:00
parent 8ddec91870
commit 44823e0c94
1 changed files with 120 additions and 120 deletions

View File

@ -102,7 +102,7 @@ function changeScale() {
// Always turn it off, we will re-add it below. I don't know if you can add a callback multiple // Always turn it off, we will re-add it below. I don't know if you can add a callback multiple
// times and what the consequences would be // times and what the consequences would be
$j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active $j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active
if ( scale == '0' || scale == 'auto' ) { if (scale == '0' || scale == 'auto') {
var newSize = scaleToFit(monitorWidth, monitorHeight, $j('#liveStream'+monitorId), $j('#replayStatus')); var newSize = scaleToFit(monitorWidth, monitorHeight, $j('#liveStream'+monitorId), $j('#replayStatus'));
newWidth = newSize.width; newWidth = newSize.width;
newHeight = newSize.height; newHeight = newSize.height;
@ -150,25 +150,25 @@ function setAlarmState(currentAlarmState) {
var newAlarm = ( isAlarmed && !wasAlarmed ); var newAlarm = ( isAlarmed && !wasAlarmed );
var oldAlarm = ( !isAlarmed && wasAlarmed ); var oldAlarm = ( !isAlarmed && wasAlarmed );
if ( newAlarm ) { if (newAlarm) {
table.bootstrapTable('refresh'); table.bootstrapTable('refresh');
if ( SOUND_ON_ALARM ) { if (SOUND_ON_ALARM) {
// Enable the alarm sound // Enable the alarm sound
if ( !msieVer ) { if (!msieVer) {
$j('#alarmSound').removeClass('hidden'); $j('#alarmSound').removeClass('hidden');
} else { } else {
$j('#MediaPlayer').trigger('play'); $j('#MediaPlayer').trigger('play');
} }
} }
if ( POPUP_ON_ALARM ) { if (POPUP_ON_ALARM) {
window.focus(); window.focus();
} }
} }
if ( oldAlarm ) { // done with an event do a refresh if (oldAlarm) { // done with an event do a refresh
table.bootstrapTable('refresh'); table.bootstrapTable('refresh');
if ( SOUND_ON_ALARM ) { if (SOUND_ON_ALARM) {
// Disable alarm sound // Disable alarm sound
if ( !msieVer ) { if (!msieVer) {
$j('#alarmSound').addClass('hidden'); $j('#alarmSound').addClass('hidden');
} else { } else {
$j('#MediaPlayer').trigger('pause'); $j('#MediaPlayer').trigger('pause');
@ -188,12 +188,12 @@ function getStreamCmdError(text, error) {
function getStreamCmdResponse(respObj, respText) { function getStreamCmdResponse(respObj, respText) {
watchdogOk('stream'); watchdogOk('stream');
if ( streamCmdTimer ) { if (streamCmdTimer) {
streamCmdTimer = clearTimeout(streamCmdTimer); streamCmdTimer = clearTimeout(streamCmdTimer);
} }
if ( respObj.result == 'Ok' ) { if (respObj.result == 'Ok') {
// The get status command can get backed up, in which case we won't be able to get the semaphore and will exit. // The get status command can get backed up, in which case we won't be able to get the semaphore and will exit.
if ( respObj.status ) { if (respObj.status) {
streamStatus = respObj.status; streamStatus = respObj.status;
$j('#fpsValue').text(streamStatus.fps); $j('#fpsValue').text(streamStatus.fps);
$j('#capturefpsValue').text(streamStatus.capturefps); $j('#capturefpsValue').text(streamStatus.capturefps);
@ -203,9 +203,9 @@ function getStreamCmdResponse(respObj, respText) {
$j('#levelValue').text(streamStatus.level); $j('#levelValue').text(streamStatus.level);
var newClass = 'ok'; var newClass = 'ok';
if ( streamStatus.level > 95 ) { if (streamStatus.level > 95) {
newClass = 'alarm'; newClass = 'alarm';
} else if ( streamStatus.level > 80 ) { } else if (streamStatus.level > 80) {
newClass = 'alert'; newClass = 'alert';
} }
$j('#levelValue').removeClass(); $j('#levelValue').removeClass();
@ -213,30 +213,30 @@ function getStreamCmdResponse(respObj, respText) {
var delayString = secsToTime(streamStatus.delay); var delayString = secsToTime(streamStatus.delay);
if ( streamStatus.paused == true ) { if (streamStatus.paused == true) {
$j('#modeValue').text('Paused'); $j('#modeValue').text('Paused');
$j('#rate').addClass('hidden'); $j('#rate').addClass('hidden');
$j('#delayValue').text(delayString); $j('#delayValue').text(delayString);
$j('#delay').removeClass('hidden'); $j('#delay').removeClass('hidden');
$j('#level').removeClass('hidden'); $j('#level').removeClass('hidden');
streamCmdPause(false); streamCmdPause(false);
} else if ( streamStatus.delayed == true ) { } else if (streamStatus.delayed == true) {
$j('#modeValue').text('Replay'); $j('#modeValue').text('Replay');
$j('#rateValue').text(streamStatus.rate); $j('#rateValue').text(streamStatus.rate);
$j('#rate').removeClass('hidden'); $j('#rate').removeClass('hidden');
$j('#delayValue').text(delayString); $j('#delayValue').text(delayString);
$j('#delay').removeClass('hidden'); $j('#delay').removeClass('hidden');
$j('#level').removeClass('hidden'); $j('#level').removeClass('hidden');
if ( streamStatus.rate == 1 ) { if (streamStatus.rate == 1) {
streamCmdPlay(false); streamCmdPlay(false);
} else if ( streamStatus.rate > 0 ) { } else if (streamStatus.rate > 0) {
if ( streamStatus.rate < 1 ) { if (streamStatus.rate < 1) {
streamCmdSlowFwd(false); streamCmdSlowFwd(false);
} else { } else {
streamCmdFastFwd(false); streamCmdFastFwd(false);
} }
} else { } else {
if ( streamStatus.rate > -1 ) { if (streamStatus.rate > -1) {
streamCmdSlowRev(false); streamCmdSlowRev(false);
} else { } else {
streamCmdFastRev(false); streamCmdFastRev(false);
@ -251,17 +251,17 @@ function getStreamCmdResponse(respObj, respText) {
} // end if paused or delayed } // end if paused or delayed
$j('#zoomValue').text(streamStatus.zoom); $j('#zoomValue').text(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');
} }
if ( canEdit.Monitors ) { if (canEdit.Monitors) {
if ( streamStatus.enabled ) { if (streamStatus.enabled) {
enableAlmBtn.addClass('disabled'); enableAlmBtn.addClass('disabled');
enableAlmBtn.prop('title', disableAlarmsStr); enableAlmBtn.prop('title', disableAlarmsStr);
if ( streamStatus.forced ) { if (streamStatus.forced) {
forceAlmBtn.addClass('disabled'); forceAlmBtn.addClass('disabled');
forceAlmBtn.prop('title', cancelForcedAlarmStr); forceAlmBtn.prop('title', cancelForcedAlarmStr);
} else { } else {
@ -277,16 +277,18 @@ function getStreamCmdResponse(respObj, respText) {
enableAlmBtn.prop('disabled', false); enableAlmBtn.prop('disabled', false);
} // end if canEdit.Monitors } // end if canEdit.Monitors
if ( streamStatus.auth ) { if (streamStatus.auth) {
auth_hash = streamStatus.auth; auth_hash = streamStatus.auth;
// Try to reload the image stream. // Try to reload the image stream.
var streamImg = $j('#liveStream'+monitorId); var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) { if (streamImg) {
var oldSrc = streamImg.attr('src'); var oldSrc = streamImg.attr('src');
var newSrc = oldSrc.replace(/auth=\w+/i, 'auth='+streamStatus.auth); var newSrc = oldSrc.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
if (oldSrc != newSrc) {
streamImg.attr('src', newSrc); streamImg.attr('src', newSrc);
}
table.bootstrapTable('refresh'); table.bootstrapTable('refresh');
}
}
} // end if have a new auth hash } // end if have a new auth hash
} // end if respObj.status } // end if respObj.status
} else { } else {
@ -295,9 +297,8 @@ function getStreamCmdResponse(respObj, respText) {
// If it's an auth error, we should reload the whole page. // If it's an auth error, we should reload the whole page.
console.log("have error"); console.log("have error");
//window.location.reload(); //window.location.reload();
if ( 1 ) {
var streamImg = $j('#liveStream'+monitorId); var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) { if (streamImg) {
var oldSrc = streamImg.attr('src'); var oldSrc = streamImg.attr('src');
var newSrc = oldSrc.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) )); var newSrc = oldSrc.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
@ -307,10 +308,9 @@ function getStreamCmdResponse(respObj, respText) {
console.log('Unable to find streamImg liveStream'); console.log('Unable to find streamImg liveStream');
} }
} }
}
var streamCmdTimeout = statusRefreshTimeout; var streamCmdTimeout = statusRefreshTimeout;
if ( alarmState == STATE_ALARM || alarmState == STATE_ALERT ) { if (alarmState == STATE_ALARM || alarmState == STATE_ALERT) {
streamCmdTimeout = streamCmdTimeout/5; streamCmdTimeout = streamCmdTimeout/5;
} }
streamCmdTimer = setTimeout(streamCmdQuery, streamCmdTimeout); streamCmdTimer = setTimeout(streamCmdQuery, streamCmdTimeout);
@ -320,15 +320,15 @@ function streamCmdPause(action) {
setButtonState('pauseBtn', 'active'); setButtonState('pauseBtn', 'active');
setButtonState('playBtn', 'inactive'); setButtonState('playBtn', 'inactive');
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
setButtonState('fastRevBtn', 'inactive'); setButtonState('fastRevBtn', 'inactive');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_PAUSE; data.command = CMD_PAUSE;
streamCmdReq(data); streamCmdReq(data);
} }
@ -337,9 +337,9 @@ function streamCmdPause(action) {
function streamCmdPlay(action) { function streamCmdPlay(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'active'); setButtonState('playBtn', 'active');
if ( streamStatus.delayed == true ) { if (streamStatus.delayed == true) {
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
@ -347,16 +347,16 @@ function streamCmdPlay(action) {
} }
} else { } else {
setButtonState('stopBtn', 'unavail'); setButtonState('stopBtn', 'unavail');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'unavail'); setButtonState('fastFwdBtn', 'unavail');
setButtonState('slowFwdBtn', 'unavail'); setButtonState('slowFwdBtn', 'unavail');
setButtonState('slowRevBtn', 'unavail'); setButtonState('slowRevBtn', 'unavail');
setButtonState('fastRevBtn', 'unavail'); setButtonState('fastRevBtn', 'unavail');
} }
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_PLAY; data.command = CMD_PLAY;
streamCmdReq(data); streamCmdReq(data);
} }
@ -374,15 +374,15 @@ function streamCmdStop(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'unavail'); setButtonState('playBtn', 'unavail');
setButtonState('stopBtn', 'active'); setButtonState('stopBtn', 'active');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'unavail'); setButtonState('fastFwdBtn', 'unavail');
setButtonState('slowFwdBtn', 'unavail'); setButtonState('slowFwdBtn', 'unavail');
setButtonState('slowRevBtn', 'unavail'); setButtonState('slowRevBtn', 'unavail');
setButtonState('fastRevBtn', 'unavail'); setButtonState('fastRevBtn', 'unavail');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_STOP; data.command = CMD_STOP;
streamCmdReq(data); streamCmdReq(data);
} }
@ -394,15 +394,15 @@ function streamCmdFastFwd(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'inactive'); setButtonState('playBtn', 'inactive');
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
setButtonState('fastRevBtn', 'inactive'); setButtonState('fastRevBtn', 'inactive');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_FASTFWD; data.command = CMD_FASTFWD;
streamCmdReq(data); streamCmdReq(data);
} }
@ -412,20 +412,20 @@ function streamCmdSlowFwd(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'inactive'); setButtonState('playBtn', 'inactive');
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'active'); setButtonState('slowFwdBtn', 'active');
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
setButtonState('fastRevBtn', 'inactive'); setButtonState('fastRevBtn', 'inactive');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_SLOWFWD; data.command = CMD_SLOWFWD;
streamCmdReq(data); streamCmdReq(data);
} }
setButtonState('pauseBtn', 'active'); setButtonState('pauseBtn', 'active');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
} }
} }
@ -434,20 +434,20 @@ function streamCmdSlowRev(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'inactive'); setButtonState('playBtn', 'inactive');
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
setButtonState('slowRevBtn', 'active'); setButtonState('slowRevBtn', 'active');
setButtonState('fastRevBtn', 'inactive'); setButtonState('fastRevBtn', 'inactive');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_SLOWREV; data.command = CMD_SLOWREV;
streamCmdReq(data); streamCmdReq(data);
} }
setButtonState('pauseBtn', 'active'); setButtonState('pauseBtn', 'active');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
} }
} }
@ -456,23 +456,23 @@ function streamCmdFastRev(action) {
setButtonState('pauseBtn', 'inactive'); setButtonState('pauseBtn', 'inactive');
setButtonState('playBtn', 'inactive'); setButtonState('playBtn', 'inactive');
setButtonState('stopBtn', 'inactive'); setButtonState('stopBtn', 'inactive');
if ( monitorStreamReplayBuffer ) { if (monitorStreamReplayBuffer) {
setButtonState('fastFwdBtn', 'inactive'); setButtonState('fastFwdBtn', 'inactive');
setButtonState('slowFwdBtn', 'inactive'); setButtonState('slowFwdBtn', 'inactive');
setButtonState('slowRevBtn', 'inactive'); setButtonState('slowRevBtn', 'inactive');
setButtonState('fastRevBtn', 'inactive'); setButtonState('fastRevBtn', 'inactive');
} }
if ( action ) { if (action) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_FASTREV; data.command = CMD_FASTREV;
streamCmdReq(data); streamCmdReq(data);
} }
} }
function streamCmdZoomIn( x, y ) { function streamCmdZoomIn(x, y) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.x = x; data.x = x;
data.y = y; data.y = y;
data.command = CMD_ZOOMIN; data.command = CMD_ZOOMIN;
@ -481,22 +481,22 @@ function streamCmdZoomIn( x, y ) {
function streamCmdZoomOut() { function streamCmdZoomOut() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_ZOOMOUT; data.command = CMD_ZOOMOUT;
streamCmdReq(data); streamCmdReq(data);
} }
function streamCmdScale( scale ) { function streamCmdScale(scale) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_SCALE; data.command = CMD_SCALE;
data.scale = scale; data.scale = scale;
streamCmdReq(data); streamCmdReq(data);
} }
function streamCmdPan( x, y ) { function streamCmdPan(x, y) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.x = x; data.x = x;
data.y = y; data.y = y;
data.command = CMD_PAN; data.command = CMD_PAN;
@ -505,18 +505,18 @@ function streamCmdPan( x, y ) {
function streamCmdQuery() { function streamCmdQuery() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = CMD_QUERY; data.command = CMD_QUERY;
streamCmdReq(data); streamCmdReq(data);
} }
function getStatusCmdResponse(respObj, respText) { function getStatusCmdResponse(respObj, respText) {
watchdogOk('status'); watchdogOk('status');
if ( statusCmdTimer ) { if (statusCmdTimer) {
statusCmdTimer = clearTimeout(statusCmdTimer); statusCmdTimer = clearTimeout(statusCmdTimer);
} }
if ( respObj.result == 'Ok' ) { if (respObj.result == 'Ok') {
$j('#fpsValue').text(respObj.monitor.FrameRate); $j('#fpsValue').text(respObj.monitor.FrameRate);
setAlarmState(respObj.monitor.Status); setAlarmState(respObj.monitor.Status);
} else { } else {
@ -556,20 +556,20 @@ function getAlarmCmdResponse(respObj, respText) {
function cmdDisableAlarms() { function cmdDisableAlarms() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = 'disableAlarms'; data.command = 'disableAlarms';
alarmCmdReq(data); alarmCmdReq(data);
} }
function cmdEnableAlarms() { function cmdEnableAlarms() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = 'enableAlarms'; data.command = 'enableAlarms';
alarmCmdReq(data); alarmCmdReq(data);
} }
function cmdAlarm() { function cmdAlarm() {
if ( enableAlmBtn.hasClass('disabled') ) { if (enableAlmBtn.hasClass('disabled')) {
cmdEnableAlarms(); cmdEnableAlarms();
} else { } else {
cmdDisableAlarms(); cmdDisableAlarms();
@ -578,23 +578,23 @@ function cmdAlarm() {
function cmdForceAlarm() { function cmdForceAlarm() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = 'forceAlarm'; data.command = 'forceAlarm';
alarmCmdReq(data); alarmCmdReq(data);
if ( window.event ) window.event.preventDefault(); if (window.event) window.event.preventDefault();
} }
function cmdCancelForcedAlarm() { function cmdCancelForcedAlarm() {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.command = 'cancelForcedAlarm'; data.command = 'cancelForcedAlarm';
alarmCmdReq(data); alarmCmdReq(data);
if ( window.event ) window.event.preventDefault(); if (window.event) window.event.preventDefault();
return false; return false;
} }
function cmdForce() { function cmdForce() {
if ( forceAlmBtn.hasClass('disabled') ) { if (forceAlmBtn.hasClass('disabled')) {
cmdCancelForcedAlarm(); cmdCancelForcedAlarm();
} else { } else {
cmdForceAlarm(); cmdForceAlarm();
@ -608,11 +608,11 @@ function controlReq(data) {
} }
function getControlResponse(respObj, respText) { function getControlResponse(respObj, respText) {
if ( !respObj ) { if (!respObj) {
return; return;
} }
//console.log( respText ); //console.log( respText );
if ( respObj.result != 'Ok' ) { if (respObj.result != 'Ok') {
alert("Control response was status = "+respObj.status+"\nmessage = "+respObj.message); alert("Control response was status = "+respObj.status+"\nmessage = "+respObj.message);
} }
} }
@ -633,7 +633,7 @@ function controlCmd(event) {
var data = {}; var data = {};
if ( event && (xtell || ytell) ) { if (event && (xtell || ytell)) {
var target = event.target; var target = event.target;
var offset = $j(target).offset(); var offset = $j(target).offset();
var width = $j(target).width(); var width = $j(target).width();
@ -642,45 +642,45 @@ function controlCmd(event) {
var x = event.pageX - offset.left; var x = event.pageX - offset.left;
var y = event.pageY - offset.top; var y = event.pageY - offset.top;
if ( xtell ) { if (xtell) {
var xge = parseInt((x*100)/width); var xge = parseInt((x*100)/width);
if ( xtell == -1 ) { if (xtell == -1) {
xge = 100 - xge; xge = 100 - xge;
} else if ( xtell == 2 ) { } else if (xtell == 2) {
xge = 2*(50 - xge); xge = 2*(50 - xge);
} }
data.xge = xge; data.xge = xge;
} }
if ( ytell ) { if (ytell) {
var yge = parseInt((y*100)/height); var yge = parseInt((y*100)/height);
if ( ytell == -1 ) { if (ytell == -1) {
yge = 100 - yge; yge = 100 - yge;
} else if ( ytell == 2 ) { } else if (ytell == 2) {
yge = 2*(50 - yge); yge = 2*(50 - yge);
} }
data.yge = yge; data.yge = yge;
} }
} }
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.control = control; data.control = control;
controlReq(data); controlReq(data);
if ( streamMode == 'single' ) { if (streamMode == 'single') {
setTimeout(fetchImage, 1000, $j('#imageFeed img')); setTimeout(fetchImage, 1000, $j('#imageFeed img'));
} }
} }
function controlCmdImage( x, y ) { function controlCmdImage(x, y) {
var data = {}; var data = {};
if ( auth_hash ) data.auth = auth_hash; if (auth_hash) data.auth = auth_hash;
data.scale = scale; data.scale = scale;
data.control = imageControlMode; data.control = imageControlMode;
data.x = x; data.x = x;
data.y = y; data.y = y;
controlReq(data); controlReq(data);
if ( streamMode == 'single' ) { if (streamMode == 'single') {
setTimeout(fetchImage, 1000, $j('#imageFeed img')); setTimeout(fetchImage, 1000, $j('#imageFeed img'));
} }
} }
@ -701,10 +701,10 @@ function handleClick(event) {
var x = parseInt((event.pageX - pos.left) * scaleX); var x = parseInt((event.pageX - pos.left) * scaleX);
var y = parseInt((event.pageY - pos.top) * scaleY); var y = parseInt((event.pageY - pos.top) * scaleY);
if ( showMode == 'events' || !imageControlMode ) { if (showMode == 'events' || !imageControlMode) {
if ( event.shift ) { if ( event.shift ) {
streamCmdPan(x, y); streamCmdPan(x, y);
} else if ( event.ctrlKey ) { } else if (event.ctrlKey) {
streamCmdZoomOut(); streamCmdZoomOut();
} else { } else {
streamCmdZoomIn(x, y); streamCmdZoomIn(x, y);
@ -715,16 +715,16 @@ function handleClick(event) {
} }
function appletRefresh() { function appletRefresh() {
if ( streamStatus && (!streamStatus.paused && !streamStatus.delayed) ) { if (streamStatus && (!streamStatus.paused && !streamStatus.delayed)) {
var streamImg = $j('#liveStream'+monitorId); var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) { if (streamImg) {
var parent = streamImg.parent(); var parent = streamImg.parent();
streamImg.remove(); streamImg.remove();
streamImg.append(parent); streamImg.append(parent);
} else { } else {
console.error("Nothing found for liveStream"+monitorId); console.error("Nothing found for liveStream"+monitorId);
} }
if ( appletRefreshTime ) { if (appletRefreshTime) {
setTimeout(appletRefresh, appletRefreshTime*1000); setTimeout(appletRefresh, appletRefreshTime*1000);
} }
} else { } else {
@ -743,8 +743,8 @@ var watchdogFunctions = {
}; };
//Make sure the various refreshes are still taking effect //Make sure the various refreshes are still taking effect
function watchdogCheck( type ) { function watchdogCheck(type) {
if ( watchdogInactive[type] ) { if (watchdogInactive[type]) {
console.log("Detected streamWatch of type: " + type + " stopped, restarting"); console.log("Detected streamWatch of type: " + type + " stopped, restarting");
watchdogFunctions[type](); watchdogFunctions[type]();
watchdogInactive[type] = false; watchdogInactive[type] = false;
@ -753,7 +753,7 @@ function watchdogCheck( type ) {
} }
} }
function watchdogOk( type ) { function watchdogOk(type) {
watchdogInactive[type] = false; watchdogInactive[type] = false;
} }
@ -797,7 +797,7 @@ function getSettingsModal() {
} }
function processClicks(event, field, value, row, $element) { function processClicks(event, field, value, row, $element) {
if ( field == 'Delete' ) { if (field == 'Delete') {
$j.getJSON(monitorUrl + '?request=modal&modal=delconfirm') $j.getJSON(monitorUrl + '?request=modal&modal=delconfirm')
.done(function(data) { .done(function(data) {
insertModalHtml('deleteConfirm', data.html); insertModalHtml('deleteConfirm', data.html);
@ -812,7 +812,7 @@ function processClicks(event, field, value, row, $element) {
// Manage the DELETE CONFIRMATION modal button // Manage the DELETE CONFIRMATION modal button
function manageDelConfirmModalBtns() { function manageDelConfirmModalBtns() {
document.getElementById("delConfirmBtn").addEventListener("click", function onDelConfirmClick(evt) { document.getElementById("delConfirmBtn").addEventListener("click", function onDelConfirmClick(evt) {
if ( ! canEdit.Events ) { if (!canEdit.Events) {
enoperm(); enoperm();
return; return;
} }
@ -821,7 +821,7 @@ function manageDelConfirmModalBtns() {
evt.preventDefault(); evt.preventDefault();
$j.getJSON(thisUrl + '?request=events&task=delete&eids[]='+eid) $j.getJSON(thisUrl + '?request=events&task=delete&eids[]='+eid)
.done( function(data) { .done(function(data) {
table.bootstrapTable('refresh'); table.bootstrapTable('refresh');
$j('#deleteConfirm').modal('hide'); $j('#deleteConfirm').modal('hide');
}) })
@ -838,7 +838,7 @@ function msieVer() {
var ua = window.navigator.userAgent; var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE "); var msie = ua.indexOf("MSIE ");
if ( msie >= 0 ) { // If Internet Explorer, return version number if (msie >= 0) { // If Internet Explorer, return version number
return msie; return msie;
} else { // If another browser, return 0 } else { // If another browser, return 0
return 0; return 0;
@ -846,15 +846,15 @@ function msieVer() {
} }
function initPage() { function initPage() {
if ( canView.Control ) { if (canView.Control) {
// Load the PTZ Preset modal into the DOM // Load the PTZ Preset modal into the DOM
if ( monitorControllable ) getCtrlPresetModal(); if (monitorControllable) getCtrlPresetModal();
// Load the settings modal into the DOM // Load the settings modal into the DOM
if ( monitorType == "Local" ) getSettingsModal(); if (monitorType == "Local") getSettingsModal();
} }
if ( monitorType != 'WebSite' ) { if (monitorType != 'WebSite') {
if ( streamMode == 'single' ) { if (streamMode == 'single') {
statusCmdTimer = setTimeout(statusCmdQuery, (Math.random()+0.1)*statusRefreshTimeout ); statusCmdTimer = setTimeout(statusCmdQuery, (Math.random()+0.1)*statusRefreshTimeout );
setInterval(watchdogCheck, statusRefreshTimeout*2, 'status'); setInterval(watchdogCheck, statusRefreshTimeout*2, 'status');
} else { } else {
@ -862,15 +862,15 @@ function initPage() {
setInterval(watchdogCheck, statusRefreshTimeout*2, 'stream'); setInterval(watchdogCheck, statusRefreshTimeout*2, 'stream');
} }
if ( canStreamNative || (streamMode == 'single') ) { if (canStreamNative || (streamMode == 'single')) {
var streamImg = $j('#imageFeed img'); var streamImg = $j('#imageFeed img');
if ( !streamImg ) { if (!streamImg) {
streamImg = $j('#imageFeed object'); streamImg = $j('#imageFeed object');
} }
if ( !streamImg ) { if (!streamImg) {
console.error('No streamImg found for imageFeed'); console.error('No streamImg found for imageFeed');
} else { } else {
if ( streamMode == 'single' ) { if (streamMode == 'single') {
streamImg.click(streamImg, fetchImage); streamImg.click(streamImg, fetchImage);
setInterval(fetchImage, imageRefreshTimeout, $j('#imageFeed img')); setInterval(fetchImage, imageRefreshTimeout, $j('#imageFeed img'));
} else { } else {
@ -881,17 +881,17 @@ function initPage() {
} // end if have streamImg } // end if have streamImg
} // streamMode native or single } // streamMode native or single
if ( refreshApplet && appletRefreshTime ) { if (refreshApplet && appletRefreshTime) {
setTimeout(appletRefresh, appletRefreshTime*1000); setTimeout(appletRefresh, appletRefreshTime*1000);
} }
if ( window.history.length == 1 ) { if (window.history.length == 1) {
$j('#closeControl').html(''); $j('#closeControl').html('');
} }
document.querySelectorAll('select[name="scale"]').forEach(function(el) { document.querySelectorAll('select[name="scale"]').forEach(function(el) {
el.onchange = window['changeScale']; el.onchange = window['changeScale'];
}); });
changeScale(); changeScale();
} else if ( monitorRefresh > 0 ) { } else if (monitorRefresh > 0) {
setInterval(reloadWebSite, monitorRefresh*1000); setInterval(reloadWebSite, monitorRefresh*1000);
} }
@ -920,7 +920,7 @@ function initPage() {
settingsBtn.prop('disabled', !(canView.Control && monitorType == 'Local')); settingsBtn.prop('disabled', !(canView.Control && monitorType == 'Local'));
// Init the bootstrap-table // Init the bootstrap-table
if ( monitorType != 'WebSite' ) table.bootstrapTable({icons: icons}); if (monitorType != 'WebSite') table.bootstrapTable({icons: icons});
// Update table rows each time after new data is loaded // Update table rows each time after new data is loaded
table.on('post-body.bs.table', function(data) { table.on('post-body.bs.table', function(data) {