2020-12-10 07:58:46 +08:00
|
|
|
var streamCmdTimer = null;
|
2020-11-27 07:00:05 +08:00
|
|
|
var streamStatus;
|
|
|
|
var alarmState = STATE_IDLE;
|
|
|
|
var lastAlarmState = STATE_IDLE;
|
2020-10-16 21:08:23 +08:00
|
|
|
var backBtn = $j('#backBtn');
|
|
|
|
var settingsBtn = $j('#settingsBtn');
|
2020-10-17 04:47:42 +08:00
|
|
|
var enableAlmBtn = $j('#enableAlmBtn');
|
|
|
|
var forceAlmBtn = $j('#forceAlmBtn');
|
2020-11-27 07:00:05 +08:00
|
|
|
var table = $j('#eventList');
|
2020-12-03 21:53:09 +08:00
|
|
|
var filterQuery = '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId;
|
2020-11-27 07:00:05 +08:00
|
|
|
|
2022-01-12 11:19:58 +08:00
|
|
|
var server;
|
|
|
|
var janus = null;
|
|
|
|
var opaqueId;
|
|
|
|
var streaming2;
|
2020-11-27 07:00:05 +08:00
|
|
|
/*
|
|
|
|
This is the format of the json object sent by bootstrap-table
|
|
|
|
|
|
|
|
var params =
|
|
|
|
{
|
|
|
|
"type":"get",
|
|
|
|
"data":
|
|
|
|
{
|
|
|
|
"search":"some search text",
|
|
|
|
"sort":"StartDateTime",
|
|
|
|
"order":"asc",
|
|
|
|
"offset":0,
|
|
|
|
"limit":25
|
|
|
|
"filter":
|
|
|
|
{
|
|
|
|
"Name":"some advanced search text"
|
|
|
|
"StartDateTime":"some more advanced search text"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"cache":true,
|
|
|
|
"contentType":"application/json",
|
|
|
|
"dataType":"json"
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Called by bootstrap-table to retrieve zm event data
|
|
|
|
function ajaxRequest(params) {
|
2020-12-03 09:44:12 +08:00
|
|
|
// Maintain legacy behavior by statically setting these parameters
|
2021-01-20 00:10:51 +08:00
|
|
|
var data = params.data;
|
|
|
|
data.order = 'desc';
|
|
|
|
data.limit = maxDisplayEvents;
|
|
|
|
data.sort = 'Id';
|
|
|
|
data.view = 'request';
|
|
|
|
data.request = 'watch';
|
|
|
|
data.mid = monitorId;
|
2021-12-11 04:34:35 +08:00
|
|
|
if (auth_hash) data.auth = auth_hash;
|
2020-12-03 09:44:12 +08:00
|
|
|
|
2021-01-20 00:10:51 +08:00
|
|
|
$j.getJSON(thisUrl, data)
|
2020-11-27 07:00:05 +08:00
|
|
|
.done(function(data) {
|
2020-12-03 09:44:12 +08:00
|
|
|
var rows = processRows(data.rows);
|
2021-01-20 00:10:51 +08:00
|
|
|
params.success(rows);
|
2020-11-27 07:00:05 +08:00
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
}
|
|
|
|
|
|
|
|
function processRows(rows) {
|
|
|
|
$j.each(rows, function(ndx, row) {
|
|
|
|
var eid = row.Id;
|
|
|
|
|
2020-12-03 09:44:12 +08:00
|
|
|
row.Delete = '<i class="fa fa-trash text-danger"></i>';
|
2020-11-27 07:00:05 +08:00
|
|
|
row.Id = '<a href="?view=event&eid=' + eid + filterQuery + '">' + eid + '</a>';
|
|
|
|
row.Name = '<a href="?view=event&eid=' + eid + filterQuery + '">' + row.Name + '</a>';
|
|
|
|
row.Frames = '<a href="?view=frames&eid=' + eid + '">' + row.Frames + '</a>';
|
|
|
|
row.AlarmFrames = '<a href="?view=frames&eid=' + eid + '">' + row.AlarmFrames + '</a>';
|
|
|
|
row.MaxScore = '<a href="?view=frame&eid=' + eid + '&fid=0">' + row.MaxScore + '</a>';
|
2020-12-03 09:44:12 +08:00
|
|
|
if ( LIST_THUMBS ) row.Thumbnail = '<a href="?view=event&eid=' + eid + filterQuery + '&page=1">' + row.imgHtml + '</a>';
|
2020-11-27 07:00:05 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return rows;
|
|
|
|
}
|
2009-05-08 18:04:12 +08:00
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function showEvents() {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#ptzControls').addClass('hidden');
|
|
|
|
$j('#events').removeClass('hidden');
|
2021-08-24 05:11:40 +08:00
|
|
|
if ($j('#eventsControl')) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#eventsControl').addClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-08-24 05:11:40 +08:00
|
|
|
if ($j('#controlControl')) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#controlControl').removeClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-03-05 00:17:48 +08:00
|
|
|
showMode = 'events';
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function showPtzControls() {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#events').addClass('hidden');
|
|
|
|
$j('#ptzControls').removeClass('hidden');
|
2021-08-24 05:11:40 +08:00
|
|
|
if ($j('#eventsControl')) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#eventsControl').removeClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-08-24 05:11:40 +08:00
|
|
|
if ($j('#controlControl')) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#controlControl').addClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-03-05 00:17:48 +08:00
|
|
|
showMode = 'control';
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
function changeSize() {
|
|
|
|
var width = $j('#width').val();
|
|
|
|
var height = $j('#height').val();
|
|
|
|
|
|
|
|
// Scale the frame
|
|
|
|
monitor_frame = $j('#imageFeed');
|
|
|
|
if (!monitor_frame) {
|
|
|
|
console.log('Error finding frame');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (width) monitor_frame.css('width', width);
|
|
|
|
if (height) monitor_frame.css('height', height);
|
|
|
|
|
|
|
|
var streamImg = document.getElementById('liveStream'+monitorData[monIdx].id);
|
|
|
|
if (streamImg) {
|
|
|
|
if (streamImg.nodeName == 'IMG') {
|
|
|
|
let src = streamImg.src;
|
|
|
|
streamImg.src = '';
|
|
|
|
src = src.replace(/width=[\.\d]+/i, 'width='+parseInt(width));
|
|
|
|
src = src.replace(/height=[\.\d]+/i, 'height='+parseInt(height));
|
|
|
|
src = src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
|
|
|
|
streamImg.src = src;
|
|
|
|
}
|
|
|
|
streamImg.style.width = width ? width : null;
|
|
|
|
streamImg.style.height = height ? height : null;
|
|
|
|
} else {
|
|
|
|
console.log('Did not find liveStream'+monitorData[monIdx].id);
|
|
|
|
}
|
|
|
|
$j('#scale').val('');
|
|
|
|
setCookie('zmCycleScale', '', 3600);
|
|
|
|
setCookie('zmCycleWidth', width, 3600);
|
|
|
|
setCookie('zmCycleHeight', height, 3600);
|
|
|
|
} // end function changeSize()
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function changeScale() {
|
2020-12-04 03:12:01 +08:00
|
|
|
var scale = $j('#scale').val();
|
2021-12-17 05:38:15 +08:00
|
|
|
setCookie('zmWatchScale'+monitorId, scale, 3600);
|
2021-12-11 04:34:35 +08:00
|
|
|
$j('#width').val('auto');
|
|
|
|
$j('#height').val('auto');
|
|
|
|
setCookie('zmCycleScale', scale, 3600);
|
|
|
|
setCookie('zmCycleWidth', 'auto', 3600);
|
|
|
|
setCookie('zmCycleHeight', 'auto', 3600);
|
|
|
|
|
2017-11-21 03:25:13 +08:00
|
|
|
var newWidth;
|
|
|
|
var newHeight;
|
2021-10-15 01:00:49 +08:00
|
|
|
var autoScale;
|
2021-01-12 02:38:04 +08:00
|
|
|
|
2021-12-17 05:38:15 +08:00
|
|
|
var streamImg = $j('#liveStream'+monitorId);
|
|
|
|
if (!streamImg.length) {
|
|
|
|
console.error('No element found for liveStream'+monitorId);
|
|
|
|
}
|
|
|
|
|
2021-01-27 06:44:23 +08:00
|
|
|
// Always turn it off, we will re-add it below. I don't know if you can add a callback multiple
|
2021-01-12 02:38:04 +08:00
|
|
|
// times and what the consequences would be
|
|
|
|
$j(window).off('resize', endOfResize); //remove resize handler when Scale to Fit is not active
|
2021-08-19 06:40:25 +08:00
|
|
|
if (scale == '0' || scale == 'auto') {
|
2021-12-17 05:38:15 +08:00
|
|
|
const newSize = scaleToFit(monitorWidth, monitorHeight, streamImg, $j('#dvrControls'));
|
2017-11-21 03:25:13 +08:00
|
|
|
newWidth = newSize.width;
|
|
|
|
newHeight = newSize.height;
|
|
|
|
autoScale = newSize.autoScale;
|
2021-01-12 02:38:04 +08:00
|
|
|
$j(window).on('resize', endOfResize); //remove resize handler when Scale to Fit is not active
|
2017-11-21 03:25:13 +08:00
|
|
|
} else {
|
|
|
|
newWidth = monitorWidth * scale / SCALE_BASE;
|
|
|
|
newHeight = monitorHeight * scale / SCALE_BASE;
|
|
|
|
}
|
|
|
|
|
2021-12-17 05:38:15 +08:00
|
|
|
if (streamImg.prop('nodeName') == 'IMG') {
|
|
|
|
const oldSrc = streamImg.attr('src');
|
|
|
|
streamImg.attr('src', '');
|
|
|
|
// This is so that we don't waste bandwidth and let the browser do all the scaling.
|
|
|
|
if (autoScale > 100) autoScale = 100;
|
|
|
|
if (scale > 100) scale = 100;
|
|
|
|
const newSrc = oldSrc.replace(/scale=\d+/i, 'scale='+((scale == 'auto' || scale == '0') ? autoScale : scale));
|
|
|
|
|
|
|
|
streamImg.css('width', newWidth+'px');
|
|
|
|
streamImg.width(newWidth);
|
|
|
|
streamImg.css('height', newHeight+'px');
|
|
|
|
streamImg.height(newHeight);
|
|
|
|
streamImg.attr('src', newSrc);
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2021-12-17 05:38:15 +08:00
|
|
|
console.log("Not an IMG, can't set size");
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2021-01-27 06:44:23 +08:00
|
|
|
} // end function changeScale
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function setAlarmState(currentAlarmState) {
|
2016-09-27 23:51:55 +08:00
|
|
|
alarmState = currentAlarmState;
|
|
|
|
|
2020-01-06 06:33:53 +08:00
|
|
|
var stateClass = '';
|
2021-08-24 05:11:40 +08:00
|
|
|
if (alarmState == STATE_ALARM) {
|
2020-01-06 06:33:53 +08:00
|
|
|
stateClass = 'alarm';
|
2021-08-24 05:11:40 +08:00
|
|
|
} else if (alarmState == STATE_ALERT) {
|
2020-01-06 06:33:53 +08:00
|
|
|
stateClass = 'alert';
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#stateValue').text(stateStrings[alarmState]);
|
2021-08-24 05:11:40 +08:00
|
|
|
if (stateClass) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#stateValue').addClass(stateClass);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#stateValue').removeClass();
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
|
|
|
|
var isAlarmed = ( alarmState == STATE_ALARM || alarmState == STATE_ALERT );
|
|
|
|
var wasAlarmed = ( lastAlarmState == STATE_ALARM || lastAlarmState == STATE_ALERT );
|
|
|
|
|
|
|
|
var newAlarm = ( isAlarmed && !wasAlarmed );
|
|
|
|
var oldAlarm = ( !isAlarmed && wasAlarmed );
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (newAlarm) {
|
2020-12-03 22:31:52 +08:00
|
|
|
table.bootstrapTable('refresh');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (SOUND_ON_ALARM) {
|
2016-09-27 23:51:55 +08:00
|
|
|
// Enable the alarm sound
|
2021-08-19 06:40:25 +08:00
|
|
|
if (!msieVer) {
|
2020-12-08 00:22:54 +08:00
|
|
|
$j('#alarmSound').removeClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2020-12-08 00:22:54 +08:00
|
|
|
$j('#MediaPlayer').trigger('play');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2008-07-16 23:47:33 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (POPUP_ON_ALARM) {
|
2016-09-27 23:51:55 +08:00
|
|
|
window.focus();
|
2008-07-16 23:47:33 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (oldAlarm) { // done with an event do a refresh
|
2020-12-03 22:31:52 +08:00
|
|
|
table.bootstrapTable('refresh');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (SOUND_ON_ALARM) {
|
2016-09-27 23:51:55 +08:00
|
|
|
// Disable alarm sound
|
2021-08-19 06:40:25 +08:00
|
|
|
if (!msieVer) {
|
2020-12-08 00:22:54 +08:00
|
|
|
$j('#alarmSound').addClass('hidden');
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2020-12-08 00:22:54 +08:00
|
|
|
$j('#MediaPlayer').trigger('pause');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2009-05-26 02:03:46 +08:00
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
lastAlarmState = alarmState;
|
2020-03-05 00:17:48 +08:00
|
|
|
} // end function setAlarmState( currentAlarmState )
|
2008-07-16 23:47:33 +08:00
|
|
|
|
2021-12-17 05:38:15 +08:00
|
|
|
function streamCmdReq(data) {
|
|
|
|
if (auth_hash) data.auth = auth_hash;
|
|
|
|
$j.getJSON(monitorUrl + '?view=request&request=stream&connkey='+connKey, data)
|
|
|
|
.done(getStreamCmdResponse)
|
|
|
|
.fail(getStreamCmdError);
|
|
|
|
|
|
|
|
streamCmdTimer = null;
|
|
|
|
}
|
|
|
|
|
2019-01-18 23:00:55 +08:00
|
|
|
function getStreamCmdError(text, error) {
|
2018-08-31 22:34:54 +08:00
|
|
|
console.log(error);
|
|
|
|
// Error are normally due to failed auth. reload the page.
|
2021-01-12 02:38:04 +08:00
|
|
|
|
|
|
|
//window.location.reload();
|
2018-08-31 22:34:54 +08:00
|
|
|
}
|
2020-11-27 07:00:05 +08:00
|
|
|
|
2018-08-31 22:34:54 +08:00
|
|
|
function getStreamCmdResponse(respObj, respText) {
|
2020-01-06 06:33:53 +08:00
|
|
|
watchdogOk('stream');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamCmdTimer) {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdTimer = clearTimeout(streamCmdTimer);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (respObj.result == 'Ok') {
|
2018-01-30 00:25:46 +08:00
|
|
|
// The get status command can get backed up, in which case we won't be able to get the semaphore and will exit.
|
2021-08-19 06:40:25 +08:00
|
|
|
if (respObj.status) {
|
2018-01-30 00:25:46 +08:00
|
|
|
streamStatus = respObj.status;
|
2021-12-11 04:34:35 +08:00
|
|
|
if ($j('#viewingFPSValue').text() != streamStatus.fps) {
|
|
|
|
$j('#viewingFPSValue').text(streamStatus.fps);
|
|
|
|
}
|
|
|
|
if ($j('#captureFPSValue').text() != streamStatus.capturefps) {
|
|
|
|
$j('#captureFPSValue').text(streamStatus.capturefps);
|
|
|
|
}
|
|
|
|
if ($j('#analysisFPSValue').text() != streamStatus.analysisfps) {
|
|
|
|
$j('#analysisFPSValue').text(streamStatus.analysisfps);
|
|
|
|
}
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2018-08-31 22:34:54 +08:00
|
|
|
setAlarmState(streamStatus.state);
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#levelValue').text(streamStatus.level);
|
2020-12-08 00:22:54 +08:00
|
|
|
var newClass = 'ok';
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.level > 95) {
|
2020-12-08 00:22:54 +08:00
|
|
|
newClass = 'alarm';
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (streamStatus.level > 80) {
|
2020-12-08 00:22:54 +08:00
|
|
|
newClass = 'alert';
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-12-08 00:22:54 +08:00
|
|
|
$j('#levelValue').removeClass();
|
|
|
|
$j('#levelValue').addClass(newClass);
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2018-08-31 22:34:54 +08:00
|
|
|
var delayString = secsToTime(streamStatus.delay);
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.paused == true) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#modeValue').text('Paused');
|
|
|
|
$j('#rate').addClass('hidden');
|
|
|
|
$j('#delayValue').text(delayString);
|
|
|
|
$j('#delay').removeClass('hidden');
|
|
|
|
$j('#level').removeClass('hidden');
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdPause(false);
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (streamStatus.delayed == true) {
|
2020-12-04 03:12:01 +08:00
|
|
|
$j('#modeValue').text('Replay');
|
|
|
|
$j('#rateValue').text(streamStatus.rate);
|
|
|
|
$j('#rate').removeClass('hidden');
|
|
|
|
$j('#delayValue').text(delayString);
|
|
|
|
$j('#delay').removeClass('hidden');
|
|
|
|
$j('#level').removeClass('hidden');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.rate == 1) {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdPlay(false);
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (streamStatus.rate > 0) {
|
|
|
|
if (streamStatus.rate < 1) {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdSlowFwd(false);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdFastFwd(false);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-01-30 00:25:46 +08:00
|
|
|
} else {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.rate > -1) {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdSlowRev(false);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2018-08-31 22:34:54 +08:00
|
|
|
streamCmdFastRev(false);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-01-30 00:25:46 +08:00
|
|
|
} // rate
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2020-12-16 04:56:41 +08:00
|
|
|
$j('#modeValue').text('Live');
|
|
|
|
$j('#rate').addClass('hidden');
|
|
|
|
$j('#delay').addClass('hidden');
|
|
|
|
$j('#level').addClass('hidden');
|
2019-09-27 04:13:49 +08:00
|
|
|
streamCmdPlay(false);
|
2018-01-30 00:25:46 +08:00
|
|
|
} // end if paused or delayed
|
|
|
|
|
2020-12-16 04:56:41 +08:00
|
|
|
$j('#zoomValue').text(streamStatus.zoom);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.zoom == '1.0') {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('zoomOutBtn', 'unavail');
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('zoomOutBtn', 'inactive');
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (canEdit.Monitors) {
|
|
|
|
if (streamStatus.enabled) {
|
2020-10-17 04:47:42 +08:00
|
|
|
enableAlmBtn.addClass('disabled');
|
|
|
|
enableAlmBtn.prop('title', disableAlarmsStr);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.forced) {
|
2020-10-17 04:47:42 +08:00
|
|
|
forceAlmBtn.addClass('disabled');
|
|
|
|
forceAlmBtn.prop('title', cancelForcedAlarmStr);
|
2018-01-30 00:25:46 +08:00
|
|
|
} else {
|
2020-10-17 04:47:42 +08:00
|
|
|
forceAlmBtn.removeClass('disabled');
|
|
|
|
forceAlmBtn.prop('title', forceAlarmStr);
|
2018-01-30 00:25:46 +08:00
|
|
|
}
|
2020-10-17 04:47:42 +08:00
|
|
|
forceAlmBtn.prop('disabled', false);
|
2016-09-01 00:53:34 +08:00
|
|
|
} else {
|
2020-10-17 04:47:42 +08:00
|
|
|
enableAlmBtn.removeClass('disabled');
|
|
|
|
enableAlmBtn.prop('title', enableAlarmsStr);
|
|
|
|
forceAlmBtn.prop('disabled', true);
|
2016-09-01 00:53:34 +08:00
|
|
|
}
|
2020-10-17 04:47:42 +08:00
|
|
|
enableAlmBtn.prop('disabled', false);
|
2020-12-09 04:25:48 +08:00
|
|
|
} // end if canEdit.Monitors
|
2018-01-30 00:25:46 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.auth) {
|
2020-01-08 06:08:57 +08:00
|
|
|
auth_hash = streamStatus.auth;
|
2018-01-30 00:25:46 +08:00
|
|
|
// Try to reload the image stream.
|
2020-12-08 00:22:54 +08:00
|
|
|
var streamImg = $j('#liveStream'+monitorId);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamImg) {
|
2021-12-11 04:34:35 +08:00
|
|
|
const oldSrc = streamImg.attr('src');
|
|
|
|
if (oldSrc) {
|
|
|
|
const newSrc = oldSrc.replace(/auth=\w+/i, 'auth='+streamStatus.auth);
|
|
|
|
if (oldSrc != newSrc) {
|
|
|
|
streamImg.attr('src', newSrc);
|
|
|
|
table.bootstrapTable('refresh');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
}
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-08-31 22:34:54 +08:00
|
|
|
} // end if have a new auth hash
|
2018-01-30 00:25:46 +08:00
|
|
|
} // end if respObj.status
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2021-12-17 05:38:15 +08:00
|
|
|
console.log("Not ok");
|
2020-03-05 00:17:48 +08:00
|
|
|
checkStreamForErrors('getStreamCmdResponse', respObj);//log them
|
2021-12-17 05:38:15 +08:00
|
|
|
fetchImage($j('#imageFeed img'));
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
var streamCmdTimeout = statusRefreshTimeout;
|
2021-08-19 06:40:25 +08:00
|
|
|
if (alarmState == STATE_ALARM || alarmState == STATE_ALERT) {
|
2016-09-27 23:51:55 +08:00
|
|
|
streamCmdTimeout = streamCmdTimeout/5;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-01-09 02:25:17 +08:00
|
|
|
streamCmdTimer = setTimeout(streamCmdQuery, streamCmdTimeout);
|
2017-05-19 01:50:56 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-12-17 05:38:15 +08:00
|
|
|
function streamCmdQuery() {
|
|
|
|
streamCmdReq({command: CMD_QUERY});
|
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdPause(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'active');
|
|
|
|
setButtonState('playBtn', 'inactive');
|
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2021-08-19 06:40:25 +08:00
|
|
|
if (auth_hash) data.auth = auth_hash;
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = CMD_PAUSE;
|
|
|
|
streamCmdReq(data);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdPlay(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'active');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus.delayed == true) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('stopBtn', 'unavail');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'unavail');
|
|
|
|
setButtonState('slowFwdBtn', 'unavail');
|
|
|
|
setButtonState('slowRevBtn', 'unavail');
|
|
|
|
setButtonState('fastRevBtn', 'unavail');
|
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_PLAY});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2020-12-10 02:25:40 +08:00
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdStop(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'unavail');
|
|
|
|
setButtonState('stopBtn', 'active');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'unavail');
|
|
|
|
setButtonState('slowFwdBtn', 'unavail');
|
|
|
|
setButtonState('slowRevBtn', 'unavail');
|
|
|
|
setButtonState('fastRevBtn', 'unavail');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-11 04:34:35 +08:00
|
|
|
streamCmdReq({command: CMD_STOP});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('stopBtn', 'unavail');
|
|
|
|
setButtonState('playBtn', 'active');
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdFastFwd(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'inactive');
|
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_FASTFWD});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdSlowFwd(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'inactive');
|
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'active');
|
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_SLOWFWD});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'active');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdSlowRev(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'inactive');
|
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowRevBtn', 'active');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_SLOWREV});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'active');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-01-30 03:05:04 +08:00
|
|
|
function streamCmdFastRev(action) {
|
2020-03-03 00:52:32 +08:00
|
|
|
setButtonState('pauseBtn', 'inactive');
|
|
|
|
setButtonState('playBtn', 'inactive');
|
|
|
|
setButtonState('stopBtn', 'inactive');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorStreamReplayBuffer) {
|
2020-03-03 01:43:07 +08:00
|
|
|
setButtonState('fastFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowFwdBtn', 'inactive');
|
|
|
|
setButtonState('slowRevBtn', 'inactive');
|
|
|
|
setButtonState('fastRevBtn', 'inactive');
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (action) {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_FASTREV});
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
function streamCmdZoomIn(x, y) {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.x = x;
|
|
|
|
data.y = y;
|
|
|
|
data.command = CMD_ZOOMIN;
|
|
|
|
streamCmdReq(data);
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function streamCmdZoomOut() {
|
2021-12-17 05:38:15 +08:00
|
|
|
streamCmdReq({command: CMD_ZOOMOUT});
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
function streamCmdScale(scale) {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = CMD_SCALE;
|
|
|
|
data.scale = scale;
|
2020-12-10 07:58:46 +08:00
|
|
|
streamCmdReq(data);
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
function streamCmdPan(x, y) {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.x = x;
|
|
|
|
data.y = y;
|
|
|
|
data.command = CMD_PAN;
|
|
|
|
streamCmdReq(data);
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
|
2008-07-16 23:47:33 +08:00
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
/* getStatusCmd is used when not streaming, since there is no persistent zms */
|
2018-08-31 22:34:54 +08:00
|
|
|
function getStatusCmdResponse(respObj, respText) {
|
2020-03-05 00:17:48 +08:00
|
|
|
watchdogOk('status');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (statusCmdTimer) {
|
2018-08-31 22:34:54 +08:00
|
|
|
statusCmdTimer = clearTimeout(statusCmdTimer);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (respObj.result == 'Ok') {
|
2021-12-11 04:34:35 +08:00
|
|
|
$j('#captureFPSValue').text(respObj.monitor.FrameRate);
|
2018-08-31 22:34:54 +08:00
|
|
|
setAlarmState(respObj.monitor.Status);
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2020-03-05 00:17:48 +08:00
|
|
|
checkStreamForErrors('getStatusCmdResponse', respObj);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
|
|
|
|
var statusCmdTimeout = statusRefreshTimeout;
|
2021-12-11 04:34:35 +08:00
|
|
|
if (alarmState == STATE_ALARM || alarmState == STATE_ALERT) {
|
2016-09-27 23:51:55 +08:00
|
|
|
statusCmdTimeout = statusCmdTimeout/5;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-01-09 02:25:17 +08:00
|
|
|
statusCmdTimer = setTimeout(statusCmdQuery, statusCmdTimeout);
|
2017-03-18 15:00:51 +08:00
|
|
|
}
|
2008-07-16 23:47:33 +08:00
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function statusCmdQuery() {
|
2021-12-11 04:34:35 +08:00
|
|
|
$j.getJSON(monitorUrl + '?view=request&request=status&entity=monitor&element[]=Status&element[]=FrameRate&id='+monitorId+'&'+auth_relay)
|
2020-12-10 02:25:40 +08:00
|
|
|
.done(getStatusCmdResponse)
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
statusCmdTimer = null;
|
2020-12-10 02:25:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function alarmCmdReq(data) {
|
2021-12-11 04:34:35 +08:00
|
|
|
if (auth_hash) data.auth = auth_hash;
|
2021-01-17 02:16:23 +08:00
|
|
|
$j.getJSON(monitorUrl + '?view=request&request=alarm&id='+monitorId, data)
|
2020-12-10 02:25:40 +08:00
|
|
|
.done(getAlarmCmdResponse)
|
|
|
|
.fail(function(jqxhr, textStatus, error) {
|
2021-12-11 04:34:35 +08:00
|
|
|
if (textStatus === 'timeout') {
|
2020-12-10 02:25:40 +08:00
|
|
|
streamCmdQuery();
|
|
|
|
} else {
|
|
|
|
logAjaxFail(jqxhr, textStatus, error);
|
|
|
|
}
|
|
|
|
});
|
2018-04-27 05:18:36 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2020-03-05 00:17:48 +08:00
|
|
|
function getAlarmCmdResponse(respObj, respText) {
|
|
|
|
checkStreamForErrors('getAlarmCmdResponse', respObj);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function cmdDisableAlarms() {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = 'disableAlarms';
|
|
|
|
alarmCmdReq(data);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function cmdEnableAlarms() {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = 'enableAlarms';
|
|
|
|
alarmCmdReq(data);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-10-17 04:47:42 +08:00
|
|
|
function cmdAlarm() {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (enableAlmBtn.hasClass('disabled')) {
|
2020-10-17 04:47:42 +08:00
|
|
|
cmdEnableAlarms();
|
|
|
|
} else {
|
|
|
|
cmdDisableAlarms();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function cmdForceAlarm() {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = 'forceAlarm';
|
|
|
|
alarmCmdReq(data);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (window.event) window.event.preventDefault();
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function cmdCancelForcedAlarm() {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.command = 'cancelForcedAlarm';
|
|
|
|
alarmCmdReq(data);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (window.event) window.event.preventDefault();
|
2017-08-04 00:41:43 +08:00
|
|
|
return false;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2020-10-17 04:47:42 +08:00
|
|
|
function cmdForce() {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (forceAlmBtn.hasClass('disabled')) {
|
2020-10-17 04:47:42 +08:00
|
|
|
cmdCancelForcedAlarm();
|
|
|
|
} else {
|
|
|
|
cmdForceAlarm();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-10 02:25:40 +08:00
|
|
|
function controlReq(data) {
|
2021-12-11 04:34:35 +08:00
|
|
|
if (auth_hash) data.auth = auth_hash;
|
2021-01-17 02:16:23 +08:00
|
|
|
$j.getJSON(monitorUrl + '?view=request&request=control&id='+monitorId, data)
|
2020-12-10 02:25:40 +08:00
|
|
|
.done(getControlResponse)
|
|
|
|
.fail(logAjaxFail);
|
2018-04-27 05:18:36 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2020-03-05 00:17:48 +08:00
|
|
|
function getControlResponse(respObj, respText) {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (!respObj) {
|
2016-09-27 23:51:55 +08:00
|
|
|
return;
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
//console.log( respText );
|
2021-08-19 06:40:25 +08:00
|
|
|
if (respObj.result != 'Ok') {
|
2020-03-05 00:17:48 +08:00
|
|
|
alert("Control response was status = "+respObj.status+"\nmessage = "+respObj.message);
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-30 04:35:04 +08:00
|
|
|
function controlCmd(event) {
|
|
|
|
button = event.target;
|
2021-04-24 07:40:52 +08:00
|
|
|
|
|
|
|
console.log(event);
|
|
|
|
if (event.type !='mouseup') {
|
2021-04-16 22:24:48 +08:00
|
|
|
control = button.getAttribute('value');
|
|
|
|
} else {
|
|
|
|
console.log('stop');
|
2021-04-16 23:27:48 +08:00
|
|
|
console.log(event);
|
2021-04-16 22:24:48 +08:00
|
|
|
control = 'moveStop';
|
|
|
|
}
|
2020-05-13 20:01:04 +08:00
|
|
|
xtell = button.getAttribute('data-xtell');
|
|
|
|
ytell = button.getAttribute('data-ytell');
|
2020-04-10 23:30:30 +08:00
|
|
|
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (event && (xtell || ytell)) {
|
2021-12-11 04:34:35 +08:00
|
|
|
const target = event.target;
|
|
|
|
const offset = $j(target).offset();
|
|
|
|
const width = $j(target).width();
|
|
|
|
const height = $j(target).height();
|
2016-09-27 23:51:55 +08:00
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
const x = event.pageX - offset.left;
|
|
|
|
const y = event.pageY - offset.top;
|
2016-09-27 23:51:55 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (xtell) {
|
2021-12-11 04:34:35 +08:00
|
|
|
let xge = parseInt((x*100)/width);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (xtell == -1) {
|
2016-09-27 23:51:55 +08:00
|
|
|
xge = 100 - xge;
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (xtell == 2) {
|
2016-09-27 23:51:55 +08:00
|
|
|
xge = 2*(50 - xge);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-12-10 02:25:40 +08:00
|
|
|
data.xge = xge;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (ytell) {
|
2021-12-11 04:34:35 +08:00
|
|
|
let yge = parseInt((y*100)/height);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (ytell == -1) {
|
2016-09-27 23:51:55 +08:00
|
|
|
yge = 100 - yge;
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (ytell == 2) {
|
2016-09-27 23:51:55 +08:00
|
|
|
yge = 2*(50 - yge);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2020-12-10 02:25:40 +08:00
|
|
|
data.yge = yge;
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2020-12-10 02:25:40 +08:00
|
|
|
|
2020-12-10 07:58:46 +08:00
|
|
|
data.control = control;
|
2020-12-10 02:25:40 +08:00
|
|
|
controlReq(data);
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamMode == 'single') {
|
2020-12-13 02:45:36 +08:00
|
|
|
setTimeout(fetchImage, 1000, $j('#imageFeed img'));
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
function controlCmdImage(x, y) {
|
2020-12-10 07:58:46 +08:00
|
|
|
var data = {};
|
2020-12-10 02:25:40 +08:00
|
|
|
data.scale = scale;
|
|
|
|
data.control = imageControlMode;
|
|
|
|
data.x = x;
|
|
|
|
data.y = y;
|
|
|
|
controlReq(data);
|
2020-12-10 07:58:46 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamMode == 'single') {
|
2020-12-13 02:45:36 +08:00
|
|
|
setTimeout(fetchImage, 1000, $j('#imageFeed img'));
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2018-10-19 08:33:50 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-02-03 12:19:44 +08:00
|
|
|
function fetchImage(streamImage) {
|
2021-12-17 05:38:15 +08:00
|
|
|
const oldsrc = streamImage.attr('src');
|
|
|
|
streamImage.attr('src', '');
|
|
|
|
streamImage.attr('src', oldsrc.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) )));
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2021-02-03 12:19:44 +08:00
|
|
|
function handleClick(event) {
|
2021-01-14 23:33:03 +08:00
|
|
|
// target should be the img tag
|
2021-02-03 12:19:44 +08:00
|
|
|
var target = $j(event.target);
|
|
|
|
var width = target.width();
|
|
|
|
var height = target.height();
|
2020-12-08 04:44:45 +08:00
|
|
|
|
2020-12-08 00:22:54 +08:00
|
|
|
var scaleX = parseInt(monitorWidth / width);
|
|
|
|
var scaleY = parseInt(monitorHeight / height);
|
2021-02-03 12:19:44 +08:00
|
|
|
var pos = target.offset();
|
|
|
|
var x = parseInt((event.pageX - pos.left) * scaleX);
|
|
|
|
var y = parseInt((event.pageY - pos.top) * scaleY);
|
2016-09-27 23:51:55 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (showMode == 'events' || !imageControlMode) {
|
2019-01-19 23:32:40 +08:00
|
|
|
if ( event.shift ) {
|
2021-01-14 23:33:03 +08:00
|
|
|
streamCmdPan(x, y);
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (event.ctrlKey) {
|
2019-06-11 22:58:54 +08:00
|
|
|
streamCmdZoomOut();
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2019-09-27 04:13:49 +08:00
|
|
|
streamCmdZoomIn(x, y);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2019-09-27 04:13:49 +08:00
|
|
|
controlCmdImage(x, y);
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function appletRefresh() {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamStatus && (!streamStatus.paused && !streamStatus.delayed)) {
|
2020-12-08 00:22:54 +08:00
|
|
|
var streamImg = $j('#liveStream'+monitorId);
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamImg) {
|
2020-12-08 00:22:54 +08:00
|
|
|
var parent = streamImg.parent();
|
|
|
|
streamImg.remove();
|
2021-01-30 03:05:04 +08:00
|
|
|
streamImg.append(parent);
|
2020-03-20 23:06:01 +08:00
|
|
|
} else {
|
|
|
|
console.error("Nothing found for liveStream"+monitorId);
|
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (appletRefreshTime) {
|
2021-01-09 02:25:17 +08:00
|
|
|
setTimeout(appletRefresh, appletRefreshTime*1000);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
2021-01-30 03:05:04 +08:00
|
|
|
setTimeout(appletRefresh, 15*1000); // if we are paused or delayed check every 15 seconds if we are live yet...
|
2016-09-27 23:51:55 +08:00
|
|
|
}
|
2009-05-26 02:03:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var watchdogInactive = {
|
2016-09-27 23:51:55 +08:00
|
|
|
'stream': false,
|
2020-11-27 07:00:05 +08:00
|
|
|
'status': false
|
2009-05-26 02:03:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
var watchdogFunctions = {
|
2016-09-27 23:51:55 +08:00
|
|
|
'stream': streamCmdQuery,
|
|
|
|
'status': statusCmdQuery,
|
2009-05-26 02:03:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//Make sure the various refreshes are still taking effect
|
2021-08-19 06:40:25 +08:00
|
|
|
function watchdogCheck(type) {
|
|
|
|
if (watchdogInactive[type]) {
|
2018-08-31 22:34:54 +08:00
|
|
|
console.log("Detected streamWatch of type: " + type + " stopped, restarting");
|
2016-09-27 23:51:55 +08:00
|
|
|
watchdogFunctions[type]();
|
2009-05-26 02:03:46 +08:00
|
|
|
watchdogInactive[type] = false;
|
2016-09-27 23:51:55 +08:00
|
|
|
} else {
|
|
|
|
watchdogInactive[type] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
function watchdogOk(type) {
|
2016-09-27 23:51:55 +08:00
|
|
|
watchdogInactive[type] = false;
|
|
|
|
}
|
|
|
|
|
2018-07-05 21:43:21 +08:00
|
|
|
function reloadWebSite() {
|
2018-08-31 22:34:54 +08:00
|
|
|
document.getElementById('imageFeed').innerHTML = document.getElementById('imageFeed').innerHTML;
|
2018-07-05 21:43:21 +08:00
|
|
|
}
|
|
|
|
|
2020-10-03 04:46:28 +08:00
|
|
|
function updatePresetLabels() {
|
2021-01-30 03:05:04 +08:00
|
|
|
var lblNdx = $j('#ctrlPresetForm option:selected').val();
|
2020-12-08 02:32:07 +08:00
|
|
|
$j('#newLabel').val(labels[lblNdx]);
|
2020-10-03 04:46:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCtrlPresetModal() {
|
2021-01-17 02:16:23 +08:00
|
|
|
$j.getJSON(monitorUrl + '?request=modal&modal=controlpreset&mid=' + monitorId)
|
2020-10-03 04:46:28 +08:00
|
|
|
.done(function(data) {
|
2020-10-15 04:58:39 +08:00
|
|
|
insertModalHtml('ctrlPresetModal', data.html);
|
2020-10-03 04:46:28 +08:00
|
|
|
updatePresetLabels();
|
2020-10-04 10:14:24 +08:00
|
|
|
// Manage the Preset Select box
|
|
|
|
$j('#preset').change(updatePresetLabels);
|
2020-10-03 05:10:32 +08:00
|
|
|
// Manage the Save button
|
|
|
|
$j('#cPresetSubmitModal').click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j('#ctrlPresetForm').submit();
|
2020-10-03 10:11:54 +08:00
|
|
|
});
|
2020-10-03 04:46:28 +08:00
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
}
|
|
|
|
|
2021-10-06 07:21:55 +08:00
|
|
|
function changeControl(e) {
|
|
|
|
const input = e.target;
|
|
|
|
$j.getJSON(monitorUrl+'?request=v4l2_settings&mid='+monitorId+'&'+input.name+'='+input.value)
|
|
|
|
.done(function(evt) {
|
|
|
|
if (evt.result == 'Ok') {
|
|
|
|
evt.controls.forEach(function(control) {
|
|
|
|
const element = $j('#new'+control.control.charAt(0).toUpperCase() + control.control.slice(1));
|
|
|
|
if (element.length) {
|
|
|
|
element.val(control.value);
|
|
|
|
element.attr('title', control.value);
|
|
|
|
} else {
|
|
|
|
console.err('Element not found for #new'+control.control.charAt(0).toUpperCase() + control.control.slice(1));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
}
|
|
|
|
|
2020-10-04 05:51:25 +08:00
|
|
|
function getSettingsModal() {
|
2021-01-17 02:16:23 +08:00
|
|
|
$j.getJSON(monitorUrl + '?request=modal&modal=settings&mid=' + monitorId)
|
2020-10-04 05:51:25 +08:00
|
|
|
.done(function(data) {
|
2020-10-15 04:58:39 +08:00
|
|
|
insertModalHtml('settingsModal', data.html);
|
2020-10-04 05:51:25 +08:00
|
|
|
// Manage the Save button
|
|
|
|
$j('#settingsSubmitModal').click(function(evt) {
|
|
|
|
evt.preventDefault();
|
|
|
|
$j('#settingsForm').submit();
|
|
|
|
});
|
2021-10-06 07:21:55 +08:00
|
|
|
$j('#newBrightness').change(changeControl);
|
|
|
|
$j('#newContrast').change(changeControl);
|
|
|
|
$j('#newHue').change(changeControl);
|
|
|
|
$j('#newColour').change(changeControl);
|
2020-10-04 05:51:25 +08:00
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
}
|
|
|
|
|
2020-11-27 07:00:05 +08:00
|
|
|
function processClicks(event, field, value, row, $element) {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (field == 'Delete') {
|
2021-01-17 02:16:23 +08:00
|
|
|
$j.getJSON(monitorUrl + '?request=modal&modal=delconfirm')
|
2020-11-27 09:28:25 +08:00
|
|
|
.done(function(data) {
|
|
|
|
insertModalHtml('deleteConfirm', data.html);
|
|
|
|
manageDelConfirmModalBtns();
|
|
|
|
$j('#deleteConfirm').data('eid', row.Id.replace(/(<([^>]+)>)/gi, ''));
|
|
|
|
$j('#deleteConfirm').modal('show');
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
2020-11-27 07:00:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Manage the DELETE CONFIRMATION modal button
|
|
|
|
function manageDelConfirmModalBtns() {
|
|
|
|
document.getElementById("delConfirmBtn").addEventListener("click", function onDelConfirmClick(evt) {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (!canEdit.Events) {
|
2020-11-27 07:00:05 +08:00
|
|
|
enoperm();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var eid = $j('#deleteConfirm').data('eid');
|
|
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
$j.getJSON(thisUrl + '?request=events&task=delete&eids[]='+eid)
|
2021-08-19 06:40:25 +08:00
|
|
|
.done(function(data) {
|
2020-11-27 07:00:05 +08:00
|
|
|
table.bootstrapTable('refresh');
|
|
|
|
$j('#deleteConfirm').modal('hide');
|
|
|
|
})
|
|
|
|
.fail(logAjaxFail);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the CANCEL modal button
|
|
|
|
document.getElementById("delCancelBtn").addEventListener("click", function onDelCancelClick(evt) {
|
|
|
|
$j('#deleteConfirm').modal('hide');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-01-08 22:27:06 +08:00
|
|
|
function msieVer() {
|
2021-01-08 22:50:57 +08:00
|
|
|
var ua = window.navigator.userAgent;
|
|
|
|
var msie = ua.indexOf("MSIE ");
|
2021-01-08 22:27:06 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (msie >= 0) { // If Internet Explorer, return version number
|
2021-01-08 22:50:57 +08:00
|
|
|
return msie;
|
|
|
|
} else { // If another browser, return 0
|
|
|
|
return 0;
|
|
|
|
}
|
2021-01-08 22:27:06 +08:00
|
|
|
}
|
|
|
|
|
2016-09-27 23:51:55 +08:00
|
|
|
function initPage() {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (canView.Control) {
|
2020-10-04 05:51:25 +08:00
|
|
|
// Load the PTZ Preset modal into the DOM
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorControllable) getCtrlPresetModal();
|
2020-10-04 05:51:25 +08:00
|
|
|
// Load the settings modal into the DOM
|
2021-12-11 04:34:35 +08:00
|
|
|
if (monitorType == 'Local') getSettingsModal();
|
2020-10-04 05:51:25 +08:00
|
|
|
}
|
2020-10-03 04:46:28 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorType != 'WebSite') {
|
2022-01-12 11:19:58 +08:00
|
|
|
if (streamMode != 'janus') {
|
|
|
|
if (streamMode == 'single') {
|
|
|
|
statusCmdTimer = setTimeout(statusCmdQuery, 200);
|
|
|
|
setInterval(watchdogCheck, statusRefreshTimeout*2, 'status');
|
|
|
|
} else {
|
|
|
|
streamCmdTimer = setTimeout(streamCmdQuery, 200);
|
|
|
|
setInterval(watchdogCheck, statusRefreshTimeout*2, 'stream');
|
|
|
|
}
|
2018-04-27 05:18:36 +08:00
|
|
|
}
|
2022-01-12 11:19:58 +08:00
|
|
|
if (streamMode == 'janus') {
|
|
|
|
server = "http://" + window.location.hostname + ":8088/janus";
|
|
|
|
opaqueId = "streamingtest-"+Janus.randomString(12);
|
|
|
|
Janus.init({debug: "all", callback: function() {
|
|
|
|
janus = new Janus({
|
|
|
|
server: server,
|
|
|
|
success: function() {
|
|
|
|
janus.attach({
|
|
|
|
plugin: "janus.plugin.streaming",
|
|
|
|
opaqueId: opaqueId,
|
|
|
|
success: function(pluginHandle) {
|
|
|
|
streaming2 = pluginHandle;
|
|
|
|
var body = { "request": "watch", "id":monitorId };
|
|
|
|
streaming2.send({"message": body});
|
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
Janus.error(" -- Error attaching plugin... ", error);
|
|
|
|
},
|
|
|
|
onmessage: function(msg, jsep) {
|
|
|
|
Janus.debug(" ::: Got a message :::");
|
|
|
|
Janus.debug(msg);
|
|
|
|
var result = msg["result"];
|
|
|
|
if(result !== null && result !== undefined) {
|
|
|
|
if(result["status"] !== undefined && result["status"] !== null) {
|
|
|
|
var status = result["status"];
|
|
|
|
}
|
|
|
|
} else if(msg["error"] !== undefined && msg["error"] !== null) {
|
2022-01-13 12:46:26 +08:00
|
|
|
Janus.error(msg["error"]);
|
2022-01-12 11:19:58 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(jsep !== undefined && jsep !== null) {
|
|
|
|
Janus.debug("Handling SDP as well...");
|
|
|
|
Janus.debug(jsep);
|
|
|
|
// Offer from the plugin, let's answer
|
|
|
|
streaming2.createAnswer({
|
|
|
|
jsep: jsep,
|
|
|
|
// We want recvonly audio/video and, if negotiated, datachannels
|
|
|
|
media: { audioSend: false, videoSend: false, data: true },
|
|
|
|
success: function(jsep) {
|
|
|
|
Janus.debug("Got SDP!");
|
|
|
|
Janus.debug(jsep);
|
|
|
|
var body = { "request": "start"};
|
|
|
|
streaming2.send({"message": body, "jsep": jsep});
|
|
|
|
},
|
|
|
|
error: function(error) {
|
|
|
|
Janus.error("WebRTC error:", error);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, //onmessage function
|
|
|
|
onremotestream: function(stream) {
|
|
|
|
Janus.debug(" ::: Got a remote track :::");
|
|
|
|
Janus.debug(stream);
|
|
|
|
Janus.attachMediaStream(document.getElementById("liveStream" + monitorId), stream);
|
|
|
|
document.getElementById("liveStream" + monitorId).play();
|
|
|
|
}
|
|
|
|
});// attach
|
|
|
|
} //Success functio
|
|
|
|
}); //new Janus
|
|
|
|
}}); //janus.init callback
|
|
|
|
} else if (canStreamNative || (streamMode == 'single')) {
|
2020-12-13 02:45:36 +08:00
|
|
|
var streamImg = $j('#imageFeed img');
|
2021-12-11 04:34:35 +08:00
|
|
|
if (!streamImg) streamImg = $j('#imageFeed object');
|
2021-08-19 06:40:25 +08:00
|
|
|
if (!streamImg) {
|
2020-03-20 23:06:01 +08:00
|
|
|
console.error('No streamImg found for imageFeed');
|
2019-01-19 23:32:40 +08:00
|
|
|
} else {
|
2021-08-19 06:40:25 +08:00
|
|
|
if (streamMode == 'single') {
|
2020-12-13 02:45:36 +08:00
|
|
|
streamImg.click(streamImg, fetchImage);
|
|
|
|
setInterval(fetchImage, imageRefreshTimeout, $j('#imageFeed img'));
|
2020-03-20 23:06:01 +08:00
|
|
|
} else {
|
2020-12-13 02:45:36 +08:00
|
|
|
streamImg.click(function(event) {
|
2020-03-20 23:06:01 +08:00
|
|
|
handleClick(event);
|
|
|
|
});
|
2021-12-11 04:34:35 +08:00
|
|
|
streamImg.on("error", function(thing) {
|
|
|
|
console.log("Error loading image");
|
|
|
|
console.log(thing);
|
2021-12-17 05:38:15 +08:00
|
|
|
setInterval(fetchImage, 100, $j('#imageFeed img'));
|
2021-12-11 04:34:35 +08:00
|
|
|
});
|
2020-03-20 23:06:01 +08:00
|
|
|
}
|
|
|
|
} // end if have streamImg
|
|
|
|
} // streamMode native or single
|
2018-04-27 05:18:36 +08:00
|
|
|
|
2021-08-19 06:40:25 +08:00
|
|
|
if (refreshApplet && appletRefreshTime) {
|
2021-01-09 02:25:17 +08:00
|
|
|
setTimeout(appletRefresh, appletRefreshTime*1000);
|
2019-01-19 23:32:40 +08:00
|
|
|
}
|
2021-08-19 06:40:25 +08:00
|
|
|
if (window.history.length == 1) {
|
2018-04-27 05:18:36 +08:00
|
|
|
$j('#closeControl').html('');
|
|
|
|
}
|
2019-09-20 22:44:38 +08:00
|
|
|
document.querySelectorAll('select[name="scale"]').forEach(function(el) {
|
2019-09-20 02:57:17 +08:00
|
|
|
el.onchange = window['changeScale'];
|
|
|
|
});
|
2021-01-12 02:38:04 +08:00
|
|
|
changeScale();
|
2021-12-17 05:38:15 +08:00
|
|
|
document.querySelectorAll('select[name="changeRate"]').forEach(function(el) {
|
|
|
|
el.onchange = window['changeRate'].bind(el, el);
|
|
|
|
});
|
2021-08-19 06:40:25 +08:00
|
|
|
} else if (monitorRefresh > 0) {
|
2019-01-19 23:32:40 +08:00
|
|
|
setInterval(reloadWebSite, monitorRefresh*1000);
|
2017-12-13 23:20:02 +08:00
|
|
|
}
|
2020-11-27 07:00:05 +08:00
|
|
|
|
2020-10-16 21:08:23 +08:00
|
|
|
// Manage the BACK button
|
2021-01-17 02:16:23 +08:00
|
|
|
bindButton('#backBtn', 'click', null, function onBackClick(evt) {
|
2020-10-16 21:08:23 +08:00
|
|
|
evt.preventDefault();
|
|
|
|
window.history.back();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Don't enable the back button if there is no previous zm page to go back to
|
|
|
|
backBtn.prop('disabled', !document.referrer.length);
|
|
|
|
|
|
|
|
// Manage the REFRESH Button
|
2021-01-17 02:16:23 +08:00
|
|
|
bindButton('#refreshBtn', 'click', null, function onRefreshClick(evt) {
|
2020-10-16 21:08:23 +08:00
|
|
|
evt.preventDefault();
|
|
|
|
window.location.reload(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Manage the SETTINGS button
|
2021-01-20 00:32:18 +08:00
|
|
|
bindButton('#settingsBtn', 'click', null, function onSettingsClick(evt) {
|
2020-10-16 21:08:23 +08:00
|
|
|
evt.preventDefault();
|
|
|
|
$j('#settingsModal').modal('show');
|
|
|
|
});
|
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
bindButton('#cyclePlayBtn', 'click', null, cycleStart);
|
|
|
|
bindButton('#cyclePauseBtn', 'click', null, cyclePause);
|
|
|
|
bindButton('#cycleNextBtn', 'click', null, cycleNext);
|
|
|
|
bindButton('#cyclePrevBtn', 'click', null, cyclePrev);
|
|
|
|
bindButton('#cycleToggle', 'click', null, cycleToggle);
|
|
|
|
bindButton('#cyclePeriod', 'change', null, cyclePeriodChange);
|
|
|
|
if (cycle) {
|
|
|
|
cycleStart();
|
|
|
|
} else {
|
|
|
|
cyclePause();
|
|
|
|
}
|
|
|
|
|
2020-10-16 21:08:23 +08:00
|
|
|
// Only enable the settings button for local cameras
|
2021-10-25 03:51:58 +08:00
|
|
|
settingsBtn.prop('disabled', !(canView.Control && (monitorType == 'Local')));
|
2020-11-27 07:00:05 +08:00
|
|
|
|
|
|
|
// Init the bootstrap-table
|
2021-08-19 06:40:25 +08:00
|
|
|
if (monitorType != 'WebSite') table.bootstrapTable({icons: icons});
|
2020-11-27 07:00:05 +08:00
|
|
|
|
|
|
|
// Update table rows each time after new data is loaded
|
|
|
|
table.on('post-body.bs.table', function(data) {
|
|
|
|
$j('#eventList tr:contains("New Event")').addClass('recent');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Take appropriate action when the user clicks on a cell
|
|
|
|
table.on('click-cell.bs.table', processClicks);
|
2020-12-03 09:44:12 +08:00
|
|
|
|
|
|
|
// Some toolbar events break the thumbnail animation, so re-init eventlistener
|
|
|
|
table.on('all.bs.table', initThumbAnimation);
|
|
|
|
|
|
|
|
// Update table links each time after new data is loaded
|
|
|
|
table.on('post-body.bs.table', function(data) {
|
|
|
|
var thumb_ndx = $j('#eventList tr th').filter(function() {
|
|
|
|
return $j(this).text().trim() == 'Thumbnail';
|
|
|
|
}).index();
|
2020-12-05 04:35:39 +08:00
|
|
|
table.find("tr td:nth-child(" + (thumb_ndx+1) + ")").addClass('colThumbnail');
|
2020-12-03 09:44:12 +08:00
|
|
|
});
|
2020-10-23 21:34:35 +08:00
|
|
|
} // initPage
|
2008-07-14 21:54:50 +08:00
|
|
|
|
2021-11-10 03:32:06 +08:00
|
|
|
function watchFullscreen() {
|
2021-11-11 03:22:05 +08:00
|
|
|
const btn = document.getElementById('fullscreenBtn');
|
|
|
|
if (btn.firstElementChild.innerHTML=='fullscreen') {
|
|
|
|
const content = document.getElementById('content');
|
|
|
|
openFullscreen(content);
|
|
|
|
btn.firstElementChild.innerHTML='fullscreen_exit';
|
|
|
|
btn.setAttribute('title', translate["Exit Fullscreen"]);
|
|
|
|
} else {
|
|
|
|
closeFullscreen();
|
|
|
|
btn.firstElementChild.innerHTML='fullscreen';
|
|
|
|
btn.setAttribute('title', translate["Fullscreen"]);
|
|
|
|
}
|
2021-11-10 03:32:06 +08:00
|
|
|
}
|
|
|
|
|
2021-12-11 04:34:35 +08:00
|
|
|
var intervalId;
|
|
|
|
var secondsToCycle = 0;
|
|
|
|
|
|
|
|
function nextCycleView() {
|
|
|
|
secondsToCycle --;
|
|
|
|
if (secondsToCycle<=0) {
|
|
|
|
window.location.replace('?view=watch&mid='+nextMid+'&mode='+mode+'&cycle=true');
|
|
|
|
}
|
|
|
|
$j('#secondsToCycle').text(secondsToCycle);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cyclePause() {
|
|
|
|
clearInterval(intervalId);
|
|
|
|
$j('#cyclePauseBtn').hide();
|
|
|
|
$j('#cyclePlayBtn').show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cycleStart() {
|
|
|
|
secondsToCycle = $j('#cyclePeriod').val();
|
|
|
|
intervalId = setInterval(nextCycleView, 1000);
|
|
|
|
$j('#cyclePauseBtn').show();
|
|
|
|
$j('#cyclePlayBtn').hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cycleNext() {
|
|
|
|
monIdx ++;
|
|
|
|
if (monIdx >= monitorData.length) {
|
|
|
|
monIdx = 0;
|
|
|
|
}
|
|
|
|
if (!monitorData[monIdx]) {
|
|
|
|
console.log('No monitorData for ' + monIdx);
|
|
|
|
}
|
|
|
|
window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cyclePrev() {
|
|
|
|
monIdx --;
|
|
|
|
if (monIdx < 0) {
|
|
|
|
monIdx = monitorData.length - 1;
|
|
|
|
}
|
|
|
|
if (!monitorData[monIdx]) {
|
|
|
|
console.log('No monitorData for ' + monIdx);
|
|
|
|
}
|
|
|
|
window.location.replace('?view=watch&cycle=true&mid='+monitorData[monIdx].id+'&mode='+mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
function cyclePeriodChange() {
|
|
|
|
const cyclePeriodSelect = $j('#cyclePeriod');
|
|
|
|
secondsToCycle = cyclePeriodSelect.val();
|
|
|
|
setCookie('zmCyclePeriod', secondsToCycle, 3600);
|
|
|
|
}
|
|
|
|
function cycleToggle(e) {
|
|
|
|
sidebar = $j('#sidebar');
|
|
|
|
button = $j('#cycleToggle');
|
|
|
|
if (sidebar.is(":visible")) {
|
|
|
|
sidebar.hide();
|
|
|
|
setCookie('zmCycleShow', false, 3600);
|
|
|
|
} else {
|
|
|
|
sidebar.show();
|
|
|
|
setCookie('zmCycleShow', true, 3600);
|
|
|
|
}
|
|
|
|
button.toggleClass('btn-secondary');
|
|
|
|
button.toggleClass('btn-primary');
|
|
|
|
}
|
|
|
|
|
2021-12-17 05:38:15 +08:00
|
|
|
function changeRate(e) {
|
|
|
|
const newvalue = $j(e).val();
|
|
|
|
if (1) {
|
|
|
|
var data = {};
|
|
|
|
data.command = CMD_MAXFPS;
|
|
|
|
data.maxfps = newvalue;
|
|
|
|
streamCmdReq(data);
|
|
|
|
} else {
|
|
|
|
streamImage = $j('#liveStream'+monitorData[monIdx].id);
|
|
|
|
const oldsrc = streamImage.attr('src');
|
|
|
|
streamImage.attr('src', ''); // stop streaming
|
|
|
|
console.log(newvalue);
|
|
|
|
if (newvalue == '0') {
|
|
|
|
// Unlimited
|
|
|
|
streamImage.attr('src', oldsrc.replace(/maxfps=\d+/i, 'maxfps=0.00100'));
|
|
|
|
} else {
|
|
|
|
streamImage.attr('src', oldsrc.replace(/maxfps=\d+/i, 'maxfps='+newvalue));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setCookie('zmWatchRate', newvalue, 3600);
|
|
|
|
}
|
|
|
|
|
2008-07-14 21:54:50 +08:00
|
|
|
// Kick everything off
|
2020-10-03 04:46:28 +08:00
|
|
|
$j(document).ready(initPage);
|