forked from frdteknikelektro/MMM-SimpleLogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-SimpleLogo.js
44 lines (41 loc) · 1.31 KB
/
MMM-SimpleLogo.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
Module.register("MMM-SimpleLogo", {
// Default module config.
defaults: {
text: "Simple Logo",
fileUrl: "modules/MMM-SimpleLogo/public/logo.png",
width: "200px",
position: "left",
refreshInterval: 0
},
start: function() {
if (this.config.refreshInterval > 0) {
var self = this;
var imgsrc = self.config.fileUrl;
setInterval(function() {
img = document.querySelector(".simple-logo__container img[src*='" + imgsrc + "']");
imgsrc = self.config.fileUrl;
if(!imgsrc.includes("?"))
imgsrc += '?' + Date.now();
else
imgsrc += '&' + Date.now();
img.setAttribute('src', imgsrc);
}, this.config.refreshInterval);
}
},
getStyles: function () {
return [
this.file('css/mmm-simplelogo.css')
];
},
// Override dom generator.
getDom: function() {
var wrapper = document.createElement("div");
wrapper.className = 'simple-logo__container';
wrapper.classList.add(this.config.position);
wrapper.style.width = this.config.width;
var img = document.createElement("img");
img.setAttribute('src', this.config.fileUrl);
wrapper.appendChild(img);
return wrapper;
}
});