add auto change wallpaper

This commit is contained in:
Данил 2022-09-19 16:55:29 +03:00
parent 41507c8fc5
commit b9d775eec9
4 changed files with 111 additions and 10 deletions

View file

@ -10,6 +10,10 @@ $.ajax({
$("#autorunSwitch").attr("checked", "true");
$("#autorunText").text("On");
}
if(data["autochangewallpaper"] === 1) {
$("#autosetWallpaperSwitch").attr("checked", "true");
$("#autosetWallpaperText").text("On");
}
}
})
@ -81,4 +85,38 @@ $("#autorunSwitch").click(function(){
}
}
});
})
$("#autosetWallpaperSwitch").click(function(){
$.ajax({
url: "http://localhost:8080/api/get/settings",
type: "GET",
success: function(data){
if(data["autochangewallpaper"] === 1){
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autochangewallpaper: 0
},
success: function(){
$("#autosetWallpaperSwitch").removeAttr("checked");
$("#autosetWallpaperText").text("Off");
}
})
} else {
$.ajax({
url: "http://localhost:8080/api/update/settings",
type: "POST",
data: {
autochangewallpaper: 1
},
success: function(){
$("#autosetWallpaperSwitch").attr("checked", "true");
$("#autosetWallpaperText").text("On");
}
})
}
}
});
})