-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoredDaily.js
67 lines (51 loc) · 1.54 KB
/
BoredDaily.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
/* Magic Mirror
* Module: BoredDaily
*
* By CptMeetKat
* MIT Licensed.
*/
Module.register("BoredDaily", {
// Default module config.
defaults: {
boredURL: "https://www.boredapi.com/api/activity",
updateInterval : 10, //Seconds before changeing
type: "Welcome to BoredDaily!",
text: "New ideas to keep your boring life fresh"
},
start: function() {
this.getActivity();
this.config.updateInterval = this.config.updateInterval * 1000
setInterval(() => {
this.getActivity();
}, this.config.updateInterval);
},
getDom: function() {
var top = document.createElement("div");
top.className = "bored-banner"
top.innerHTML = this.config.type;
var bot = document.createElement("div");
bot.className = "bored-content"
bot.innerHTML = this.config.text;
var wrapper = document.createElement("div");
wrapper.appendChild(top)
wrapper.appendChild(bot)
return wrapper;
},
socketNotificationReceived: function(notification, payload) {
if (notification === "ACTIVITY") {
this.config.type = payload.type.toUpperCase() + ": ";
this.config.text = payload.activity;
this.updateDom(1000);
}
},
getActivity: function() {
Log.info("BORED: Getting activity.");
this.sendSocketNotification("GET_ACTIVITY", {
config: this.config
});
},
// Define required styles.
getStyles: function() {
return ["bored.css"];
}
});