forked from EbenKouao/MMM-Face-Recognition-SMAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-Face-Recognition-SMAI.js
executable file
·86 lines (64 loc) · 1.95 KB
/
MMM-Face-Recognition-SMAI.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Module.register("MMM-Face-Recognition-SMAI", {
defaults: {
prompt: "Use FaceID to access profiles",
fileUrl: "modules/MMM-Face-Recognition-SMAI/public/face.png",
width: "200px",
position: "left",
refreshInterval: 2
},
start: function () {
this.count = 0
},
getStyles: function () {
return [
this.file('css/mmm-style.css')
];
},
getDom: function() {
var element = document.createElement("div")
element.className = "face-image"
element.innerHTML = this.config.prompt
var subElement = document.createElement("p")
subElement.id = "COUNT"
element.appendChild(subElement)
return element
},
//Create Socket Connnection with nodehelper.js
notificationReceived: function(notification, payload, sender) {
switch(notification) {
case "DOM_OBJECTS_CREATED":
var timer = setInterval(()=>{
this.sendSocketNotification("DO_YOUR_JOB", this.count)
this.count++
}, 1000)
break
}
},
//Recieve notification from socket of Python Variables via nodehelper.js
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "I_DID":
//Store Image Here
var elem = document.getElementById("COUNT")
elem.innerHTML = "Welcome back, " + payload
//Creat Image Element Image
elem.classList.add(this.config.position);
elem.style.width = this.config.width;
var img = document.createElement("img");
img.setAttribute('src', this.config.fileUrl);
elem.appendChild(img);
return elem
break;
default:
var elem = document.getElementById("COUNT")
elem.innerHTML = "Welcome back, User"
//Creat Image Element Image
elem.classList.add(this.config.position);
elem.style.width = this.config.width;
var img = document.createElement("img");
img.setAttribute('src', "modules/MMM-Face-Recognition-SMAI/public/guest.gif");
elem.appendChild(img);
return elem
}
},
})