-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXT-Background.js
56 lines (51 loc) · 1.48 KB
/
EXT-Background.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
/******************
* EXT-Background
* ©Bugsounet
* 03/2023
******************/
Module.register("EXT-Background", {
defaults: {
model: "jarvis",
myImage: null
},
notificationReceived (notification, payload, sender) {
if (notification === "GA_READY" ) {
if (sender.name !== "MMM-GoogleAssistant") return;
this.sendSocketNotification("INIT");
this.sendNotification("EXT_HELLO", this.name);
}
if (!sender || (sender.name !== "MMM-GoogleAssistant")) return;
switch(notification) {
case "ASSISTANT_THINK":
case "ASSISTANT_CONTINUE":
case "ASSISTANT_LISTEN":
this.setBackground("listen");
break;
case "ASSISTANT_STANDBY":
this.setBackground("standby");
break;
case "ASSISTANT_REPLY":
this.setBackground("reply");
break;
case "ASSISTANT_HOOK":
case "ASSISTANT_CONFIRMATION":
this.setBackground("confirmation");
break;
case "ASSISTANT_ERROR":
this.setBackground("error");
break;
}
},
setBackground (status) {
let path = "modules/EXT-Background/";
var GA = document.getElementById("GA_DOM");
if (this.config.myImage) path = path + this.config.myImage;
else path = `${path + this.config.model}/${status}.gif?seed=${Date.now()}`;
GA.setAttribute("style", `background-image: url(${path});`);
},
getDom () {
var dom = document.createElement("div");
dom.style.display = "none";
return dom;
}
});