-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMMM-Slideshow.js
53 lines (37 loc) · 1.09 KB
/
MMM-Slideshow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Module.register("MMM-Slideshow", {
// Default module config
defaults: {
text: "This is my slideshow!",
pictures: [
"images/slide01.jpg",
"images/slide02.jpg",
"images/slide03.jpg",
"images/slide04.jpg",
"images/slide05.jpg"
],
// 1000 ms = 1s
updateInterval: 10000,
fadeSpeed: 2000
},
getStyles: function() {
return ["slideshow_style.css"];
},
start: function() {
// Log.info("Starting module: " + this.name);
// Schedule update timer.
var self = this;
setInterval(function() {
self.updateDom(self.config.fadeSpeed);
}, this.config.updateInterval);
},
getDom: function() {
max = 4;
min = 0;
var wrapper = document.createElement("div");
var image = document.createElement("img");
image.className = "slide";
image.src = this.data.path + this.config.pictures[Math.floor(Math.random() * 5)];
wrapper.appendChild(image);
return wrapper;
}
});