diff --git a/static/js/carousel.js b/static/js/carousel.js
index 35ba599..043c52e 100644
--- a/static/js/carousel.js
+++ b/static/js/carousel.js
@@ -14,24 +14,26 @@ function checkElement(selector) {
}
var slideIndex = 1;
+var slideIndex2 = 1;
+var slideIndex3 = 1;
// Next/previous controls
-function plusSlides(n, className = "mySlides") {
+function plusSlides(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
console.log("changing slides");
- showSlides(slideIndex += n, className);
+ showSlides(window[counter] += n, className, counter, dotclass);
}
// Thumbnail image controls
-function currentSlide(n, className = "mySlides") {
- showSlides(slideIndex = n, className);
+function currentSlide(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
+ showSlides(window[counter] = n, className, counter, dotclass);
}
-function showSlides(n, className = "mySlides") {
+function showSlides(n, className = "mySlides", counter = "slideIndex", dotclass = "dot") {
var i;
var slides = document.getElementsByClassName(className);
- var dots = document.getElementsByClassName("dot");
- if (n > slides.length) {slideIndex = 1}
+ var dots = document.getElementsByClassName(dotclass);
+ if (n > slides.length) {window[counter] = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
@@ -39,9 +41,9 @@ function showSlides(n, className = "mySlides") {
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" carousel-active", "");
}
- slides[slideIndex-1].style.display = "block";
- dots[slideIndex-1].className += " carousel-active";
-}
+ slides[window[counter]-1].style.display = "block";
+ dots[window[counter]-1].className += " carousel-active";
+}
checkElement('.mySlides') //use whichever selector you want
.then((element) => {
@@ -52,24 +54,13 @@ checkElement('.mySlides') //use whichever selector you want
checkElement('.mySlides2') //use whichever selector you want
.then((element) => {
console.log("sldaldsaldsa");
- showSlides(slideIndex, "mySlides2");
+ showSlides(slideIndex2, "mySlides2", "slideIndex2");
});
checkElement('.mySlides3') //use whichever selector you want
.then((element) => {
console.log("sldaldsaldsa");
- showSlides(slideIndex, "mySlides3");
-});
-
-checkElement('.mySlides4') //use whichever selector you want
-.then((element) => {
- console.log("sldaldsaldsa");
- showSlides(slideIndex, "mySlides4");
+ showSlides(slideIndex3, "mySlides3", "slideIndex3");
});
-checkElement('.mySlides5') //use whichever selector you want
-.then((element) => {
- console.log("sldaldsaldsa");
- showSlides(slideIndex, "mySlides5");
-});