-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMMM-catfact.js
More file actions
30 lines (29 loc) · 900 Bytes
/
MMM-catfact.js
File metadata and controls
30 lines (29 loc) · 900 Bytes
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
Module.register('MMM-catfact', {
defaults: {
text: '',
maxlength: 40,
fadespeed: 2000,
updatespeed: 10000,
size: 'small'
},
start: function () {
setTimeout(() => {
this.sendSocketNotification('run', this.config.maxlength);
setInterval(() => {
this.sendSocketNotification('run', this.config.maxlength);
}, this.config.updatespeed);
}, 1000);
},
getDom: function () {
let wrapper = document.createElement('div');
wrapper.className = `normal ${this.config.size} light`;
wrapper.innerHTML = this.config.text;
return wrapper;
},
socketNotificationReceived: function (n, p) {
if (n === 'sent') {
this.config.text = p;
this.updateDom(this.config.fadespeed);
}
}
});