node-red-contrib-mobius-flow-base 2.5.86-beta.4 → 2.5.86-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,10 +41,29 @@ POSSIBILITY OF SUCH DAMAGE.
41
41
  <option value="object">Object - Resource PVs, URIs and Names</option>
42
42
  </select>
43
43
  </div>
44
- <div class="form-row node-input-resources-container-row">
44
+ <div id="node-input-resources-container-row" class="form-row node-input-resources-container-row">
45
45
  <label for="node-input-resources-container"><i class="fa fa-bars"></i> Resources</label>
46
46
  <ol id="node-input-resources-container"></ol>
47
47
  </div>
48
+
49
+ <div id="instance-search-row">
50
+ <div class="form-row">
51
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
52
+ <input type="text" id="instance-search-hid" style="width:13%;" placeholder="HID">
53
+ <input type="text" id="instance-search-sid" style="width:8%;" placeholder="SID">
54
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
55
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
56
+ <input type="text" id="instance-search-rid" style="width:8%;" placeholder="RID">
57
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
58
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle; color: #CCCCCC"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
59
+ </div>
60
+ </div>
61
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
62
+ <p>Please note: The selection of wildcard '+'
63
+ means a search for a specific instance or resource
64
+ cannot be performed. As such, enter the
65
+ INS and/or RID manually.</p>
66
+ </div>
48
67
  </script>
49
68
 
50
69
  <script type="text/javascript">
@@ -82,6 +101,266 @@ POSSIBILITY OF SUCH DAMAGE.
82
101
  resource.find(".node-input-resource-comment").width(newWidth - 270);
83
102
  }
84
103
 
104
+ let mobiusSrvc = $("#node-input-connection").val();
105
+
106
+ // *** MOBSEARCH *** //
107
+
108
+ $("#instance-search-row").hide();
109
+ $("#wildcard-alert-row").hide();
110
+ $("#node-search-return").addClass('disabled');
111
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
112
+ $("#instance-search-hid").val(response);
113
+ })
114
+
115
+ let globalSubscriptionIndex = 0;
116
+
117
+ let searchObject = {
118
+ hid: '',
119
+ sid: '',
120
+ pid: '',
121
+ ins: '',
122
+ rid: '',
123
+ objects: []
124
+ }
125
+
126
+ //Function to search for RIDs
127
+ function ridSearch (objects, ins) {
128
+ $.getJSON(`mdiscover?mobius=${mobiusSrvc}&uri=${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`, (response) => {
129
+ resList = response.value[0].resources
130
+ ress = ['#'];
131
+ for (let j = 0; j < resList.length; j++) {
132
+ ress.push(`${resList[j].rid} - ${resList[j].name}`)
133
+ }
134
+ $("#instance-search-rid").autocomplete({
135
+ source: ress,
136
+ minLength: 0,
137
+ close: function (event, ui) {
138
+ acceptCheck();
139
+ $("#instance-search-rid").autocomplete('destroy');
140
+ $("#instance-search-rid").val($("#instance-search-rid").val().substring(0, 2));
141
+ searchObject.rid = $("#instance-search-rid").val();
142
+ }
143
+ }).autocomplete('search', '');
144
+ })
145
+ }
146
+
147
+ //Function to search for INSs
148
+ function insSearch (objects, pid) {
149
+ let inss = ['#', '+'];
150
+ for (let i = 0; i < objects.length; i++) {
151
+ if (objects[i].pid === pid) {
152
+ const name = objects[i].resources[1].pv;
153
+ if (name === '') {
154
+ inss.push(objects[i].ins);
155
+ } else {
156
+ inss.push(`${objects[i].ins} - ${name}`);
157
+ }
158
+ }
159
+ }
160
+ $("#instance-search-ins").autocomplete({
161
+ source: inss,
162
+ minLength: 0,
163
+ close: function (event, ui) {
164
+ acceptCheck();
165
+ $("#instance-search-ins").autocomplete('destroy');
166
+ if ($("#instance-search-ins").val().length > 4) {
167
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
168
+ }
169
+ searchObject.ins = $("#instance-search-ins").val();
170
+ }
171
+ }).autocomplete('search', '');
172
+ }
173
+
174
+ //Function to search for PIDs
175
+ function pidsSearch(objects) {
176
+ searchObject.objects = objects;
177
+ let pids = ['#', '+'];
178
+ for (let i = 0; i < objects.length; i++) {
179
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
180
+ }
181
+ pids = [...new Set(pids)];
182
+ $("#instance-search-pid").autocomplete({
183
+ source: pids,
184
+ minLength: 0,
185
+ close: function (event, ui) {
186
+ acceptCheck();
187
+ $("#instance-search-pid").autocomplete('destroy');
188
+ if ($("#instance-search-pid").val().length > 4) {
189
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
190
+ }
191
+ searchObject.pid = $("#instance-search-pid").val();
192
+ }
193
+ }).autocomplete('search', '');
194
+ }
195
+
196
+ //Function to search for SIDs, and then fetch child objects based on selection
197
+ function serviceSearch(response) {
198
+ let services = ['#', '+'];
199
+ for (let i = 0; i < response.length; i++) {
200
+ if (response[i].sid !== '009') {
201
+ services.push(`${response[i].sid} - ${response[i].name}`);
202
+ }
203
+ }
204
+ $("#instance-search-sid").autocomplete({
205
+ source: services,
206
+ minLength: 0,
207
+ close: function (event, ui) {
208
+ acceptCheck();
209
+ $("#instance-search-sid").autocomplete('destroy');
210
+ if ($("#instance-search-sid").val().length > 3) {
211
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
212
+ }
213
+ searchObject.sid = $("#instance-search-sid").val();
214
+ if (searchObject.sid === '+') {
215
+ for (let i = 2; i < services.length; i++) {
216
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
217
+ searchObject.objects = searchObject.objects.concat(objects);
218
+ })
219
+ }
220
+ } else {
221
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
222
+ searchObject.objects = objects;
223
+ })
224
+ }
225
+ }
226
+ }).autocomplete('search', '');
227
+ }
228
+
229
+ //Start a new search
230
+ function startSearch() {
231
+ $("#wildcard-alert-row").hide();
232
+ $("#instance-search-sid").val('');
233
+ $("#instance-search-pid").val('');
234
+ $("#instance-search-ins").val('');
235
+ searchObject.hid = $("#instance-search-hid").val()
236
+ searchObject.sid = '';
237
+ searchObject.pid = '';
238
+ searchObject.ins = '';
239
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
240
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
241
+ .fail((err) => {
242
+ console.log('Some kind of html failure message on service discovery');
243
+ });
244
+ }
245
+ }
246
+
247
+ //Finish a search
248
+ function finishSearch() {
249
+ $("#wildcard-alert-row").hide();
250
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}/${searchObject.rid}`
251
+ if (uri.includes('#')) {
252
+ uri = uri.substring(0,uri.indexOf('#') + 1)
253
+ }
254
+ node.resources[globalSubscriptionIndex].uri = uri;
255
+ updateList()
256
+ $("#node-search-accept").css('color', '#CCCCCC');
257
+ readyToAccept = false;
258
+ $("#node-search-return").addClass('disabled');
259
+ $("#node-search-accept").addClass('disabled');
260
+ $("#node-lookup-instance").removeClass('disabled');
261
+ $("#instance-search-row").hide();
262
+ $("#instance-row").show();
263
+ }
264
+
265
+ //Function to update if accept button is grade out and functions based on conditions of fields
266
+ function acceptCheck() {
267
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '' && $("#instance-search-rid").val() !== '') ||
268
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#' || $("#instance-search-rid").val() === '#') {
269
+ $("#node-search-accept").css('color', '#555555');
270
+ readyToAccept = true;
271
+ } else {
272
+ $("#node-search-accept").css('color', '#CCCCCC');
273
+ readyToAccept = false;
274
+ }
275
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+' && $("#instance-search-ins").val() !== '+') {
276
+ $("#wildcard-alert-row").hide();
277
+ } else {
278
+ $("#wildcard-alert-row").show();
279
+ }
280
+ }
281
+
282
+ // Respond to clicks
283
+ $("#node-lookup-instance").click(function () { //When search button is clicked
284
+ $("#instance-search-sid").val('');
285
+ $("#instance-search-pid").val('');
286
+ $("#instance-search-ins").val('');
287
+ $("#instance-search-rid").val('');
288
+ $("#node-lookup-instance").addClass('disabled');
289
+ $("#node-search-return").removeClass('disabled');
290
+ $("#node-search-accept").removeClass('disabled');
291
+ $("#instance-row").hide();
292
+ $("#instance-search-row").show();
293
+ });
294
+ $("#instance-search-sid").click(function () { //SID field clicked
295
+ $("#instance-search-pid").val('')
296
+ $("#instance-search-ins").val('')
297
+ searchObject.pid = '';
298
+ searchObject.ins = '';
299
+ searchObject.rid = '';
300
+ searchObject.objects = [];
301
+ startSearch();
302
+ })
303
+ $("#instance-search-pid").click(function () { //PID field clicked
304
+ $("#instance-search-ins").val('')
305
+ $("#instance-search-rid").val('')
306
+ searchObject.ins = '';
307
+ searchObject.rid = '';
308
+ if (searchObject.sid !== '') {
309
+ pidsSearch(searchObject.objects);
310
+ }
311
+ })
312
+ $("#instance-search-ins").click(function () { //INS field clicked
313
+ $("#instance-search-rid").val('')
314
+ searchObject.rid = '';
315
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
316
+ insSearch(searchObject.objects, searchObject.pid);
317
+ }
318
+ })
319
+ $("#instance-search-rid").click(function () { //RID clicked
320
+ if (searchObject.ins !== '' && searchObject.ins !== '+' && searchObject.pid !== '+' && searchObject.sid !== '+') {
321
+ ridSearch(searchObject.objects, searchObject.ins);
322
+ }
323
+ });
324
+ $("#node-search-return").click(function () { //Return/Back button clicked
325
+ $("#node-search-return").addClass('disabled');
326
+ $("#node-search-accept").addClass('disabled');
327
+ $("#node-lookup-instance").removeClass('disabled');
328
+ $("#instance-search-row").hide();
329
+ $("#instance-row").show();
330
+ });
331
+ $("#node-search-accept").click(function () { //Accept button clicked
332
+ if (readyToAccept) {
333
+ finishSearch();
334
+ }
335
+ });
336
+
337
+ // Respond to search field changes
338
+ $("#instance-search-hid").change(function () {
339
+ acceptCheck();
340
+ $("#instance-search-sid").val('');
341
+ $("#instance-search-pid").val('');
342
+ $("#instance-search-ins").val('');
343
+ $("#instance-search-rid").val('');
344
+ });
345
+ $("#instance-search-sid").change(function () {
346
+ searchObject.sid = $("#instance-search-sid").val()
347
+ acceptCheck();
348
+ });
349
+ $("#instance-search-pid").change(function () {
350
+ searchObject.pid = $("#instance-search-pid").val()
351
+ acceptCheck();
352
+ });
353
+ $("#instance-search-ins").change(function () {
354
+ searchObject.ins = $("#instance-search-ins").val()
355
+ acceptCheck();
356
+ });
357
+ $("#instance-search-rid").change(function () {
358
+ searchObject.rid = $("#instance-search-rid").val()
359
+ acceptCheck();
360
+ });
361
+
362
+ // *** END MOBSEARCH *** //
363
+
85
364
  /** Create the subs container and populate it */
86
365
  $('#node-input-resources-container').css('min-height', '300px').css('min-width', '450px').editableList ({
87
366
  addButton: "add",
@@ -100,13 +379,38 @@ POSSIBILITY OF SUCH DAMAGE.
100
379
 
101
380
  var row = $('<div>URI</div>').appendTo(container);
102
381
  var uriField = $('<input/>',{class: "node-input-resource-uri", type: "text", style: "width: 200px; margin-left: 5px; text-align: left;"}).appendTo(row);
382
+
383
+ // *** MOBSEARCH *** //
384
+ var searchField = $('<a class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>').appendTo(row);
385
+ // *** END MOBSEARCH *** //
386
+
103
387
  row.append('&nbsp;&nbsp;-&nbsp;');
104
- var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "margin-left: 5px; text-align: left;"}).appendTo(row);
388
+ var commentField = $('<input/>',{class: "node-input-resource-comment", type: "text", style: "width: 120px; margin-left: 5px; text-align: left;"}).appendTo(row);
105
389
 
106
390
  // Populate the new stat
107
391
  uriField.val(resource.uri);
108
392
  commentField.val(resource.comment);
109
- resizeResource(container);
393
+ // resizeResource(container);
394
+
395
+ // *** MOBSEARCH *** //
396
+
397
+ if (!node.resources[i]) {
398
+ node.resources[i] = {uri: '', comment: ''}
399
+ }
400
+
401
+ searchField.click(function () {
402
+ globalSubscriptionIndex = i;
403
+ $('#node-input-resources-container-row').hide();
404
+ $("#instance-search-sid").val('');
405
+ $("#instance-search-pid").val('');
406
+ $("#instance-search-ins").val('');
407
+ $("#instance-search-rid").val('');
408
+ $("#node-search-return").removeClass('disabled');
409
+ $("#node-search-accept").removeClass('disabled');
410
+ $("#instance-search-row").show();
411
+
412
+ });
413
+ // *** END MOBSEARCH *** //
110
414
  },
111
415
  resizeItem: resizeResource
112
416
  });
@@ -115,7 +419,24 @@ POSSIBILITY OF SUCH DAMAGE.
115
419
  if (!node.resources) {
116
420
  node.resources = [resource = {uri: '', comment: ''}];
117
421
  }
118
- // Populate list with all saved filters
422
+
423
+ // *** MOBSEARCH *** //
424
+
425
+ function updateList() {
426
+ $("#node-input-resources-container").editableList('items').each(function (i) {
427
+ let resource = $(this);
428
+ let comment = resource.find(".node-input-resource-comment").val();
429
+ node.resources[i].comment = comment;
430
+ })
431
+ $("#node-input-resources-container").editableList('empty');
432
+ for (let i = 0; i < node.resources.length; i++) {
433
+ let resource = node.resources[i];
434
+ $("#node-input-resources-container").editableList('addItem', resource);
435
+ }
436
+ }
437
+
438
+ // *** END MOBSEARCH *** //
439
+
119
440
  for (let i = 0; i < node.resources.length; i++) {
120
441
  let resource = node.resources[i];
121
442
  $("#node-input-resources-container").editableList('addItem', resource);
@@ -29,9 +29,35 @@ POSSIBILITY OF SUCH DAMAGE.
29
29
  <label for="node-input-connection"><i class="fa fa-globe"></i> MOBiUS</label>
30
30
  <input type="text" id="node-input-connection">
31
31
  </div>
32
- <div class="form-row">
33
- <label for="node-input-mobject"><i class="fa fa-tasks"></i> URI</label>
34
- <input type="text" id="node-input-mobject" placeholder="Object URI (hid/sid/pid/ins)">
32
+ <div id="instance-message-row" class="form-row hidden" style="color:#ff0000" align="center">
33
+ <p>To select a configured object from a drop-down list, <br/>
34
+ please create a MOBiUS connection, deploy the flow, and <br />
35
+ ensure that the node-red-connector service is running. <br />
36
+ Click the Confirm Deploy button if asked.</p>
37
+ </div>
38
+ <div id="instance-row">
39
+ <div class="form-row">
40
+ <label for="node-input-instance"><i class="fa fa-tasks"></i> URI</label>
41
+ <input type="text" id="node-input-instance" style="width:61%;" placeholder="HID/SID/PID/INS (optional name)">
42
+ <a id="node-lookup-instance" class="searchbutton" style="vertical-align: middle"><i id="node-lookup-instance-icon" class="fa fa-search"></i></a>
43
+ </div>
44
+ </div>
45
+ <div id="instance-search-row">
46
+ <div class="form-row">
47
+ <label for="instance-search-sid"><i class="fa fa-tasks"></i> URI</label>
48
+ <input type="text" id="instance-search-hid" style="width:15%;" placeholder="HID">
49
+ <input type="text" id="instance-search-sid" style="width:10%;" placeholder="SID">
50
+ <input type="text" id="instance-search-pid" style="width:10%;" placeholder="PID">
51
+ <input type="text" id="instance-search-ins" style="width:10%;" placeholder="INS">
52
+ <a id="node-search-return" class="searchbutton" style="vertical-align: middle"><i id="node-search-return-icon" class="fa fa-arrow-left"></i></a>
53
+ <a id="node-search-accept" class="searchbutton" style="vertical-align: middle"><i id="node-search-accept-icon" class="fa fa-check"></i></a>
54
+ </div>
55
+ </div>
56
+ <div id="wildcard-alert-row" class="form-row hidden" style="color:#555555" align="center">
57
+ <p>Please note: The selection of wildcard '+'
58
+ means a search for a specific instance or resource
59
+ cannot be performed. As such, enter the
60
+ INS manually.</p>
35
61
  </div>
36
62
  <div class="form-row">
37
63
  <label for="node-input-format"><i class="fa fa-bars"></i> Format</label>
@@ -60,7 +86,7 @@ POSSIBILITY OF SUCH DAMAGE.
60
86
  name: {value: ""},
61
87
  detailedOutput: {value:false},
62
88
  format: {value: "name", required: true},
63
- mobject: {value: "", validate:function(v) {
89
+ instance: {value: "", validate:function(v) {
64
90
  if(v === '') { return true; }
65
91
  let parts = v.split('/');
66
92
  for(let lp = 0; lp < parts.length; lp++) {
@@ -86,12 +112,251 @@ POSSIBILITY OF SUCH DAMAGE.
86
112
  if(this.name) {
87
113
  return this.name;
88
114
  } else {
89
- return this.mobject ? `Get - ${this.mobject}` : "get object";
115
+ return this.instance ? `Get - ${this.instance}` : "get object";
90
116
  }
91
117
  },
92
118
  labelStyle: function() {
93
119
  return this.name ? "node_label_italic":"";
94
120
  },
121
+ oneditprepare: function () {
122
+
123
+ var node = this;
124
+ let mobiusSrvc = $("#node-input-connection").val();
125
+
126
+ $("#instance-search-row").hide();
127
+
128
+ function doesMobiusServiceExist() {
129
+ let srvc = $("#node-input-mobius").val();
130
+ if (srvc === '_ADD_') {
131
+ $("#node-lookup-instance").hide();
132
+ $("#instance-message-row").show();
133
+ } else {
134
+ $("#instance-message-row").hide();
135
+ $("#node-lookup-instance").show();
136
+ }
137
+ }
138
+ doesMobiusServiceExist();
139
+
140
+ $("#node-search-return").addClass('disabled');
141
+
142
+ // *** MOBSEARCH *** //
143
+
144
+ //Inital setup
145
+ $("#instance-search-row").hide();
146
+ $("#wildcard-alert-row").hide();
147
+ $("#node-search-return").addClass('disabled');
148
+ $.getJSON(`mgethid?mobius=${mobiusSrvc}`, function (response) {
149
+ $("#instance-search-hid").val(response);
150
+ })
151
+ let readyToAccept = false;
152
+ let searchObject = {
153
+ hid: $("#instance-search-hid").val(),
154
+ sid: $("#instance-search-sid").val(),
155
+ pid: $("#instance-search-pid").val(),
156
+ ins: $("#instance-search-ins").val(),
157
+ objects: []
158
+ }
159
+
160
+ //Function to search for INSs
161
+ function insSearch (objects, pid) {
162
+ let inss = ['#'];
163
+ for (let i = 0; i < objects.length; i++) {
164
+ if (objects[i].pid === pid) {
165
+ const name = objects[i].resources[1].pv;
166
+ if (name === '') {
167
+ inss.push(objects[i].ins);
168
+ } else {
169
+ inss.push(`${objects[i].ins} - ${name}`);
170
+ }
171
+ }
172
+ }
173
+ $("#instance-search-ins").autocomplete({
174
+ source: inss,
175
+ minLength: 0,
176
+ close: function (event, ui) {
177
+ acceptCheck();
178
+ $("#instance-search-ins").autocomplete('destroy');
179
+ if ($("#instance-search-ins").val().length > 4) {
180
+ $("#instance-search-ins").val($("#instance-search-ins").val().substring(0, 4))
181
+ }
182
+ searchObject.ins = $("#instance-search-ins").val();
183
+ }
184
+ }).autocomplete('search', '');
185
+ }
186
+
187
+ //Function to search for PIDs
188
+ function pidsSearch(objects) {
189
+ searchObject.objects = objects;
190
+ let pids = ['#', '+'];
191
+ for (let i = 0; i < objects.length; i++) {
192
+ pids.push(`${objects[i].pid} - ${objects[i].profileName}`);
193
+ }
194
+ pids = [...new Set(pids)];
195
+ $("#instance-search-pid").autocomplete({
196
+ source: pids,
197
+ minLength: 0,
198
+ close: function (event, ui) {
199
+ acceptCheck();
200
+ $("#instance-search-pid").autocomplete('destroy');
201
+ if ($("#instance-search-pid").val().length > 4) {
202
+ $("#instance-search-pid").val($("#instance-search-pid").val().substring(0, 4))
203
+ }
204
+ searchObject.pid = $("#instance-search-pid").val();
205
+ }
206
+ }).autocomplete('search', '');
207
+ }
208
+
209
+ //Function to search for SIDs, and then fetch child objects based on selection
210
+ function serviceSearch(response) {
211
+ let services = ['#', '+'];
212
+ for (let i = 0; i < response.length; i++) {
213
+ if (response[i].sid !== '009') {
214
+ services.push(`${response[i].sid} - ${response[i].name}`);
215
+ }
216
+ }
217
+ $("#instance-search-sid").autocomplete({
218
+ source: services,
219
+ minLength: 0,
220
+ close: function (event, ui) {
221
+ acceptCheck();
222
+ $("#instance-search-sid").autocomplete('destroy');
223
+ if ($("#instance-search-sid").val().length > 3) {
224
+ $("#instance-search-sid").val($("#instance-search-sid").val().substring(0, 3))
225
+ }
226
+ searchObject.sid = $("#instance-search-sid").val();
227
+ if (searchObject.sid === '+') {
228
+ for (let i = 2; i < services.length; i++) {
229
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${services[i].substring(0, 3)}`, (objects) => {
230
+ searchObject.objects = searchObject.objects.concat(objects);
231
+ })
232
+ }
233
+ } else {
234
+ $.getJSON(`mgetobjects?mobius=${mobiusSrvc}&hid=${searchObject.hid}&sid=${searchObject.sid}`, (objects) => {
235
+ searchObject.objects = objects;
236
+ })
237
+ }
238
+ }
239
+ }).autocomplete('search', '');
240
+ }
241
+
242
+ //Start a new search
243
+ function startSearch() {
244
+ $("#wildcard-alert-row").hide();
245
+ $("#instance-search-sid").val('');
246
+ $("#instance-search-pid").val('');
247
+ $("#instance-search-ins").val('');
248
+ searchObject.hid = $("#instance-search-hid").val()
249
+ searchObject.sid = '';
250
+ searchObject.pid = '';
251
+ searchObject.ins = '';
252
+ if (/((^([0-9A-F]){6}$)|^$)/.test(searchObject.hid)) {
253
+ $.getJSON(`mgetservices?mobius=${mobiusSrvc}&hid=${searchObject.hid}`, serviceSearch)
254
+ .fail((err) => {
255
+ console.log('Some kind of html failure message on service discovery');
256
+ });
257
+ }
258
+ }
259
+
260
+ //Finish a search
261
+ function finishSearch() {
262
+ $("#wildcard-alert-row").hide();
263
+ let uri = `${searchObject.hid}/${searchObject.sid}/${searchObject.pid}/${searchObject.ins}`
264
+ if (uri.includes('#')) {
265
+ uri = uri.substring(0,uri.indexOf('#') + 1)
266
+ }
267
+ $("#node-input-instance").val(uri);
268
+ $("#node-search-accept").css('color', '#CCCCCC');
269
+ readyToAccept = false;
270
+ $("#node-search-return").addClass('disabled');
271
+ $("#node-search-accept").addClass('disabled');
272
+ $("#node-lookup-instance").removeClass('disabled');
273
+ $("#instance-search-row").hide();
274
+ $("#instance-row").show();
275
+ }
276
+
277
+ //Function to update if accept button is grade out and functions based on conditions of fields
278
+ function acceptCheck() {
279
+ if (($("#instance-search-hid").val() !== '' && $("#instance-search-sid").val() !== '' && $("#instance-search-pid").val() !== '' && $("#instance-search-ins").val() !== '') ||
280
+ $("#instance-search-sid").val() === '#' || $("#instance-search-pid").val() === '#' || $("#instance-search-ins").val() === '#') {
281
+ $("#node-search-accept").css('color', '#555555');
282
+ readyToAccept = true;
283
+ } else {
284
+ $("#node-search-accept").css('color', '#CCCCCC');
285
+ readyToAccept = false;
286
+ }
287
+ if ($("#instance-search-sid").val() !== '+' && $("#instance-search-pid").val() !== '+') {
288
+ $("#wildcard-alert-row").hide();
289
+ } else {
290
+ $("#wildcard-alert-row").show();
291
+ }
292
+ }
293
+
294
+ // Respond to clicks
295
+ $("#node-lookup-instance").click(function () { //When search button is clicked
296
+ $("#instance-search-sid").val('');
297
+ $("#instance-search-pid").val('');
298
+ $("#instance-search-ins").val('');
299
+ $("#node-lookup-instance").addClass('disabled');
300
+ $("#node-search-return").removeClass('disabled');
301
+ $("#node-search-accept").removeClass('disabled');
302
+ $("#instance-row").hide();
303
+ $("#instance-search-row").show();
304
+ });
305
+ $("#instance-search-sid").click(function () { //SID field clicked
306
+ $("#instance-search-pid").val('')
307
+ $("#instance-search-ins").val('')
308
+ searchObject.pid = '';
309
+ searchObject.ins = '';
310
+ searchObject.objects = [];
311
+ startSearch();
312
+ })
313
+ $("#instance-search-pid").click(function () { //PID field clicked
314
+ $("#instance-search-ins").val('')
315
+ searchObject.ins = '';
316
+ if (searchObject.sid !== '') {
317
+ pidsSearch(searchObject.objects);
318
+ }
319
+ })
320
+ $("#instance-search-ins").click(function () { //INS field clicked
321
+ if (searchObject.pid !== '' && searchObject.pid !== '+' && searchObject.sid !== '+') {
322
+ insSearch(searchObject.objects, searchObject.pid);
323
+ }
324
+ })
325
+ $("#node-search-return").click(function () { //Return/Back button clicked
326
+ $("#node-search-return").addClass('disabled');
327
+ $("#node-search-accept").addClass('disabled');
328
+ $("#node-lookup-instance").removeClass('disabled');
329
+ $("#instance-search-row").hide();
330
+ $("#instance-row").show();
331
+ });
332
+ $("#node-search-accept").click(function () { //Accept button clicked
333
+ if (readyToAccept) {
334
+ finishSearch();
335
+ }
336
+ });
337
+
338
+ // Respond to search field changes
339
+ $("#instance-search-hid").change(function () {
340
+ acceptCheck();
341
+ $("#instance-search-sid").val('');
342
+ $("#instance-search-pid").val('');
343
+ $("#instance-search-ins").val('');
344
+ });
345
+ $("#instance-search-sid").change(function () {
346
+ searchObject.sid = $("#instance-search-sid").val()
347
+ acceptCheck();
348
+ });
349
+ $("#instance-search-pid").change(function () {
350
+ searchObject.pid = $("#instance-search-pid").val()
351
+ acceptCheck();
352
+ });
353
+ $("#instance-search-ins").change(function () {
354
+ searchObject.ins = $("#instance-search-ins").val()
355
+ acceptCheck();
356
+ });
357
+
358
+ // *** MOBSEARCH *** //
359
+ },
95
360
  oneditsave: function() {
96
361
  if($("#node-input-detailedOutput").prop('checked')) {
97
362
  this.outputs = 3;