-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-MyWordsRandomed.js
55 lines (51 loc) · 1.32 KB
/
MMM-MyWordsRandomed.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
/* global Module */
/* Magic Mirror
* Module: MMM-MyWordsRandomed
* https://github.com/framboise-pi/MMM-MyWordsRandomed
* Copyright(C) 2020 Cedric Camille Lafontaine http://www.framboise-pi.fr,
* version 0.0.1
*/
Module.register("MMM-MyWordsRandomed",{
// CONFIG
defaults: {
//display_interval: 5000,//ms
fade: 3000,//ms
},
sentence: "loading...",
// CSS
getStyles: function () {
return ["MMM-MyWordsRandomed.css", "font-awesome.css"];
},
//
start: function() {
var self = this;
setInterval(function() {
self.RandomWords();
self.updateDom();
}, this.config.display_interval);
},
//
socketNotificationReceived: function (notification, payload) {
var self = this;
if (notification = "MMM_MyWordsRandomed_done"){
self.sentence = payload;
self.updateDom(this.config.fade);
}
},
RandomWords: function() {
var self = this;
this.sendSocketNotification("MMM_MyWordsRandomed_do");
},
//#end socketNotif - random done
getDom: function() {
var self = this;
var wrapper = document.createElement("div");
//compliments look-like
wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright pre-line";
ihtml = "<div class='container'>"
ihtml += "<div><p class='bottom'>" + self.sentence + "</p></div>"
ihtml += "</div>"
wrapper.innerHTML = ihtml
return wrapper
},
});