-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-GmailNotifier.js
48 lines (41 loc) · 1.5 KB
/
MMM-GmailNotifier.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
Module.register("MMM-GmailNotifier", {
defaults: {
clientId: "",
clientSecret: "",
refreshToken: "",
userName: "Your Name",
profileImage: ""
},
start: function() {
this.emailCount = 0;
this.profileImage = this.config.profileImage;
this.sendSocketNotification("CONFIG", this.config);
},
getDom: function() {
var wrapper = document.createElement("div");
if (this.profileImage) {
var imageElement = document.createElement("img");
imageElement.src = this.profileImage;
imageElement.style.borderRadius = "50%";
imageElement.style.width = "100px"; // Adjust size as needed
wrapper.appendChild(imageElement);
}
var nameElement = document.createElement("div");
nameElement.innerHTML = this.config.userName;
wrapper.appendChild(nameElement);
var emailCountElement = document.createElement("div");
emailCountElement.innerHTML = this.emailCount > 0 ? "You have " + this.emailCount + " unread emails" : "";
wrapper.appendChild(emailCountElement);
return wrapper;
},
socketNotificationReceived: function(notification, payload) {
if (notification === "EMAIL_COUNT") {
this.emailCount = payload;
this.updateDom();
}
if (notification === "PROFILE_IMAGE") {
this.profileImage = payload;
this.updateDom();
}
}
});