From 10f19183c7e00e0bd1f9a67b4986d1b643364359 Mon Sep 17 00:00:00 2001
From: Aymeric Henouille <aymeric.henouille.etu@univ-lille.fr>
Date: Tue, 10 Mar 2020 14:53:49 +0100
Subject: [PATCH] add Slidesshow.js

---
 js/Slideshow.js | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 js/Slideshow.js

diff --git a/js/Slideshow.js b/js/Slideshow.js
new file mode 100644
index 0000000..5141568
--- /dev/null
+++ b/js/Slideshow.js
@@ -0,0 +1,29 @@
+export class Slideshow {
+
+    constructor(image, element) {
+        this.images = image.split(',');
+        this.element = element;
+        this._index = 0;
+        this.show(this.images[this._index]);
+    }
+
+    show(image) {
+        this.element.html(`<a href="images/${image}.gif">
+        <img src="images/${image}.gif" /></a>`);
+    }
+
+    next() {
+        this._index = this._index + 1 < this.images.length ? this._index + 1 : 0;
+        this.show(this.images[this._index]);
+    }
+
+    prev() {
+        this._index = this._index - 1 > -1 ? this._index - 1 : this.images.length - 1;
+        this.show(this.images[this._index]);
+    }
+
+    get index() {
+        return this._index;
+    }
+
+}
\ No newline at end of file
-- 
GitLab