38 lines
665 B
JavaScript
38 lines
665 B
JavaScript
var counter = 0;
|
|
|
|
async function reloadSlide() {
|
|
const req = await fetch(`./slide/${counter}.html`)
|
|
if(req.status != 200) return false;
|
|
container.innerHTML = await req.text();
|
|
return true;
|
|
}
|
|
|
|
async function nextSlide() {
|
|
counter++;
|
|
if(!await reloadSlide()) counter--;
|
|
}
|
|
|
|
async function previousSlide() {
|
|
counter--;
|
|
if(!await reloadSlide()) counter++;
|
|
}
|
|
|
|
document.body.addEventListener('click', nextSlide);
|
|
|
|
document.addEventListener(
|
|
"keydown",
|
|
(event) => {
|
|
if(event.key === "ArrowRight") {
|
|
nextSlide();
|
|
return;
|
|
}
|
|
if(event.key === "ArrowLeft") {
|
|
previousSlide();
|
|
return;
|
|
}
|
|
},
|
|
false,
|
|
);
|
|
|
|
nextSlide();
|