site/js/screenshot.js
2025-04-23 15:59:39 +02:00

38 lines
1 KiB
JavaScript

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]) + " - <a href=\"../assets/screenshots/original/" + src[index] + "\">Image orignale</a>";
}
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));