38 lines
977 B
JavaScript
38 lines
977 B
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/photo/miniature/" + src[index]);
|
|
document.getElementById("mainFrame").setAttribute("alt", "Prise le " + getDate(src[index].split(".")[0]));
|
|
document.getElementById("desc").innerHTML = "Prise le " + getDate(src[index].split(".")[0]) + " - <a href=\"../assets/photo/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/photo/list")
|
|
.then((res) => res.text())
|
|
.then((text) => {
|
|
src = text.split("\n");
|
|
src.pop(-1);
|
|
})
|
|
.catch((e) => console.error(e));
|