Add more functions

This commit is contained in:
2024-11-13 08:35:32 +07:00
parent 1fe4716bab
commit f7f711d3fe
22 changed files with 1307 additions and 294 deletions

View File

@@ -54,7 +54,14 @@ function fill_select(index, values){
*/
let preset = document.getElementById("preset"+index);
preset.innerHTML = "";
if (values!=null && values.length>0){
// add empty option
let option = document.createElement("option");
option.value = "";
option.innerText = "";
preset.appendChild(option);
for (let i = 0; i < values.length; i++) {
const element = values[i];
let option = document.createElement("option");
@@ -108,4 +115,91 @@ function showConfirm() {
icon.classList.remove('fa-eye-slash');
icon.classList.add('fa-eye');
}
}
function save_audio(){
let preset1 = $('#preset1').val();
let preset2 = $('#preset2').val();
let preset3 = $('#preset3').val();
let preset4 = $('#preset4').val();
let preset5 = $('#preset5').val();
if (confirm("Are you sure want to change Audio Preset ?")){
fetch("/setting/audiofile", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams({preset1: preset1, preset2: preset2, preset3: preset3, preset4: preset4, preset5: preset5})
}).then(resp => {
if (resp.status === 200) {
alert("Success");
} else {
resp.text().then(text=>alert("Failed to change Audio Preset : "+text));
}
});
}
}
function save_camera(){
let ip = $('#setting_ip').val();
let port = $('#setting_port').val();
let username = $('#setting_username').val();
let password = $('#setting_password').val();
if (confirm("Are you sure want to change Camera Information ?")){
fetch("/setting/camera", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams({ip: ip, port: port, username: username, password: password})
}).then(resp => {
if (resp.status === 200) {
alert("Success");
} else {
resp.text().then(text => {
alert("Failed to change Camera Information : "+text);
});
}
});
}
}
function save_login(){
let username = $('#login_username').val();
let password = $('#edit_password').val();
let confirmpassword = $('#confirm_password').val();
if (username.length === 0){
alert("Username cannot be empty");
return;
}
if (password.length === 0){
alert("Password cannot be empty");
return;
}
if (password !== confirmpassword){
alert("Password not match");
return;
}
if (confirm("Are you sure want to change Web Login Information ?")){
fetch("/setting/weblogin", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams({username: username, password: password})
}).then(resp => {
if (resp.status === 200) {
alert("Success");
} else {
resp.text().then(text => {
alert("Failed to change Web Login Information : "+text);
});
}
})
}
}