adding javascript to store hostname in local storage between restart

This commit is contained in:
Johannes B. Ullrich 2025-02-23 10:55:16 -05:00
parent 8eb38b6c40
commit 47ddf3552f
No known key found for this signature in database
GPG key ID: C7596EC5976E8833

View file

@ -19,8 +19,14 @@ var unsavedChanges = [];
// Set everything up
function bodyOnLoad() {
defaultControlsHTML = document.getElementById("allCamerasContainer").innerHTML;
// prefill camera hostname (or IP address)
document.getElementById("hostnameInput").value = localStorage.getItem("camerahostname_"+ci.toString());
if ( localStorage.getItem("camerasecurity_"+ci.toString()) === 'true' ) {
document.getElementById("secureCheckbox").checked = true
}
}
// Checks the hostname, if it replies successfully then a new BMCamera object
// is made and gets put in the array at ind
function initCamera() {
@ -35,13 +41,16 @@ function initCamera() {
if (response.status < 300) {
// Success, make a new camera, get all relevant info, and populate the UI
cameras[ci] = new BMCamera(hostname, security);
// Save camera hostname and security status in local storage
localStorage.setItem("camerahostname_"+ci, hostname)
localStorage.setItem("camerasecurity_"+ci, security)
cameras[ci].updateUI = updateUIAll;
cameras[ci].active = true;
document.getElementById("connectionErrorSpan").innerHTML = "Connected.";
document.getElementById("connectionErrorSpan").setAttribute("style","color: #6e6e6e;");
} else {
// Something has gone wrong, tell the user
document.getElementById("connectionErrorSpan").innerHTML = response.statusText;
@ -320,7 +329,10 @@ function switchCamera(index) {
document.getElementById("cameraNumberLabel").innerHTML = "CAM"+(ci+1);
document.getElementById("cameraName").innerHTML = "CAMERA NAME";
document.getElementById("hostnameInput").value = localStorage.getItem("camerahostname_"+ci.toString());
if ( localStorage.getItem("camerasecurity_"+ci.toString()) === 'true' ) {
document.getElementById("secureCheckbox").checked = true
}
if (cameras[ci]) {
cameras[ci].active = true;
}