diff --git a/functions/database.go b/functions/database.go index 4e122c7..7ee635e 100644 --- a/functions/database.go +++ b/functions/database.go @@ -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) } diff --git a/web/static/scripts/switch.js b/web/static/scripts/switch.js index 24f3360..8858059 100644 --- a/web/static/scripts/switch.js +++ b/web/static/scripts/switch.js @@ -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"); + } + } + }) } }) }