test
This commit is contained in:
@@ -3,14 +3,32 @@ let api_url = "https://timelapse.kerboul.me/api";
|
|||||||
let global_project_list;
|
let global_project_list;
|
||||||
let current_project = "";
|
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 to get data from API
|
||||||
|
|
||||||
function getDataFromApi() {
|
function getDataFromApi() {
|
||||||
const cachedData = localStorage.getItem("project_list");
|
// const cachedData = localStorage.getItem("project_list");
|
||||||
if (cachedData) {
|
// if (cachedData) {
|
||||||
// If the data is in the cache, parse it and return it
|
// // If the data is in the cache, parse it and return it
|
||||||
return Promise.resolve(JSON.parse(cachedData));
|
// return Promise.resolve(JSON.parse(cachedData));
|
||||||
} else {
|
// } else {
|
||||||
// If the data is not in the cache, make the API request
|
// If the data is not in the cache, make the API request
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
url: api_url.concat("/itemsdb"),
|
url: api_url.concat("/itemsdb"),
|
||||||
@@ -21,7 +39,7 @@ function getDataFromApi() {
|
|||||||
localStorage.setItem("project_list", JSON.stringify(data));
|
localStorage.setItem("project_list", JSON.stringify(data));
|
||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to send data to API
|
// Function to send data to API
|
||||||
|
|||||||
@@ -5,13 +5,17 @@ function display_projects() {
|
|||||||
let datas = `<tr>
|
let datas = `<tr>
|
||||||
<th>Id</th>
|
<th>Id</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Status</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr> `;
|
</tr> `;
|
||||||
for (let i = 0; i < global_project_list.rows.length; i++) {
|
for (let i = 0; i < global_project_list.rows.length; i++) {
|
||||||
datas += `<tr>
|
datas += `<tr>
|
||||||
<th>${global_project_list.rows[i].id}</th>
|
<th>${global_project_list.rows[i].id}</th>
|
||||||
<th>${global_project_list.rows[i].name}</th>
|
<th>${global_project_list.rows[i].titre}</th>
|
||||||
<th><button class="project_detail btn btn-primary">détails de ${global_project_list.rows[i].name}</button></th>
|
<th>${formatDate(global_project_list.rows[i].creation)}</th>
|
||||||
|
<th>${global_project_list.rows[i].status}</th>
|
||||||
|
<th><button class="project_detail btn btn-primary">détails de ${global_project_list.rows[i].titre}</button></th>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
}
|
}
|
||||||
table.innerHTML = datas;
|
table.innerHTML = datas;
|
||||||
|
|||||||
Reference in New Issue
Block a user