mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-06 01:13:57 +03:00
The settings code was almost returned to the old form, errors were fixed
This commit is contained in:
parent
727cc1d1e6
commit
ea9931dc83
2 changed files with 110 additions and 114 deletions
|
@ -63,7 +63,7 @@ func SetWallpaper() {
|
|||
|
||||
func StartWallpaper() {
|
||||
type Autostart struct {
|
||||
Autochangewallpaper int `json:"autochangewallpaper"`
|
||||
Wallpaper int `json:"wallpaper"`
|
||||
}
|
||||
|
||||
client := fetch.NewDefault()
|
||||
|
@ -83,7 +83,7 @@ func StartWallpaper() {
|
|||
Logger(err.Error())
|
||||
}
|
||||
|
||||
if AutostartSetWallpaper.Autochangewallpaper == 1 {
|
||||
if AutostartSetWallpaper.Wallpaper == 1 {
|
||||
times := time.Now()
|
||||
t := time.Date(times.Year(), times.Month(), times.Day(), 4, 50, times.Second(), times.Nanosecond(), time.UTC)
|
||||
|
||||
|
|
|
@ -1,127 +1,123 @@
|
|||
$(document).ready(async function() {
|
||||
const data = await getData();
|
||||
|
||||
const $startupSwitch = $("#settings_startupSwitch");
|
||||
const $startupSwitchTogglerName = $("#settings_startupTogglerName");
|
||||
|
||||
const $wallpaperSwitch = $("#settings_autoSetWallpaperSwitch");
|
||||
const $wallpaperSwitchTogglerName = $("#settings_autoSetWallpaperTogglerName");
|
||||
|
||||
if(data["wallpaper"] === 1) {
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
}
|
||||
if(data["startup"] === 1) {
|
||||
$startupSwitch.attr("checked", "true");
|
||||
$startupSwitchTogglerName.text("On");
|
||||
}
|
||||
|
||||
$wallpaperSwitch.click(function() {
|
||||
if(data["wallpaper"] === 1) {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"wallpaper": 0
|
||||
},
|
||||
success: function(data) {
|
||||
if(data["status"]) {
|
||||
$wallpaperSwitchTogglerName.text("Off");
|
||||
$wallpaperSwitch.removeAttr("checked");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"wallpaper": 1
|
||||
},
|
||||
success: function(data) {
|
||||
if(data["status"]) {
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$startupSwitch.click(function() {
|
||||
if(data["startup"] === 1) {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"startup": 0
|
||||
},
|
||||
success: async function(data) {
|
||||
if(data["status"]) {
|
||||
await editStartup(0);
|
||||
|
||||
$startupSwitchTogglerName.text("Off");
|
||||
$startupSwitch.removeAttr("checked");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"startup": 1
|
||||
},
|
||||
success: async function(data) {
|
||||
if(data["status"]) {
|
||||
await editStartup(1);
|
||||
|
||||
$startupSwitchTogglerName.text("On");
|
||||
$startupSwitch.attr("checked", "true");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#createLabelButton").click(function() {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/create/label",
|
||||
type: "POST",
|
||||
success: function (data) {
|
||||
if (data["status"]) {
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to create label");
|
||||
}
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/get/settings",
|
||||
type: "GET",
|
||||
success: function(data) {
|
||||
if (data["wallpaper"] === 1) {
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
}
|
||||
if (data["startup"] === 1) {
|
||||
$startupSwitch.attr("checked", "true");
|
||||
$startupSwitchTogglerName.text("On");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
$wallpaperSwitch.click(async function() {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/get/settings",
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
if (data["wallpaper"] === 1) {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"wallpaper": 0,
|
||||
},
|
||||
success: function (data) {
|
||||
if(data["status"]) {
|
||||
$wallpaperSwitchTogglerName.text("Off");
|
||||
$wallpaperSwitch.removeAttr("checked");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"wallpaper": 1,
|
||||
},
|
||||
success: function (data) {
|
||||
if(data["status"]) {
|
||||
$wallpaperSwitchTogglerName.text("On");
|
||||
$wallpaperSwitch.attr("checked", "true");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
$startupSwitch.click(async function() {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/get/settings",
|
||||
type: "GET",
|
||||
success: function (data) {
|
||||
if (data["startup"] === 1) {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"startup": 0,
|
||||
},
|
||||
success: async function (data) {
|
||||
if (data["status"]) {
|
||||
await editStartup(0);
|
||||
|
||||
$startupSwitchTogglerName.text("Off");
|
||||
$startupSwitch.removeAttr("checked");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
"startup": 1,
|
||||
},
|
||||
success: async function (data) {
|
||||
if (data["status"]) {
|
||||
await editStartup(1);
|
||||
|
||||
$startupSwitchTogglerName.text("On");
|
||||
$startupSwitch.attr("checked", "true");
|
||||
|
||||
toast(data.message);
|
||||
} else {
|
||||
toast("Failed to apply settings.");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function getData() {
|
||||
return fetch("http://localhost:8080/api/get/settings").then(response => response.json()).then(data => {
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
function toast(message) {
|
||||
$(".toast-body").text(message);
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
|
|
Loading…
Reference in a new issue