function display_metrics(metrics_datas) { // Get data from API and then generate HTML code to display the data in a table const table = document.getElementById("table-metrics"); let datas = ` Date Température Hygrométrie `; for (let i = 0; i < metrics_datas.length; i++) { datas += ` ${formatDate(metrics_datas[i].date_metrique)} ${metrics_datas[i].temperature} ${metrics_datas[i].hygrometrie} `; } table.innerHTML = datas; } // function display_metrics(images_datas) { // // Get data from API and then generate HTML code to display the data in a table // const table_image = document.getElementById("table-image"); // let datas = ` // Images // `; // for (let i = 0; i < images_datas.length; i+=3) { // if(i+2 // ${images_datas[i]} // ${images_datas[i+1]} // ${images_datas[i+2]} // `; // } // table_image.innerHTML = datas; // } document.addEventListener("DOMContentLoaded", () => { const urlParams = new URLSearchParams(window.location.search); const projectId = urlParams.get("id"); getDataProjectMetricsFromApi(projectId) .then(project_metrics => { display_metrics(project_metrics); }) .catch(error => { console.error(error); }); document.getElementById("projets").addEventListener("click", () => { window.location.href = "../index.html"; current_project=""; }); global_project_list=JSON.parse(localStorage.getItem("project_list")); document.getElementById("name_project").innerHTML=global_project_list[projectId-1].titre; fetch("https://timelapse.kerboul.me/api/smile") .then(response => response.blob()) .then(blob => { const url = URL.createObjectURL(blob); const imageElement = document.getElementById("my-image"); imageElement.src = url; }); });