diff --git a/js/globals.js b/js/globals.js index d021b7c..2b81abe 100644 --- a/js/globals.js +++ b/js/globals.js @@ -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 diff --git a/js/index.js b/js/index.js index 18601be..7e89bdd 100644 --- a/js/index.js +++ b/js/index.js @@ -5,13 +5,17 @@ function display_projects() { let datas = ` Id Name + Date + Status Actions `; for (let i = 0; i < global_project_list.rows.length; i++) { datas += ` ${global_project_list.rows[i].id} - ${global_project_list.rows[i].name} - + ${global_project_list.rows[i].titre} + ${formatDate(global_project_list.rows[i].creation)} + ${global_project_list.rows[i].status} + `; } table.innerHTML = datas;