function left(){ if(index - 1 >= 0){ index -= 1; } else { index = src.length - 1; } load(); } function right(){ if(index + 1 < src.length ){ index += 1; } else { index = 0; } load(); } function load(){ document.getElementById("mainFrame").setAttribute("src", "../assets/screenshots/miniature/" + src[index]); document.getElementById("mainFrame").setAttribute("alt", src[index].split("-")[0] + ", prise le " + getDate(src[index].split("-")[1])); document.getElementById("desc").innerHTML = src[index].split("-")[0] + ", prise le " + getDate(src[index].split("-")[1]) + " - Image orignale"; } function getDate(string){ return string.substring(6, 8) + "/" + string.substring(4, 6) + "/" + string.substring(0, 4) } var src = []; var index = 0; fetch("../assets/screenshots/list") .then((res) => res.text()) .then((text) => { src = text.split("\n"); src.pop(-1); }) .catch((e) => console.error(e));