-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMMM-SendNotificationButton.js
More file actions
52 lines (45 loc) · 1.73 KB
/
MMM-SendNotificationButton.js
File metadata and controls
52 lines (45 loc) · 1.73 KB
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
/* global Module */
/* MMM-SendNotificationButton.js
*
* Magic Mirror
* Module: MMM-SendNotificationButton
* MIT Licensed.
*
* See README.md for details on this.
*/
Module.register("MMM-SendNotificationButton", {
getStyles: function() {
return [ "MMM-SendNotificationButton.css" ];
},
getDom: function() {
var div = document.createElement("div");
div.className = "sendNotificationButton";
div.appendChild(document.createTextNode("Notification Type:"));
div.appendChild(document.createElement("br"));
var label = document.createElement("input");
div.appendChild(label);
label.id = "sendNotificationButtonLabel";
div.appendChild(document.createElement("br"));
div.appendChild(document.createTextNode("Body / payload:"));
div.appendChild(document.createElement("br"));
var payload = document.createElement("textarea");
div.appendChild(payload);
payload.id = "sendNotificationButtonPayload";
div.appendChild(document.createElement("br"));
var btn = document.createElement("input");
div.appendChild(btn);
btn.type = "button";
btn.value = "Submit";
btn.onclick = event => {
var label = document.getElementById("sendNotificationButtonLabel").value;
var payloadStr = document.getElementById("sendNotificationButtonPayload").value;
if (payloadStr.length > 0) {
var payload = JSON.parse(payloadStr);
this.sendNotification(label, payload); // not sure why this isn't found
} else {
this.sendNotification(label); // not sure why this isn't found
}
};
return div;
}
});