mirror of
https://github.com/Starlio-app/Starlio-web.git
synced 2024-11-22 00:36:20 +03:00
Added if there is no error from the api, a notification will appear and the button will change its name
This commit is contained in:
parent
8409cd7b75
commit
2b3b95d697
1 changed files with 103 additions and 73 deletions
|
@ -2,75 +2,16 @@ $.ajax({
|
|||
url: "http://localhost:8080/api/get/settings",
|
||||
type: "GET",
|
||||
success: function(data){
|
||||
if(data["autostart"] === 1) {
|
||||
$("#autorunSwitch").attr("checked", "true");
|
||||
$("#autorunText").text("On");
|
||||
}
|
||||
if(data["autochangewallpaper"] === 1) {
|
||||
$("#autosetWallpaperSwitch").attr("checked", "true");
|
||||
$("#autosetWallpaperText").text("On");
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$("#autorunSwitch").click(function(){
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/get/settings",
|
||||
type: "GET",
|
||||
success: function(data){
|
||||
if(data["autostart"] === 1){
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
autostart: 0
|
||||
},
|
||||
success: function(){
|
||||
$.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 {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
autostart: 1
|
||||
},
|
||||
success: function(){
|
||||
$.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");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
if(data["startup"] === 1) {
|
||||
$("#startupSwitch").attr("checked", "true");
|
||||
$("#startupText").text("On");
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$("#autosetWallpaperSwitch").click(function(){
|
||||
$.ajax({
|
||||
|
@ -84,11 +25,18 @@ $("#autosetWallpaperSwitch").click(function(){
|
|||
data: {
|
||||
autochangewallpaper: 0
|
||||
},
|
||||
success: function(){
|
||||
success: function(data){
|
||||
if(data.status) {
|
||||
$("#autosetWallpaperSwitch").removeAttr("checked");
|
||||
$("#autosetWallpaperText").text("Off");
|
||||
|
||||
$(".toast-body").text(data.message);
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
|
@ -96,12 +44,94 @@ $("#autosetWallpaperSwitch").click(function(){
|
|||
data: {
|
||||
autochangewallpaper: 1
|
||||
},
|
||||
success: function(){
|
||||
success: function(data){
|
||||
if(data.status) {
|
||||
$("#autosetWallpaperSwitch").attr("checked", "true");
|
||||
$("#autosetWallpaperText").text("On");
|
||||
}
|
||||
})
|
||||
|
||||
$(".toast-body").text(data.message);
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
} else {
|
||||
$(".toast-body").text("Could not remove the program from autorun.");
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#startupSwitch").click(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: function () {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/del/startup",
|
||||
type: "POST",
|
||||
success: function(data){
|
||||
if(data.status) {
|
||||
$("#startupSwitch").removeAttr("checked");
|
||||
$("#startupText").text("Off");
|
||||
|
||||
$(".toast-body").text(data.message);
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
} else {
|
||||
$(".toast-body").text("Failed to apply settings.");
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/settings",
|
||||
type: "POST",
|
||||
data: {
|
||||
startup: 1
|
||||
},
|
||||
success: function () {
|
||||
$.ajax({
|
||||
url: "http://localhost:8080/api/update/set/startup",
|
||||
type: "POST",
|
||||
success: function(data){
|
||||
if(data.status) {
|
||||
$("#startupSwitch").attr("checked", "true");
|
||||
$("#startupText").text("On");
|
||||
|
||||
$(".toast-body").text(data.message);
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
} else {
|
||||
$(".toast-body").text("Failed to apply settings.");
|
||||
let toastLiveExample = document.getElementById('liveToast');
|
||||
let toast = new bootstrap.Toast(toastLiveExample);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue