Handle non-existing elements when monitor type is Website or Local.
parent
07ff3da212
commit
7750eef533
|
@ -270,10 +270,13 @@ function initPage() {
|
||||||
window.location.assign('?view=console');
|
window.location.assign('?view=console');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const form = document.getElementById('contentForm');
|
||||||
|
|
||||||
//manage the Janus settings div
|
//manage the Janus settings div
|
||||||
|
|
||||||
if (document.getElementsByName("newMonitor[JanusEnabled]")) {
|
const janusEnabled = form.elements['newMonitor[JanusEnabled]'];
|
||||||
if (document.getElementsByName("newMonitor[JanusEnabled]")[0].checked) {
|
if (janusEnabled) {
|
||||||
|
if (janusEnabled.checked) {
|
||||||
document.getElementById("FunctionJanusAudioEnabled").hidden = false;
|
document.getElementById("FunctionJanusAudioEnabled").hidden = false;
|
||||||
document.getElementById("FunctionJanusProfileOverride").hidden = false;
|
document.getElementById("FunctionJanusProfileOverride").hidden = false;
|
||||||
document.getElementById("FunctionJanusUseRTSPRestream").hidden = false;
|
document.getElementById("FunctionJanusUseRTSPRestream").hidden = false;
|
||||||
|
@ -285,7 +288,7 @@ function initPage() {
|
||||||
document.getElementById("FunctionJanusRTSPSessionTimeout").hidden = true;
|
document.getElementById("FunctionJanusRTSPSessionTimeout").hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementsByName("newMonitor[JanusEnabled]")[0].addEventListener('change', function() {
|
janusEnabled.addEventListener('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
document.getElementById("FunctionJanusAudioEnabled").hidden = false;
|
document.getElementById("FunctionJanusAudioEnabled").hidden = false;
|
||||||
document.getElementById("FunctionJanusProfileOverride").hidden = false;
|
document.getElementById("FunctionJanusProfileOverride").hidden = false;
|
||||||
|
@ -299,7 +302,7 @@ function initPage() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Janus_Use_RTSP_Restream = document.getElementsByName('newMonitor[Janus_Use_RTSP_Restream]');
|
const Janus_Use_RTSP_Restream = form.elements['newMonitor[Janus_Use_RTSP_Restream]'];
|
||||||
if (Janus_Use_RTSP_Restream.length) {
|
if (Janus_Use_RTSP_Restream.length) {
|
||||||
Janus_Use_RTSP_Restream[0].onclick = Janus_Use_RTSP_Restream_onclick;
|
Janus_Use_RTSP_Restream[0].onclick = Janus_Use_RTSP_Restream_onclick;
|
||||||
console.log("Setup Janus_RTSP_Restream.onclick");
|
console.log("Setup Janus_RTSP_Restream.onclick");
|
||||||
|
@ -309,23 +312,27 @@ function initPage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amcrest API controller
|
// Amcrest API controller
|
||||||
if (document.getElementsByName("newMonitor[ONVIF_Event_Listener]")[0].checked) {
|
const ONVIF_Event_Listener = form.elements['newMonitor[ONVIF_Event_Listener]'];
|
||||||
|
if (ONVIF_Event_Listener) {
|
||||||
|
if (ONVIF_Event_Listener[0].checked) {
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = false;
|
document.getElementById("function_use_Amcrest_API").hidden = false;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = true;
|
document.getElementById("function_use_Amcrest_API").hidden = true;
|
||||||
}
|
}
|
||||||
document.getElementsByName("newMonitor[ONVIF_Event_Listener]")[0].addEventListener('change', function() {
|
ONVIF_Event_Listener[0].addEventListener('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = false;
|
document.getElementById("function_use_Amcrest_API").hidden = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.getElementsByName("newMonitor[ONVIF_Event_Listener]")[1].addEventListener('change', function() {
|
ONVIF_Event_Listener[1].addEventListener('change', function() {
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = true;
|
document.getElementById("function_use_Amcrest_API").hidden = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const monitorPath = document.getElementsByName("newMonitor[Path]")[0];
|
const monitorPath = document.getElementsByName("newMonitor[Path]")[0];
|
||||||
|
if (monitorPath) {
|
||||||
monitorPath.addEventListener('keyup', change_Path); // on edit sync path -> user & pass
|
monitorPath.addEventListener('keyup', change_Path); // on edit sync path -> user & pass
|
||||||
monitorPath.addEventListener('blur', change_Path); // remove fields from path if user & pass equal on end of edit
|
monitorPath.addEventListener('blur', change_Path); // remove fields from path if user & pass equal on end of edit
|
||||||
|
|
||||||
|
@ -338,10 +345,13 @@ function initPage() {
|
||||||
if ( monitorPass.length > 0 ) {
|
if ( monitorPass.length > 0 ) {
|
||||||
monitorPass[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
monitorPass[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (form.elements['newMonitor[Type]'].value == 'WebSite') return;
|
||||||
|
|
||||||
if (parseInt(ZM_OPT_USE_GEOLOCATION)) {
|
if (parseInt(ZM_OPT_USE_GEOLOCATION)) {
|
||||||
if (window.L) {
|
if (window.L) {
|
||||||
const form = document.getElementById('contentForm');
|
if (form.elements['newMonitor[Type]'].value != 'WebSite') {
|
||||||
const latitude = form.elements['newMonitor[Latitude]'].value;
|
const latitude = form.elements['newMonitor[Latitude]'].value;
|
||||||
const longitude = form.elements['newMonitor[Longitude]'].value;
|
const longitude = form.elements['newMonitor[Longitude]'].value;
|
||||||
map = L.map('LocationMap', {
|
map = L.map('LocationMap', {
|
||||||
|
@ -372,6 +382,7 @@ function initPage() {
|
||||||
$j("a[href='#pills-location']").on('shown.bs.tab', function(e) {
|
$j("a[href='#pills-location']").on('shown.bs.tab', function(e) {
|
||||||
map.invalidateSize();
|
map.invalidateSize();
|
||||||
});
|
});
|
||||||
|
} // end if not website
|
||||||
} else {
|
} else {
|
||||||
console.log('Location turned on but leaflet not installed.');
|
console.log('Location turned on but leaflet not installed.');
|
||||||
}
|
}
|
||||||
|
@ -456,18 +467,21 @@ function random_WebColour() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_estimated_ram_use() {
|
function update_estimated_ram_use() {
|
||||||
var width = document.querySelectorAll('input[name="newMonitor[Width]"]')[0].value;
|
const form = document.getElementById('contentForm');
|
||||||
var height = document.querySelectorAll('input[name="newMonitor[Height]"]')[0].value;
|
if (form.elements['newMonitor[Type]'].value == 'WebSite') return;
|
||||||
var colours = document.querySelectorAll('select[name="newMonitor[Colours]"]')[0].value;
|
|
||||||
|
|
||||||
var min_buffer_count = parseInt(document.querySelectorAll('input[name="newMonitor[ImageBufferCount]"]')[0].value);
|
const width = document.querySelectorAll('input[name="newMonitor[Width]"]')[0].value;
|
||||||
|
const height = document.querySelectorAll('input[name="newMonitor[Height]"]')[0].value;
|
||||||
|
const colours = document.querySelectorAll('select[name="newMonitor[Colours]"]')[0].value;
|
||||||
|
|
||||||
|
let min_buffer_count = parseInt(document.querySelectorAll('input[name="newMonitor[ImageBufferCount]"]')[0].value);
|
||||||
min_buffer_count += parseInt(document.querySelectorAll('input[name="newMonitor[PreEventCount]"]')[0].value);
|
min_buffer_count += parseInt(document.querySelectorAll('input[name="newMonitor[PreEventCount]"]')[0].value);
|
||||||
var min_buffer_size = min_buffer_count * width * height * colours;
|
const min_buffer_size = min_buffer_count * width * height * colours;
|
||||||
document.getElementById('estimated_ram_use').innerHTML = 'Min: ' + human_filesize(min_buffer_size);
|
document.getElementById('estimated_ram_use').innerHTML = 'Min: ' + human_filesize(min_buffer_size);
|
||||||
|
|
||||||
var max_buffer_count = parseInt(document.querySelectorAll('input[name="newMonitor[MaxImageBufferCount]"]')[0].value);
|
const max_buffer_count = parseInt(document.querySelectorAll('input[name="newMonitor[MaxImageBufferCount]"]')[0].value);
|
||||||
if (max_buffer_count) {
|
if (max_buffer_count) {
|
||||||
var max_buffer_size = (min_buffer_count + max_buffer_count) * width * height * colours;
|
const max_buffer_size = (min_buffer_count + max_buffer_count) * width * height * colours;
|
||||||
document.getElementById('estimated_ram_use').innerHTML += ' Max: ' + human_filesize(max_buffer_size);
|
document.getElementById('estimated_ram_use').innerHTML += ' Max: ' + human_filesize(max_buffer_size);
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('estimated_ram_use').innerHTML += ' Max: Unlimited';
|
document.getElementById('estimated_ram_use').innerHTML += ' Max: Unlimited';
|
||||||
|
|
Loading…
Reference in New Issue