forked from PLCHome/node-red-contrib-ads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ads-connection.html
116 lines (115 loc) · 5.46 KB
/
ads-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
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
<script type="text/x-red" data-template-name="ads-connection">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-globe"></i> <span data-i18n="ads-connection.label.host"></span></label>
<input type="text" id="node-config-input-host" data-i18n="[placeholder]ads-connection.placeholder.host">
</div>
<div class="form-row">
<label for="node-config-input-clientIP"><i class="fa fa-globe"></i> <span data-i18n="ads-connection.label.clientIP"></span></label>
<input type="text" id="node-config-input-clientIP" data-i18n="[placeholder]ads-connection.placeholder.clientIP">
</div>
<div class="form-row">
<label for="node-config-input-amsNetIdTarget"><i class="fa fa-globe"></i> <span data-i18n="ads-connection.label.amsNetIdTarget"></span></label>
<input type="text" id="node-config-input-amsNetIdTarget" data-i18n="[placeholder]ads-connection.placeholder.amsNetIdTarget">
</div>
<div class="form-row">
<label for="node-config-input-amsNetIdSource"><i class="fa fa-home"></i> <span data-i18n="ads-connection.label.amsNetIdSource"></span></label>
<input type="text" id="node-config-input-amsNetIdSource" data-i18n="[placeholder]ads-connection.placeholder.amsNetIdSource">
</div>
<div class="form-row">
<label for="node-config-input-port"><i class="fa fa-sign-out"></i> <span data-i18n="ads-connection.label.port"></span></label>
<input type="number" id="node-config-input-port" data-i18n="[placeholder]ads-connection.placeholder.port">
</div>
<div class="form-row">
<label for="node-config-input-amsPortTarget"><i class="fa fa-sign-out"></i> <span data-i18n="ads-connection.label.amsPortTarget"></span></label>
<input type="number" id="node-config-input-amsPortTarget" data-i18n="[placeholder]ads-connection.placeholder.amsPortTarget">
</div>
<div class="form-row">
<label for="node-config-input-amsPortSource"><i class="fa fa-sign-in"></i> <span data-i18n="ads-connection.label.amsPortSource"></span></label>
<input type="number" id="node-config-input-amsPortSource" data-i18n="[placeholder]ads-connection.placeholder.amsPortSource">
</div>
<div class="form-row">
<label for="node-config-input-adsTimeout"><i class="fa fa-times-circle"></i> <span data-i18n="ads-connection.label.adsTimeout"></span></label>
<input type="number" id="node-config-input-adsTimeout" data-i18n="[placeholder]ads-connection.placeholder.adsTimeout">
</div>
</script>
<script type="text/javascript">
function checkIP(val,len=6) {
part=val.split(".");
var ok=(part.length==len);
for (var i = 0; (i < part.length) && ok; i++) {
ok = ok && ((parseInt(part[i])==part[i]) && part[i]>=0 && part[i]<=255)
}
return ok;
}
RED.nodes.registerType('ads-connection', {
category: 'config',
defaults: {
host: {
value: '',
required: true,
validate: function(val){ var ok = checkIP(val,4);
if (ok) {
if ($("#node-config-input-amsNetIdTarget").val() == '') {
$("#node-config-input-amsNetIdTarget").val(val+'.1.1')
}
}
return ok;
}
},
clientIP: {
value: '',
required: false,
validate: function(val){ var ok = (val=="")||checkIP(val,4);
if (ok) {
if ($("#node-config-input-amsNetIdSource").val() == '') {
$("#node-config-input-amsNetIdSource").val(val+'.1.1')
}
}
return ok;
}
},
amsNetIdTarget: {
value: '',
required: true,
validate: function(val){ var ok = checkIP(val,6);
return ok;
}
},
amsNetIdSource: {
value: '',
required: true,
validate: function(val){ var ok = checkIP(val,6);
return ok;
}
},
port: {
value: 48898,
required: true,
validate:RED.validators.number()
},
amsPortSource: {
value: 32905,
required: true,
validate:RED.validators.number()
},
amsPortTarget: {
value: 801,
required: true,
validate:RED.validators.number()
},
adsTimeout: {
value: 500,
required: true,
validate:RED.validators.number()
}
},
label: function() {
return this.amsNetIdSource+":"+this.amsNetIdTarget;
},
oneditprepare: function() {
if (this.adsTimeout === undefined) {
$("#node-config-input-adsTimeout").val("500");
}
}
});
</script>