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,69 +312,77 @@ 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]'];
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = false;
|
if (ONVIF_Event_Listener) {
|
||||||
} else {
|
if (ONVIF_Event_Listener[0].checked) {
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = true;
|
|
||||||
}
|
|
||||||
document.getElementsByName("newMonitor[ONVIF_Event_Listener]")[0].addEventListener('change', function() {
|
|
||||||
if (this.checked) {
|
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = false;
|
document.getElementById("function_use_Amcrest_API").hidden = false;
|
||||||
}
|
} else {
|
||||||
});
|
|
||||||
document.getElementsByName("newMonitor[ONVIF_Event_Listener]")[1].addEventListener('change', function() {
|
|
||||||
if (this.checked) {
|
|
||||||
document.getElementById("function_use_Amcrest_API").hidden = true;
|
document.getElementById("function_use_Amcrest_API").hidden = true;
|
||||||
}
|
}
|
||||||
});
|
ONVIF_Event_Listener[0].addEventListener('change', function() {
|
||||||
|
if (this.checked) {
|
||||||
|
document.getElementById("function_use_Amcrest_API").hidden = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ONVIF_Event_Listener[1].addEventListener('change', function() {
|
||||||
|
if (this.checked) {
|
||||||
|
document.getElementById("function_use_Amcrest_API").hidden = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const monitorPath = document.getElementsByName("newMonitor[Path]")[0];
|
const monitorPath = document.getElementsByName("newMonitor[Path]")[0];
|
||||||
monitorPath.addEventListener('keyup', change_Path); // on edit sync path -> user & pass
|
if (monitorPath) {
|
||||||
monitorPath.addEventListener('blur', change_Path); // remove fields from path if user & pass equal on end of edit
|
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
|
||||||
|
|
||||||
const monitorUser = document.getElementsByName("newMonitor[User]");
|
const monitorUser = document.getElementsByName("newMonitor[User]");
|
||||||
if ( monitorUser.length > 0 ) {
|
if ( monitorUser.length > 0 ) {
|
||||||
monitorUser[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
monitorUser[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
||||||
|
}
|
||||||
|
|
||||||
|
const monitorPass = document.getElementsByName("newMonitor[Pass]");
|
||||||
|
if ( monitorPass.length > 0 ) {
|
||||||
|
monitorPass[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const monitorPass = document.getElementsByName("newMonitor[Pass]");
|
if (form.elements['newMonitor[Type]'].value == 'WebSite') return;
|
||||||
if ( monitorPass.length > 0 ) {
|
|
||||||
monitorPass[0].addEventListener('blur', change_Path); // remove fields from path if user & pass equal
|
|
||||||
}
|
|
||||||
|
|
||||||
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', {
|
||||||
center: L.latLng(latitude, longitude),
|
center: L.latLng(latitude, longitude),
|
||||||
zoom: 8,
|
zoom: 8,
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
alert('click');
|
alert('click');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
L.tileLayer(ZM_OPT_GEOLOCATION_TILE_PROVIDER, {
|
L.tileLayer(ZM_OPT_GEOLOCATION_TILE_PROVIDER, {
|
||||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||||
maxZoom: 18,
|
maxZoom: 18,
|
||||||
id: 'mapbox/streets-v11',
|
id: 'mapbox/streets-v11',
|
||||||
tileSize: 512,
|
tileSize: 512,
|
||||||
zoomOffset: -1,
|
zoomOffset: -1,
|
||||||
accessToken: ZM_OPT_GEOLOCATION_ACCESS_TOKEN,
|
accessToken: ZM_OPT_GEOLOCATION_ACCESS_TOKEN,
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
marker = L.marker([latitude, longitude], {draggable: 'true'});
|
marker = L.marker([latitude, longitude], {draggable: 'true'});
|
||||||
marker.addTo(map);
|
marker.addTo(map);
|
||||||
marker.on('dragend', function(event) {
|
marker.on('dragend', function(event) {
|
||||||
const marker = event.target;
|
const marker = event.target;
|
||||||
const position = marker.getLatLng();
|
const position = marker.getLatLng();
|
||||||
const form = document.getElementById('contentForm');
|
const form = document.getElementById('contentForm');
|
||||||
form.elements['newMonitor[Latitude]'].value = position.lat;
|
form.elements['newMonitor[Latitude]'].value = position.lat;
|
||||||
form.elements['newMonitor[Longitude]'].value = position.lng;
|
form.elements['newMonitor[Longitude]'].value = position.lng;
|
||||||
});
|
});
|
||||||
map.invalidateSize();
|
|
||||||
$j("a[href='#pills-location']").on('shown.bs.tab', function(e) {
|
|
||||||
map.invalidateSize();
|
map.invalidateSize();
|
||||||
});
|
$j("a[href='#pills-location']").on('shown.bs.tab', function(e) {
|
||||||
|
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