-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMagicModule.js
52 lines (44 loc) · 1.39 KB
/
MagicModule.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
/* global Module */
/* Magic Mirror
* Module: MagicModule
*
* By Niklas Drössler, Simon Stauss.
*/
Module.register("MagicModule", {
defaults: {
fadeInDuration: 2000,
fadeOutDuration: 4000
},
requiresVersion: "2.17.0",
getDom: function () {
// Create a div with the overlay class to span the entire page as an overlay
let wrapper = document.createElement("div");
wrapper.className = "overlay";
return wrapper;
},
getStyles: function () {
// Return the needed css file
return [
"MagicModule.css"
];
},
start: function () {
// Establish a connection to the node_helper
// This is necessary in order for the refresh system to work
this.sendSocketNotification("Establish connection to helper");
},
socketNotificationReceived: function (notification, payload) {
if (notification === "refresh") {
// Start showing module and refresh the page after the fade
this.show(this.config.fadeInDuration, function () {
location.reload();
});
}
},
notificationReceived: function (notification, payload, sender) {
if (!sender && notification === "DOM_OBJECTS_CREATED") {
// Fade module out once every dom is created
this.hide(this.config.fadeOutDuration);
}
}
});