-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMM-Patch-Notes.js
68 lines (56 loc) · 1.56 KB
/
MMM-Patch-Notes.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
/* global Module */
/* Magic Mirror
* Module: MMM-Patch-Notes
*
* By Kyle Stadelmann and Gary Chew
*/
Module.register('MMM-Patch-Notes',
{
defaults:
{
},
start: function()
{
Log.info('Starting module: ' + this.name);
this.sendSocketNotification('START', this.config);
this.patch = null;
},
getStyles: function() {
return ["MMM-Patch-Notes.css"]
},
getDom: function() {
const wrapper = document.createElement("div");
wrapper.id = "patchNotesContainer";
if (this.patch) {
const gameTitle = document.createElement("h2");
gameTitle.id = "gameTitle";
gameTitle.innerHTML = this.patch.gameTitle;
wrapper.appendChild(gameTitle);
const version = document.createElement("h2");
version.id = "patchVersion";
version.innerHTML = this.patch.date + ' - ' + this.patch.version;
wrapper.appendChild(version);
const img = document.createElement("IMG");
img.id = "gameImage";
img.setAttribute('src', this.patch.img);
img.setAttribute("width", "150");
img.setAttribute("height", "150");
wrapper.appendChild(img);
const description = document.createElement("h3");
description.id = "moduleDescription";
description.innerHTML = '(Latest patch)';
wrapper.appendChild(description);
const body = document.createElement("div");
body.id = "patchBody";
body.innerHTML = this.patch.body;
wrapper.appendChild(body);
}
return wrapper;
},
socketNotificationReceived: function(notification, payload) {
if (notification === "UPDATE_PATCH_NOTES") {
this.patch = payload;
this.updateDom(1000);
}
}
});