-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnode-red-google-home-notify.html
119 lines (111 loc) · 4.01 KB
/
node-red-google-home-notify.html
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<script type="text/javascript">
RED.nodes.registerType('googlehome-config-node', {
category: 'config',
defaults: {
ipaddress: {
value: "",
required: true
},
name: {
value: ""
},
language: {
value: "en"
}
},
label: function () {
return this.name || this.ipaddress;
},
oneditprepare: function () {
var node = this;
var options = $("#node-input-language");
//Calling the API built by NodeJS code
$.getJSON('/languages', function (languages) {
$.each(languages, function (l, language) {
options.append($("<option />").val(language.key).text(language.value));
options.val(node.language);
});
});
try {
$("#node-config-input-ipaddress").autocomplete( "destroy" );
} catch(err) { }
$("#node-config-lookup-ipaddress").click(function() {
$("#node-config-lookup-ipaddress-icon").removeClass('fa-search');
$("#node-config-lookup-ipaddress-icon").addClass('spinner');
$("#node-config-lookup-ipaddress").addClass('disabled');
$.getJSON('ipaddresses',function(data) {
$("#node-config-lookup-ipaddress-icon").addClass('fa-search');
$("#node-config-lookup-ipaddress-icon").removeClass('spinner');
$("#node-config-lookup-ipaddress").removeClass('disabled');
var ipaddresses = [];
$.each(data, function(i, ip){
ipaddresses.push(ip);
});
$("#node-config-input-ipaddress").autocomplete({
source:ipaddresses,
minLength:0,
close: function( event, ui ) {
$("#node-config-input-ipaddress").autocomplete( "destroy" );
}
}).autocomplete("search","");
});
});
},
oneditsave: function () {
var node = this;
node.language = $("#node-input-language").val();
}
});
</script>
<script type="text/x-red" data-template-name="googlehome-config-node">
<div class="form-row">
<label for="node-config-input-ipaddress"><i class="icon-bookmark"></i> IP Adress</label>
<input type="text" id="node-config-input-ipaddress" style="width:60%;" placeholder="192.168.xxx.xxx"/>
<a id="node-config-lookup-ipaddress" class="btn"><i id="node-config-lookup-ipaddress-icon" class="fa fa-search"></i></a>
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-config-input-name" style="width:60%;" placeholder="Google Home Mini"/>
</div>
<div class="form-row">
<label for="node-input-language"><i class="fa fa-globe"></i> Language</label>
<select id="node-input-language" style="width:60%;">
<option value="en"> English</option>
</select>
</div>
<!-- <div class="form-row">
<label for="node-config-input-language"><i class="icon-bookmark"></i> Language</label>
<input type="text" id="node-config-input-language">
</div> -->
</script>
<!-- ###############################################################################################################-->
<script type="text/x-red" data-template-name="googlehome-notify">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> IP Adress</label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Google Home Notifier" style="width: 70%;">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('googlehome-notify', {
category: 'output',
color: '#fff',
defaults: {
server: {
value: "",
type: "googlehome-config-node"
},
name: {
value: ""
}
},
inputs: 1,
outputs: 0,
label: function () {
return this.configname || this.name || "Google Home Notify";
}
});
</script>