aboutsummaryrefslogtreecommitdiff
path: root/templates/index.js
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-01-28 16:03:16 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2026-01-28 16:03:16 +0100
commit96373c6d93f0c310f8b777494c5a40c27fd78a0b (patch)
treebfb9825ac80cd2331ede1adc21f84230813a1f22 /templates/index.js
parenta584e47488212c61defe9e266d23eb036c0148e4 (diff)
downloadscratch-gallery-96373c6d93f0c310f8b777494c5a40c27fd78a0b.tar.gz
scratch-gallery-96373c6d93f0c310f8b777494c5a40c27fd78a0b.zip
initial commit
Diffstat (limited to 'templates/index.js')
-rw-r--r--templates/index.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/templates/index.js b/templates/index.js
new file mode 100644
index 0000000..22d8c4e
--- /dev/null
+++ b/templates/index.js
@@ -0,0 +1,33 @@
+let slideIndex = 1;
+
+// Next/previous controls
+function plusSlides(n) {
+ showSlides(slideIndex += n);
+}
+
+// Thumbnail image controls
+function currentSlide(n) {
+ showSlides(slideIndex = n);
+}
+
+function showSlides(n) {
+ let i;
+ let slides = document.getElementsByClassName("mySlides");
+ let dots = document.getElementsByClassName("demo");
+ let captionText = document.getElementById("caption");
+ 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(" active", "");
+ }
+ slides[slideIndex-1].style.display = "block";
+ dots[slideIndex-1].className += " active";
+ captionText.innerHTML = dots[slideIndex-1].alt;
+}
+
+window.onload = function () {
+ showSlides(slideIndex);
+}