31 lines
789 B
JavaScript
31 lines
789 B
JavaScript
// https://www.w3schools.com/howto/howto_js_slideshow.asp
|
|
|
|
var slideIndex = 1;
|
|
showSlides(slideIndex);
|
|
|
|
// Next/previous controls
|
|
function plusSlides(n) {
|
|
showSlides(slideIndex += n);
|
|
}
|
|
|
|
// Thumbnail image controls
|
|
function currentSlide(n) {
|
|
showSlides(slideIndex = n);
|
|
}
|
|
|
|
function showSlides(n) {
|
|
var i;
|
|
var slides = document.getElementsByClassName("slide");
|
|
var dots = document.getElementsByClassName("slide-dot");
|
|
if(n > slides.length) {slideIndex = 1}
|
|
if(n < 1) {slideIndex = slides.length}
|
|
for(i = 0; i < slides.length; i++) {
|
|
slides[i].style.display = "none";
|
|
}
|
|
for(i = 0; i < dots.length; i++) {
|
|
dots[i].className = dots[i].className.replace(" slide-active", "");
|
|
}
|
|
slides[slideIndex-1].style.display = "block";
|
|
dots[slideIndex-1].className += " slide-active";
|
|
}
|