-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMMM-Fortunix.js
97 lines (76 loc) · 2.28 KB
/
MMM-Fortunix.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Magic Mirror
* Module: MMM-Fortunix
*
* By Mykle1
*
*/
Module.register("MMM-Fortunix", {
defaults: {
css: "",
useHeader: true,
header: "",
maxWidth: "100%",
animationSpeed: 0,
initialLoadDelay: 0,
retryDelay: 2500,
updateInterval: 60 * 1000,
},
// Gets correct css file from config.js
getStyles: function() {
if(this.config.css != ""){
return ["modules/MMM-Fortunix/css/MMM-Fortunix" + this.config.css + ".css"];
} else {
return ["modules/MMM-Fortunix/css/MMM-Fortunix1.css"]; // default.css
}
},
getScripts: function() {
return ["moment.js"];
},
start: function() {
Log.info("Starting module: " + this.name);
this.uf = {};
this.scheduleUpdate();
},
getDom: function() {
var wrapper = document.createElement("div");
wrapper.className = "wrapper";
wrapper.style.maxWidth = this.config.maxWidth;
if (!this.loaded) {
wrapper.innerHTML = this.translate("Unix wisdom . . .");
wrapper.classList.add("bright", "small");
return wrapper;
}
if (this.config.useHeader != false) {
var header = document.createElement("header");
header.classList.add("small", "bright", "header");
header.innerHTML = this.config.header;
wrapper.appendChild(header);
}
// testing div while trying to get module to load
var wisdom = document.createElement("div");
wisdom.classList.add("small", "bright", "wisdom");
wisdom.innerHTML = this.uf;
wrapper.appendChild(wisdom);
return wrapper;
},
processUF: function(data) {
this.uf = data;
this.loaded = true;
// console.log(this.uf); // for checking in dev console
},
scheduleUpdate: function() {
setInterval(() => {
this.getUF();
}, this.config.updateInterval);
this.getUF();
},
getUF: function() {
this.sendSocketNotification('GET_UF');
},
socketNotificationReceived: function(notification, payload) {
if (notification === "UF_RESULT") {
this.processUF(payload);
}
this.updateDom();
},
});