2023-09-25 16:37:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
const container = document.getElementById("new-parameters");
|
|
|
|
const content1 = document.getElementById("parameters");
|
|
|
|
const content2 = document.getElementById("ethernet");
|
|
|
|
const content3 = document.getElementById("wifi");
|
|
|
|
const content4 = document.getElementById("communication");
|
|
|
|
const content5 = document.getElementById("install");
|
2023-09-26 17:57:39 +00:00
|
|
|
const content6 = document.getElementById("ai");
|
|
|
|
const content7 = document.getElementById("cameras");
|
2023-09-25 16:37:21 +00:00
|
|
|
const radioButtons = document.querySelectorAll(
|
|
|
|
'input[type="radio"][name="newStage"]'
|
|
|
|
);
|
|
|
|
const duration = 100;
|
|
|
|
|
|
|
|
let activeContent = content1;
|
|
|
|
|
|
|
|
function switchContent(newContent) {
|
|
|
|
fadeOut(activeContent, () => {
|
|
|
|
fadeIn(newContent);
|
|
|
|
activeContent = newContent;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function fadeIn(element) {
|
|
|
|
element.style.opacity = 0;
|
|
|
|
element.style.display = "block";
|
|
|
|
let start = performance.now();
|
|
|
|
|
|
|
|
function animate(time) {
|
|
|
|
let timeFraction = (time - start) / duration;
|
|
|
|
if (timeFraction > 1) {
|
|
|
|
element.style.opacity = 1;
|
|
|
|
} else {
|
|
|
|
element.style.opacity = timeFraction;
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
}
|
|
|
|
|
|
|
|
function fadeOut(element, callback) {
|
|
|
|
element.style.opacity = 1;
|
|
|
|
let start = performance.now();
|
|
|
|
|
|
|
|
function animate(time) {
|
|
|
|
let timeFraction = (time - start) / duration;
|
|
|
|
if (timeFraction > 1) {
|
|
|
|
element.style.opacity = 0;
|
|
|
|
element.style.display = "none";
|
|
|
|
if (callback) {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
element.style.opacity = 1 - timeFraction;
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
requestAnimationFrame(animate);
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:45:53 +00:00
|
|
|
var givenData;
|
2023-09-26 17:57:39 +00:00
|
|
|
var camerasData;
|
2023-09-25 16:37:21 +00:00
|
|
|
|
2023-09-26 09:45:38 +00:00
|
|
|
function encodeCHValue(channels) {
|
|
|
|
let CH = 0;
|
|
|
|
for (const channelNumber of channels) {
|
|
|
|
if (channelNumber >= 1 && channelNumber <= 32) {
|
|
|
|
const channelBit = 1 << (channelNumber - 1);
|
|
|
|
CH |= channelBit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return CH;
|
|
|
|
}
|
|
|
|
|
|
|
|
let selectedCameras;
|
|
|
|
|
|
|
|
function checkSelectedCameras() {
|
|
|
|
const checkboxes = document.querySelectorAll('.checkbox-input');
|
|
|
|
selectedCameras = [];
|
|
|
|
|
|
|
|
checkboxes.forEach((checkbox) => {
|
|
|
|
if (checkbox.checked) {
|
|
|
|
const cameraNumber = checkbox.id.replace('camera', '');
|
|
|
|
selectedCameras.push(cameraNumber);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function decodeCHValue(CH) {
|
|
|
|
const channels = [];
|
|
|
|
for (let i = 0; i < 32; i++) {
|
|
|
|
const channelBit = (CH >> i) & 1;
|
|
|
|
if (channelBit === 1) {
|
|
|
|
const channelNumber = i + 1;
|
|
|
|
channels.push(channelNumber);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return channels;
|
|
|
|
}
|
|
|
|
|
2023-09-25 16:37:21 +00:00
|
|
|
for (let radioButton of radioButtons) {
|
|
|
|
radioButton.addEventListener("change", () => {
|
|
|
|
if (radioButton.value === "parameters") {
|
|
|
|
switchContent(content1);
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/device-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
|
|
|
document.getElementById('system-date').value = data.DATA.TIMEP.DATEM;
|
|
|
|
document.getElementById('system-time').value = data.DATA.TIMEP.TIMEM;
|
|
|
|
document.getElementById('system-language').value = data.DATA.GSP.LANT;
|
|
|
|
document.getElementById('system-timezone').value = data.DATA.TIMEP.TIMEZ;
|
|
|
|
document.getElementById('system-geo').value = data.DATA.GSP.GM;
|
|
|
|
document.getElementById('NE').checked = data.DATA.EOSD[0].NE === 1;
|
|
|
|
document.getElementById('TE').checked = data.DATA.EOSD[0].TE === 1;
|
|
|
|
document.getElementById('VE').checked = data.DATA.EOSD[0].VE === 1;
|
|
|
|
document.getElementById('SE').checked = data.DATA.EOSD[0].SE === 1;
|
|
|
|
document.getElementById('GE').checked = data.DATA.EOSD[0].GE === 1;
|
|
|
|
document.getElementById('DE').checked = data.DATA.EOSD[0].DE === 1;
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
|
|
|
} else if (radioButton.value === "ethernet") {
|
|
|
|
switchContent(content2);
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/ethernet-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
|
|
|
document.getElementById('system-ipmode').value = data.DATA.ETHERNET.IPMODE;
|
|
|
|
document.getElementById('system-ipaddr').value = data.DATA.ETHERNET.PIP.IPADDR;
|
|
|
|
document.getElementById('system-submask').value = data.DATA.ETHERNET.PIP.SUBMASK;
|
|
|
|
document.getElementById('system-gateway').value = data.DATA.ETHERNET.PIP.GATEWAY;
|
|
|
|
document.getElementById('system-dnsmode').value = data.DATA.ETHERNET.DNSMODE;
|
|
|
|
document.getElementById('system-pdns').value = data.DATA.ETHERNET.DNS.PDNS;
|
|
|
|
document.getElementById('system-adns').value = data.DATA.ETHERNET.DNS.ADNS;
|
|
|
|
document.getElementById('system-mac').value = data.DATA.KEYS.MAC;
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
|
|
|
} else if (radioButton.value === "wifi") {
|
|
|
|
switchContent(content3);
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/wifi-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
|
|
|
document.getElementById('system-wifi').value = data.DATA.WIFI.ENABLE;
|
|
|
|
document.getElementById('system-wifi-essid').value = data.DATA.WIFI.ESSID;
|
|
|
|
document.getElementById('system-wifi-ecrypttype').value = data.DATA.WIFI.ECRYPTTYPE;
|
|
|
|
document.getElementById('system-wifi-pwd').value = data.DATA.WIFI.PWD;
|
|
|
|
document.getElementById('system-wifi-ipmode').value = data.DATA.WIFI.IPMODE;
|
|
|
|
document.getElementById('system-wifi-ipaddr').value = data.DATA.WIFI.PIP.IPADDR;
|
|
|
|
document.getElementById('system-wifi-submask').value = data.DATA.WIFI.PIP.SUBMASK;
|
|
|
|
document.getElementById('system-wifi-gateway').value = data.DATA.WIFI.PIP.GATEWAY;
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
|
|
|
} else if (radioButton.value === "communication") {
|
|
|
|
switchContent(content4);
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/communication-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
|
|
|
document.getElementById('system-nm1').value = data.DATA.M3G.MP.NM;
|
|
|
|
document.getElementById('system-apn1').value = data.DATA.M3G.MP.APN;
|
|
|
|
document.getElementById('system-un1').value = data.DATA.M3G.MP.UN;
|
|
|
|
document.getElementById('system-pw1').value = data.DATA.M3G.MP.PW;
|
|
|
|
|
|
|
|
document.getElementById('system-nm2').value = data.DATA.M3G.M4G.NM;
|
|
|
|
document.getElementById('system-apn2').value = data.DATA.M3G.M4G.APN;
|
|
|
|
document.getElementById('system-un2').value = data.DATA.M3G.M4G.UN;
|
|
|
|
document.getElementById('system-pw2').value = data.DATA.M3G.M4G.PW;
|
|
|
|
|
|
|
|
document.getElementById('system-at').value = data.DATA.M3G.M3M.AT;
|
|
|
|
document.getElementById('system-tn1').value = data.DATA.M3G.M3M.TN1;
|
|
|
|
document.getElementById('system-tn2').value = data.DATA.M3G.M3M.TN2;
|
|
|
|
document.getElementById('system-tn3').value = data.DATA.M3G.M3M.TN3;
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
|
|
|
} else if (radioButton.value === "install") {
|
|
|
|
switchContent(content5);
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/install-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
2023-09-29 14:08:56 +00:00
|
|
|
console.log(decodeCHValue(data.DATA.MCMS.M));
|
|
|
|
|
2023-09-25 16:37:21 +00:00
|
|
|
clearServerContainer();
|
|
|
|
|
|
|
|
data.DATA.MCMS.SP.forEach((data) => {
|
|
|
|
addServer(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
2023-09-25 21:45:53 +00:00
|
|
|
} else if (radioButton.value === "ai") {
|
2023-09-25 16:37:21 +00:00
|
|
|
switchContent(content6);
|
2023-09-25 21:45:53 +00:00
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/ai-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
2023-09-26 17:57:39 +00:00
|
|
|
document.getElementById("system-ai").value = 0;
|
|
|
|
|
2023-09-25 21:45:53 +00:00
|
|
|
camerasData = data;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
2023-09-26 10:24:42 +00:00
|
|
|
|
|
|
|
document.getElementById('system-ai-dsmfe').value = data.DATA.DSM.DSMFE;
|
|
|
|
document.getElementById('system-ai-rwfe').value = data.DATA.DSM.RWFE;
|
|
|
|
|
|
|
|
|
2023-09-25 21:45:53 +00:00
|
|
|
givenData = data.DATA.DSM.DSMA;
|
|
|
|
|
|
|
|
var desiredCameras;
|
|
|
|
|
|
|
|
function updateCheckboxes() {
|
|
|
|
var checkboxes = document.querySelectorAll('.checkbox-input');
|
|
|
|
|
|
|
|
checkboxes.forEach(function (checkbox) {
|
|
|
|
var cameraNumber = parseInt(checkbox.id.replace('camera', ''), 10);
|
|
|
|
|
|
|
|
checkbox.checked = desiredCameras.includes(cameraNumber);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
let newCH;
|
|
|
|
|
|
|
|
function updateFields(selectedIndex) {
|
|
|
|
const selectedData = givenData[selectedIndex];
|
|
|
|
|
|
|
|
document.getElementById("system-ai-en1").value = selectedData.EN;
|
|
|
|
document.getElementById("system-ai-as1").value = selectedData.AS;
|
|
|
|
document.getElementById("system-ai-ensp1").value = selectedData.APR.ENSP;
|
|
|
|
document.getElementById("system-ai-fgms1").value = selectedData.FGMS;
|
|
|
|
document.getElementById("system-ai-sgms1").value = selectedData.SGMS;
|
|
|
|
document.getElementById("system-ai-esst1").value = selectedData.ESST;
|
|
|
|
document.getElementById("system-ai-udt1").value = selectedData.UDT;
|
|
|
|
document.getElementById("system-ai-vt1").value = selectedData.VT;
|
|
|
|
document.getElementById("system-ai-sdt1").value = selectedData.SDT;
|
|
|
|
document.getElementById("system-ai-et1").value = selectedData.APR.ET;
|
|
|
|
document.getElementById("system-ai-ss-en1").value = selectedData.APR.SS.EN;
|
|
|
|
document.getElementById("system-ai-ar-d1").value = selectedData.APR.AR.D;
|
|
|
|
|
|
|
|
desiredCameras = decodeCHValue(selectedData.APR.AR.CH);
|
|
|
|
updateCheckboxes();
|
|
|
|
|
|
|
|
checkSelectedCameras();
|
|
|
|
newCH = encodeCHValue(selectedCameras);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("system-ai").addEventListener("change", function () {
|
|
|
|
const selectedIndex = parseInt(this.value);
|
|
|
|
updateFields(selectedIndex);
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("checkboxContainer").addEventListener("change", function () {
|
|
|
|
checkSelectedCameras();
|
|
|
|
newCH = encodeCHValue(selectedCameras);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
updateFields(0);
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
2023-09-26 17:57:39 +00:00
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
|
|
|
} else if (radioButton.value === "cameras") {
|
|
|
|
switchContent(content7);
|
|
|
|
document.getElementById('parameters-bg').style.display = 'flex';
|
|
|
|
|
|
|
|
fetch('/cameras-parameters', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify(requestBody)
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
|
|
|
|
|
|
|
document.getElementById('parameters-bg').style.display = 'none';
|
|
|
|
|
|
|
|
document.getElementById("cameras-id").value = 0;
|
|
|
|
|
|
|
|
console.log(data.DATA);
|
|
|
|
|
2023-09-28 22:18:53 +00:00
|
|
|
camerasData = data.DATA.MAIN;
|
2023-09-26 17:57:39 +00:00
|
|
|
|
|
|
|
function updateFields(selectedIndex) {
|
|
|
|
const selectedData = camerasData[selectedIndex];
|
|
|
|
|
|
|
|
document.getElementById("cameras-quality").value = selectedData.QLT;
|
2023-09-29 14:08:56 +00:00
|
|
|
document.getElementById("cameras-bitrate").value = selectedData.BRM;
|
2023-09-26 17:57:39 +00:00
|
|
|
document.getElementById("cameras-video").value = selectedData.RST;
|
|
|
|
document.getElementById("cameras-alert").value = selectedData.ALT;
|
|
|
|
document.getElementById("cameras-ven").value = selectedData.VEN;
|
|
|
|
document.getElementById("cameras-aen").value = selectedData.AEN;
|
|
|
|
document.getElementById("cameras-framerate").value = selectedData.FR;
|
2023-09-29 14:08:56 +00:00
|
|
|
document.getElementById("cameras-encode").value = selectedData.ECT;
|
2023-09-26 17:57:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("cameras-id").addEventListener("change", function () {
|
|
|
|
const selectedIndex = parseInt(this.value);
|
|
|
|
updateFields(selectedIndex);
|
|
|
|
});
|
|
|
|
|
|
|
|
updateFields(0);
|
|
|
|
|
|
|
|
$("select").trigger("input");
|
|
|
|
|
2023-09-25 21:45:53 +00:00
|
|
|
})
|
|
|
|
.catch(error => console.error('Ошибка:', error));
|
2023-09-25 16:37:21 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function truncateText(select) {
|
|
|
|
var maxLength = 30;
|
|
|
|
var option = select.options[select.selectedIndex];
|
|
|
|
if (option.text.length > maxLength) {
|
|
|
|
option.text = option.text.substring(0, maxLength) + "...";
|
|
|
|
}
|
|
|
|
}
|
2023-09-26 09:45:38 +00:00
|
|
|
|
|
|
|
function updateDataInArray() {
|
|
|
|
const selectedIndex = parseInt(document.getElementById("system-ai").value);
|
|
|
|
const selectedDataRow = givenData[selectedIndex];
|
|
|
|
|
|
|
|
selectedDataRow.EN = parseInt(document.getElementById("system-ai-en1").value);
|
|
|
|
selectedDataRow.AS = parseInt(document.getElementById("system-ai-as1").value);
|
|
|
|
selectedDataRow.APR.ENSP = parseInt(document.getElementById("system-ai-ensp1").value);
|
|
|
|
selectedDataRow.FGMS = parseInt(document.getElementById("system-ai-fgms1").value);
|
|
|
|
selectedDataRow.SGMS = parseInt(document.getElementById("system-ai-sgms1").value);
|
|
|
|
selectedDataRow.ESST = parseInt(document.getElementById("system-ai-esst1").value);
|
|
|
|
selectedDataRow.UDT = parseInt(document.getElementById("system-ai-udt1").value);
|
|
|
|
selectedDataRow.VT = parseInt(document.getElementById("system-ai-vt1").value);
|
|
|
|
selectedDataRow.SDT = parseInt(document.getElementById("system-ai-sdt1").value);
|
|
|
|
selectedDataRow.APR.ET = parseInt(document.getElementById("system-ai-et1").value);
|
|
|
|
selectedDataRow.APR.SS.EN = parseInt(document.getElementById("system-ai-ss-en1").value);
|
|
|
|
selectedDataRow.APR.AR.D = parseInt(document.getElementById("system-ai-ar-d1").value);
|
|
|
|
|
|
|
|
selectedDataRow.APR.AR.CH = parseInt(encodeCHValue(selectedCameras));
|
|
|
|
|
|
|
|
givenData[selectedIndex] = selectedDataRow;
|
|
|
|
}
|
2023-09-26 17:57:39 +00:00
|
|
|
|
|
|
|
function updateCamerasInArray() {
|
|
|
|
const selectedIndex = parseInt(document.getElementById("cameras-id").value);
|
|
|
|
const selectedDataRow = camerasData[selectedIndex];
|
|
|
|
|
|
|
|
|
|
|
|
selectedDataRow.QLT = parseInt(document.getElementById("cameras-quality").value);
|
2023-09-29 14:08:56 +00:00
|
|
|
selectedDataRow.BRM = parseInt(document.getElementById("cameras-bitrate").value);
|
2023-09-26 17:57:39 +00:00
|
|
|
selectedDataRow.RST = parseInt(document.getElementById("cameras-video").value);
|
|
|
|
selectedDataRow.ALT = parseInt(document.getElementById("cameras-alert").value);
|
|
|
|
selectedDataRow.VEN = parseInt(document.getElementById("cameras-ven").value);
|
|
|
|
selectedDataRow.AEN = parseInt(document.getElementById("cameras-aen").value);
|
|
|
|
selectedDataRow.FR = parseInt(document.getElementById("cameras-framerate").value);
|
2023-09-29 14:08:56 +00:00
|
|
|
selectedDataRow.ECT = parseInt(document.getElementById("cameras-encode").value);
|
2023-09-26 17:57:39 +00:00
|
|
|
|
|
|
|
camerasData[selectedIndex] = selectedDataRow;
|
|
|
|
}
|