mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-11-22 08:46:22 +03:00
now requests to the api start_date and end_date are replaced with utc
This commit is contained in:
parent
26d463ce2a
commit
727cc1d1e6
1 changed files with 12 additions and 23 deletions
|
@ -1,8 +1,7 @@
|
||||||
let prev_date = Number(new Date().toLocaleString().slice(0,2))-1;
|
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let endDate = new Date();
|
let endDate = new Date();
|
||||||
|
|
||||||
let ids = [];
|
const ids = [];
|
||||||
let id = 0;
|
let id = 0;
|
||||||
|
|
||||||
const apiKEY = "1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et";
|
const apiKEY = "1gI9G84ZafKDEnrbydviGknReOGiVK9jqrQBE3et";
|
||||||
|
@ -14,28 +13,12 @@ $(document).ready(function() {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: {
|
data: {
|
||||||
api_key: apiKEY,
|
api_key: apiKEY,
|
||||||
start_date: `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`,
|
start_date: `${today.getUTCFullYear()}-${today.getUTCMonth() + 1}-${today.getUTCDate()}`,
|
||||||
end_date: `${new Date().toLocaleString().slice(6, 10)}-${new Date().toLocaleString().slice(3, 5)}-${new Date().toLocaleString().slice(0, 2)}`,
|
end_date: `${endDate.getUTCFullYear()}-${endDate.getUTCMonth() + 1}-${endDate.getUTCDate()}`,
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
wallpaper(data);
|
wallpaper(data);
|
||||||
},
|
},
|
||||||
error: function() {
|
|
||||||
$.ajax({
|
|
||||||
url: "https://api.nasa.gov/planetary/apod",
|
|
||||||
data: {
|
|
||||||
api_key: apiKEY,
|
|
||||||
start_date: `${today.getFullYear()}-${today.getMonth()+1}-${today.getDate()}`,
|
|
||||||
end_date: `${new Date().toLocaleString().slice(6,10)}-${new Date().toLocaleString().slice(3, 5)}-${prev_date}`,
|
|
||||||
},
|
|
||||||
success: function (data) {
|
|
||||||
wallpaper(data);
|
|
||||||
},
|
|
||||||
error: function (data) {
|
|
||||||
console.error(data);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -100,7 +83,13 @@ function wallpaper(data) {
|
||||||
if($(`img#${id}.card-img-top`).attr("src") !== "http://localhost:4662/static/image/placeholder.png") {
|
if($(`img#${id}.card-img-top`).attr("src") !== "http://localhost:4662/static/image/placeholder.png") {
|
||||||
button.innerHTML = `<button type="button" class="btn btn-primary" id="setWallpaper">Set Wallpaper</button>`;
|
button.innerHTML = `<button type="button" class="btn btn-primary" id="setWallpaper">Set Wallpaper</button>`;
|
||||||
} else {
|
} else {
|
||||||
button.innerHTML = `<button type="button" class="btn" id="setWallpaper" disabled style="background-color: grey; color: white;">Set Wallpaper</button>`;
|
button.innerHTML = `<button type="button"
|
||||||
|
class="btn"
|
||||||
|
id="setWallpaper"
|
||||||
|
disabled
|
||||||
|
style="background-color: grey; color: white;">
|
||||||
|
Set Wallpaper
|
||||||
|
</button>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let setWallpaper = document.querySelector("#setWallpaper");
|
let setWallpaper = document.querySelector("#setWallpaper");
|
||||||
|
@ -154,8 +143,8 @@ function wallpaper(data) {
|
||||||
url: "https://api.nasa.gov/planetary/apod",
|
url: "https://api.nasa.gov/planetary/apod",
|
||||||
data: {
|
data: {
|
||||||
api_key: apiKEY,
|
api_key: apiKEY,
|
||||||
start_date: `${endDate.getFullYear()}-${endDate.getMonth() + 1}-${endDate.getDate()}`,
|
start_date: `${endDate.getUTCFullYear()}-${endDate.getUTCMonth() + 1}-${endDate.getUTCDate()}`,
|
||||||
end_date: `${today.getFullYear()}-${today.getMonth() + 1}-${today.getDate()}`,
|
end_date: `${today.getUTCFullYear()}-${today.getUTCMonth() + 1}-${today.getUTCDate()}`,
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
wallpaper(data);
|
wallpaper(data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue