This commit is contained in:
anto
2024-10-24 16:05:21 +02:00
parent 87e13baed7
commit 0d19773ebb
2 changed files with 30 additions and 8 deletions

View File

@@ -3,14 +3,32 @@ let api_url = "https://timelapse.kerboul.me/api";
let global_project_list;
let current_project = "";
function formatDate(isoString) {
const date = new Date(isoString);
const options = {
year: "numeric",
month: "long",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZoneName: "short"
};
return date.toLocaleString("en-US", options);
}
const readableString = date.toLocaleString("en-US", options);
console.log(readableString);
// Function to get data from API
function getDataFromApi() {
const cachedData = localStorage.getItem("project_list");
if (cachedData) {
// If the data is in the cache, parse it and return it
return Promise.resolve(JSON.parse(cachedData));
} else {
// const cachedData = localStorage.getItem("project_list");
// if (cachedData) {
// // If the data is in the cache, parse it and return it
// return Promise.resolve(JSON.parse(cachedData));
// } else {
// If the data is not in the cache, make the API request
return $.ajax({
url: api_url.concat("/itemsdb"),
@@ -21,7 +39,7 @@ function getDataFromApi() {
localStorage.setItem("project_list", JSON.stringify(data));
return data;
});
}
// }
}
// Function to send data to API