forked from PLCHome/node-red-contrib-velux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
velux-connection.html
59 lines (58 loc) · 2.3 KB
/
velux-connection.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
<script type="text/x-red" data-template-name="velux-connection">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> <span data-i18n="velux-connection.label.host"></span></label>
<input type="text" id="node-config-input-host" data-i18n="[placeholder]velux-connection.placeholder.host">
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-globe"></i> <span data-i18n="velux-connection.label.password"></span></label>
<input type="password" id="node-config-input-password" data-i18n="[placeholder]velux-connection.placeholder.password">
</div>
<div class="form-row">
<label for="node-config-input-monitor"><i class="fa fa-code"></i> <span data-i18n="velux-connection.label.monitor"></span></label>
<select id="node-config-input-monitor">
<option value="MONITOR" data-i18n="velux-connection.monitor.MONITOR"></option>
<option value="NOMONITOR" data-i18n="velux-connection.monitor.NOMONITOR"></option>
</select>
</div>
</script>
<script type="text/javascript">
function checkIP(val,len=6) {
var part=val.split(".");
var ok=(part.length==len);
for (var i = 0; (i < part.length) && ok; i++) {
ok = ((parseInt(part[i])==part[i]) && part[i]>=0 && part[i]<=255) && ok
}
return ok;
}
RED.nodes.registerType('velux-connection', {
category: 'config',
defaults: {
host: {
value: '',
required: true,
validate: function(val){ var ok = checkIP(val,4);
return ok;
}
},
password: {
value: '',
required: true
},
monitor: {
value: 'MONITOR',
required: true
}
},
label: function() {
return "klf200:"+this.host;
},
oneditprepare: function() {
if (this.monitor === undefined) {
$("#node-config-input-monitor").val("MONITOR");
}
if (!$("#node-config-input-monitor").val()) {
$("#node-config-input-monitor").val("NOMONITOR");
}
}
});
</script>