delete autoupdate and lang

This commit is contained in:
Данил 2022-09-21 10:47:08 +03:00
parent 9082744466
commit 7c75974bfe
2 changed files with 30 additions and 47 deletions

View file

@ -20,9 +20,7 @@ func Database() {
if exists == false {
sqlTable := `
CREATE TABLE IF NOT EXISTS settings (
lang TEXT DEFAULT 'en',
autostart INTEGER DEFAULT 0,
autoupdate INTEGER DEFAULT 0,
autochangewallpaper INTEGER DEFAULT 0
);`
_, CreateTableErr := db.Exec(sqlTable)
@ -30,12 +28,12 @@ func Database() {
panic(CreateTableErr)
}
stmt, InsertErr := db.Prepare("INSERT INTO settings(lang, autostart, autoupdate) values(?,?,?)")
stmt, InsertErr := db.Prepare("INSERT INTO settings(autostart, autochangewallpaper) values(?,?)")
if InsertErr != nil {
panic(InsertErr)
}
_, ExecErr := stmt.Exec("en", 0, 0)
_, ExecErr := stmt.Exec(0, 0)
if ExecErr != nil {
panic(ExecErr)
}

View file

@ -2,10 +2,6 @@ $.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autoupdate"] === 1){
$("#updateSwitch").attr("checked", "true");
$("#updateText").text("On");
}
if(data["autostart"] === 1) {
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
@ -18,41 +14,6 @@ $.ajax({
})
$("#updateSwitch").click(function(){
$.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autoupdate"] === 1){
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autoupdate: 0
},
success: function(){
$("#updateSwitch").removeAttr("checked");
$("#updateText").text("Off");
}
})
} else {
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autoupdate: 1
},
success: function(){
$("#updateSwitch").attr("checked", "true");
$("#updateText").text("On");
}
})
}
}
});
})
$("#autorunSwitch").click(function(){
$.ajax({
url: "http://localhost:8080/api/get/settings",
@ -66,8 +27,20 @@ $("#autorunSwitch").click(function(){
autostart: 0
},
success: function(){
$("#autorunSwitch").removeAttr("checked");
$("#autorunText").text("Off");
$.ajax({
url: "http://localhost:8080/api/update/del/startapp",
type: "POST",
success: function(data){
$(".toast-body").text(data.message);
let toastLiveExample = document.getElementById('liveToast')
let toast = new bootstrap.Toast(toastLiveExample)
toast.show()
if(data.status) {
$("#autorunSwitch").removeAttr("checked");
$("#autorunText").text("Off");
}
}
})
}
})
} else {
@ -78,8 +51,20 @@ $("#autorunSwitch").click(function(){
autostart: 1
},
success: function(){
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
$.ajax({
url: "http://localhost:8080/api/update/add/startapp",
type: "POST",
success: function(data){
$(".toast-body").text(data.message);
let toastLiveExample = document.getElementById('liveToast')
let toast = new bootstrap.Toast(toastLiveExample)
toast.show()
if(data.status) {
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
}
}
})
}
})
}