-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprops.js
738 lines (622 loc) · 21.7 KB
/
props.js
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
// ------------------------------------------
// In order to suggest existing action/trigger/guard values,
// we need to be able to list all used ones.
// The functions below will help with that.
// ------------------------------------------
function isEmpty(s)
{
if (s=='' || s===undefined) return true;
return false;
}
function arrayAddNonempty(ar,val)
{
if (!isEmpty(val) && jQuery.inArray(val,ar) === -1 ) ar.push(val);
}
function naturalSort(a,b)
{
var splitreg=/(\d+)|(\D+)/g;
var num=/\d+/;
a=a.match(splitreg);
b=b.match(splitreg);
if (!a) a=[];
if (!b) b=[];
while(a.length > 0 && b.length > 0)
{
var wa=a.shift();
var wb=b.shift();
if(num.test(wa) || num.test(wb))
{
if(!num.test(wa)) return 1;
if(!num.test(wb)) return -1;
if(wa!=wb) return wa-wb;
}
else if(wa.toUpperCase()!=wb.toUpperCase()) return wa.toUpperCase()>wb.toUpperCase() ? 1 : -1;
}
return a.length-b.length;
}
// sort array, and return only unique values
function array_unique(ar)
{
var ar=ar.sort(naturalSort);
var res=[];
for (var i=0; i<ar.length; i++)
if (res.length==0 || res[res.length-1]!=ar[i])
res.push(ar[i]);
return res;
}
function array_unique_unsorted(ar)
{
var i;
var unique=[];
for (i=0; i<ar.length; i++)
if (ar[i] && jQuery.inArray(JSON.stringify(ar[i]), unique) === -1)
unique.push(JSON.stringify(ar[i]));
for (i=0; i<unique.length; i++)
unique[i]=JSON_fromString(unique[i]);
return unique;
}
// list all named actions
function listActions(states,connections)
{
var i;
var res=[];
if (!states) states=g.states;
if (!connections) connections=g.connections;
for (i=0; i<states.length; i++)
{
arrayAddNonempty(res,states[i].fwprop.entryFunc);
arrayAddNonempty(res,states[i].fwprop.doFunc);
arrayAddNonempty(res,states[i].fwprop.exitFunc);
}
for (i=0; i<connections.length; i++)
arrayAddNonempty(res,connections[i].fwprop.actionFunc);
return res;
}
// list all named triggers
function listTriggers(connections)
{
var res=[];
if (!connections) connections=g.connections;
for (var i=0; i<connections.length; i++)
arrayAddNonempty(res,connections[i].fwprop.identifier);
return res;
}
// list all named guards
function listGuards(connections)
{
var res=[];
if (!connections) connections=g.connections;
for (var i=0; i<connections.length; i++)
arrayAddNonempty(res,connections[i].fwprop.guardFunc);
return res;
}
function listAllActions()
{
var res=listActions();
var rel=allRelatedSmFilesData();
for (var key in rel)
if (rel[key].data.states && rel[key].data.connections)
res=res.concat(listActions(rel[key].data.states,rel[key].data.connections));
return array_unique(res);
}
function listAllTriggers()
{
var res=listTriggers();
var rel=allRelatedSmFilesData();
for (var key in rel)
if (rel[key].data.states)
res=res.concat(listTriggers(rel[key].data.connections));
return array_unique(res);
}
function listAllGuards()
{
var res=listGuards();
var rel=allRelatedSmFilesData();
for (var key in rel)
if (rel[key].data.states)
res=res.concat(listGuards(rel[key].data.connections));
return array_unique(res);
}
function listAllTags()
{
return g.knownTags;
}
function triggerGetID(trigger)
{
// return the trigger identifier if it is already mapped
if (trigger in g.triggerIDmap) return g.triggerIDmap[trigger];
// if we are here it means trigger was not found. Add it
var next=0;
for (var t in g.triggerIDmap) next=Math.max(next,g.triggerIDmap[t]);
next=next+1;
g.triggerIDmap[trigger]=next;
return next;
}
// ------------------------------------------
// generate auto IDs for triggers, guards, actions and states
// ------------------------------------------
function getNextStateAutoID(type)
{
var i=0;
for(var j=0; j<g.states.length; j++)
if (g.states[j].fwprop.type==type) i=Math.max(i,g.states[j].fwprop.autoid);
return i+1;
}
function getNextActionAutoID()
{
var list=listAllActions();
var i, max=0, m;
for(i=0; i<list.length; i++)
{
m=list[i].match(/^(Action)([0-9]+)$/);
if (m) max=Math.max(max,m[2]);
}
return max+1;
}
function getNextTriggerAutoID()
{
var list=listAllTriggers();
var i, max=0, m;
for(i=0; i<list.length; i++)
{
m=list[i].match(/^(Trigger)([0-9]+)$/);
if (m) max=Math.max(max,m[2]);
}
return max+1;
}
function getNextGuardAutoID()
{
var list=listAllGuards();
var i, max=0, m;
for(i=0; i<list.length; i++)
{
m=list[i].match(/^(Guard)([0-9]+)$/);
if (m) max=Math.max(max,m[2]);
}
return max+1;
}
function getNextOrderID(state)
{
var i,ret=0;
for (i=0; i<g.connections.length; i++)
if (g.connections[i].stateFrom.id==state.id)
ret=Math.max(g.connections[i].fwprop.order,ret);
return ret+1;
}
function countOutgoingTransitions(state)
{
var i,ret=0;
for (i=0; i<g.connections.length; i++)
if (g.connections[i].stateFrom.id==state.id)
ret++;
return ret;
}
// reorder remaining transitions on the stateFrom accordingly.
// The transitions are reordered only numerically (the .order property changes)
// but the physical order remains intact, and the current transition remains with undefined .order
// so it must be always set to newOrder after calling this function
function reorderTransitions(state, prevOrder, newOrder)
{
for(var i=0; i<g.connections.length; i++)
{
if (g.connections[i].stateFrom.id==state.id)
{
if (prevOrder<newOrder)
if (g.connections[i].fwprop.order>prevOrder && g.connections[i].fwprop.order<=newOrder) g.connections[i].fwprop.order--;
if (prevOrder>newOrder)
if (g.connections[i].fwprop.order<prevOrder && g.connections[i].fwprop.order>=newOrder) g.connections[i].fwprop.order++;
}
}
}
// ------------------------------------------
// Properties suggestion
// ------------------------------------------
function propSuggestHighlight(el,scroll)
{
// make all rows unselected
$('#suggest').find("a").css({"background-color":"#fff", "color":"#000"});
// select one row
$(el).css({"background-color":"#6599FF", "color":"#fff"});
// if scrolling is required, do so
if (scroll) $('#suggest').scrollTop($(el).position().top);
}
function propSuggest(ev)
{
var t=this;
var suggest=$(t).attr('data-suggest');
var hig=$(t).val();
if (!suggest) return;
var isP=$(t).hasClass('project');
var list;
if ($(t).is(":focus") && ev.type=='mousedown')
{
if (! $('#suggest').is(":hidden"))
{
propSuggestHide();
return;
}
}
if (suggest=='action') list=listAllActions();
else if (suggest=='trigger') list=listAllTriggers();
else if (suggest=='guard') list=listAllGuards();
else if (suggest=='tags') list=listAllTags();
$('#suggest').attr("data-target",$(this).attr("id"));
$('#suggest').attr("data-isFunction",'Yeah'); // non-empty value means selecting from suggestions replaces entire input
$('#suggest').show().scrollTop(0);
$('#suggest').width($(t).width()+12).html("<a>"+list.join("</a><a>")+"</a>");
$('#suggest').offset({"top": $(t).offset().top + $(t).height()+9+(isP?-2:0), "left": $(t).offset().left });
$('#suggest').find("a").mouseenter(function(){propSuggestHighlight(this);})
$('#suggest').find("a").each(function(higlight){ return function() { if ($(this).html()==higlight) propSuggestHighlight(this,true);} }(hig));
if (list.length==0) propSuggestHide();
if (isP) $('#suggest').addClass('rounded').removeClass('sharp');
else $('#suggest').addClass('sharp').removeClass('rounded');
}
function propSuggestHide()
{
$('#suggest').hide();
$('#suggest').attr("data-target","");
autocompleteHide();
}
function propSuggestSelect(ev)
{
if ($(ev.target).find("a").length==0) // make sure the user clicked on actual element
{
var text=$(ev.target).html();
var target=$('#'+$('#suggest').attr("data-target"));
if ($('#suggest').attr("data-isFunction"))
{
// set value
target.val(text);
// switch to function and trigger change event to hide code block if needed
target.prev("select").val('function').change();
}
else
{
var final=($.trim(target.val())!=''?$.trim(target.val())+", ":"")+text;
target.val(final.replace(new RegExp(text+", *", 'g'), ""));
}
}
propSuggestHide();
propUpdate();
}
function setDisplayInfo(type)
{
g.fwprop.displayInfo=type;
refreshDisplayInfo();
refreshStates();
refreshConnections();
}
function setDisplayOrder(y)
{
g.fwprop.displayOrder=y;
refreshDisplayInfo();
refreshConnections();
}
function refreshDisplayInfo()
{
$('#displayInfo').find('i').addClass('hidden').parent().removeClass("btn-info");
$('#displayInfo'+g.fwprop.displayInfo).removeClass('hidden').show().parent().addClass('btn-info');
$('#displayOrder').find('i').addClass('hidden').parent().removeClass("btn-info");
$('#displayOrder'+g.fwprop.displayOrder).removeClass('hidden').show().parent().addClass('btn-info');
}
function setMemAlloc(type)
{
g.fwprop.memalloc=type;
refreshMemAlloc();
}
function refreshMemAlloc()
{
$('#memalloc').find('i').addClass('hidden').parent().removeClass("btn-info");
$('#memalloc'+g.fwprop.memalloc).removeClass('hidden').parent().addClass('btn-info');
}
// ------------------------------------------
//
// Properties editing
//
// ------------------------------------------
// called on onChange event for SELECT
function propSelectChange(t)
{
var userChanged=true;
if (t.target) t=this; // if called on onChange event
else userChanged=false; // indicates that user changed the <select> value by mouse
var set=$(t).val();
var parent=$(t).parent();
if (parent.is("td")) parent=parent.parent();
if (parent.is("tr")) parent=parent.parent();
if (set.match(/Else/i))
{
parent.find('select').val('run code');
parent.find('textarea').eq(0).val('return 1;');
parent.find('textarea').eq(1).val('Else');
propUpdate();
return propSelectChange(t);
}
if (set.match(/Wait/i))
{
parent.find('select').val('run code');
parent.find('textarea').eq(0).val('return (FwPrGetNodeExecCnt(prDesc) == N);');
parent.find('textarea').eq(1).val('Wait N cycles');
propUpdate();
return propSelectChange(t);
}
if (set.match(/code/)) { $(t).width(269); $(t).next().hide(); }
if (set.match(/function/)) { $(t).width(118); $(t).next().show(); }
if (set=='run code')
if (userChanged) parent.find(".hidden").slideDown(100);
else parent.find(".hidden").show();
if (set=='call function' || set=='define function')
if (userChanged) parent.find(".hidden").slideUp(100);
else parent.find(".hidden").hide();
// in all cases, set font to better suit code needs
parent.find(".hidden").find("textarea").css({'font-size': '11px', 'line-height': '16px', 'font-family': 'monospace'});
if (userChanged) propUpdate();
refreshToolbarButtons();
setTimeout(fixEditboxPos,110);
}
// fill properties for selected state or connection
function propEditFill()
{
if (g.selected.length==1)
{
var state=g.selected[0];
if (state.fwprop.type=='state')
{
$('#epropStateID').val(state.fwprop.identifier);
$('#epropStateNote').val(state.fwprop.note);
$('#epropEntryType').val(state.fwprop.entryType);
$('#epropEntryFunc').val(state.fwprop.entryFunc);
$('#epropEntryCode').val(state.fwprop.entryCode);
$('#epropEntryDesc').val(state.fwprop.entryDesc);
$('#epropEntryAp')[0].checked = state.fwprop.entryAp;
propSelectChange('#epropEntryType');
$('#epropDoType').val(state.fwprop.doType);
$('#epropDoFunc').val(state.fwprop.doFunc);
$('#epropDoCode').val(state.fwprop.doCode);
$('#epropDoDesc').val(state.fwprop.doDesc);
$('#epropDoAp')[0].checked = state.fwprop.doAp;
propSelectChange('#epropDoType');
$('#epropExitType').val(state.fwprop.exitType);
$('#epropExitFunc').val(state.fwprop.exitFunc);
$('#epropExitCode').val(state.fwprop.exitCode);
$('#epropExitDesc').val(state.fwprop.exitDesc);
$('#epropExitAp')[0].checked = state.fwprop.exitAp;
propSelectChange('#epropExitType');
var options='<option value=0>';
if (!userIsSigned()) options+="<option value=0>Sign in to use this feature...";
for (var i=0; i<g.knownFiles.length; i++)
{
if (g.knownFiles[i].editorType==g.fwprop.editorType && g.knownFiles[i].id!=g.internalID)
options+="<option value="+g.knownFiles[i].id+">"+g.knownFiles[i].name;
}
if (editorIsSM())
{
$('#epropEmbedSmId').html(options);
$('#epropEmbedSM').show();
propSelectChange('#epropEmbedSmId');
}
else $('#epropEmbedSM').hide();
$('#epropEmbedSmId').val(state.fwprop.embedSmId);
}
if (state.fwprop.type=='init')
{
$('#epropInitNote').val(state.fwprop.note);
}
if (state.fwprop.type=='note')
{
$('#epropNoteNote').val(state.fwprop.note);
}
if (state.fwprop.type=='final')
{
$('#epropFinalNote').val(state.fwprop.note);
}
if (state.fwprop.type=='choice')
{
$('#epropChoiceID').val(state.fwprop.identifier);
$('#epropChoiceNote').val(state.fwprop.note);
}
return; // stop here
}
if (g.selectedCon)
{
var conn=g.selectedCon;
var options='<option>call function<option>define function<option>run code<option disabled=true>--------------------<option>Else guard';
if (editorIsPR()) options+='<option>Wait N cycles'
$('#epropTrGuardType').html(options);
$('#epropTrigger').val(conn.fwprop.identifier);
$('#epropTrGuardType').val(conn.fwprop.guardType);
$('#epropTrGuardFunc').val(conn.fwprop.guardFunc);
$('#epropTrGuardCode').val(conn.fwprop.guardCode);
$('#epropTrGuardDesc').val(conn.fwprop.guardDesc);
$('#epropTrGuardAp')[0].checked = conn.fwprop.guardAp;
propSelectChange('#epropTrGuardType');
$('#epropTrGuardOrder').html(function(n){var ret=""; for (var i=1;i<=n;i++) ret+="<option>"+i; return ret;}(countOutgoingTransitions(conn.stateFrom)));
$('#epropTrGuardOrder').val(conn.fwprop.order);
$('#epropTrActionType').val(conn.fwprop.actionType);
$('#epropTrActionFunc').val(conn.fwprop.actionFunc);
$('#epropTrActionCode').val(conn.fwprop.actionCode);
$('#epropTrActionDesc').val(conn.fwprop.actionDesc);
$('#epropTrActionAp')[0].checked = conn.fwprop.actionAp;
propSelectChange('#epropTrActionType');
$('#epropTrNote').val(conn.fwprop.note);
return; // stop here
}
// if we are here so far, we're going to process global state properties
refreshDisplayInfo();
$('#epropSmName').val(g.fwprop.smName);
$('#epropSmTitle').val(g.fwprop.smTitle);
$('#epropSmTags').val(g.fwprop.smTags);
$('#epropPreConditions').val(g.fwprop.preConditions);
$('#epropPostConditions').val(g.fwprop.postConditions);
$('#epropAutocomplete').val(g.fwprop.autocomplete);
$('#epropSmNotes').val(g.fwprop.smNotes);
$("#globadd").empty();
var globs=clone(g.fwprop.globalvar)
while(globs.length>0)
{
var row=globs.pop();
$("#globvar").find(".globvartype").val(row.type);
$("#globvar").find(".globvarname").val(row.name);
$("#globvar").find(".globvarvalue").val(row.value);
global_variable_add($("#globvar").find("button").get(0), true);
}
}
// check if there is a recursion error in embedding
function isEmbeddedError()
{
var rel=allRelatedSmFilesData();
var res={};
var i,key;
for (key in rel) res[key]=0;
for (key in rel) // for all related files
for (i=0; i<rel[key].data.states.length; i++) // check all states
res[rel[key].data.states[i].fwprop.embedSmId]++; // count how many times we saw them
for (key in res)
if (res[key]>1)
return true;
return false;
}
function countStatesByName(text)
{
var count=0;
for (var i=0; i<g.states.length; i++)
if (g.states[i].fwprop.identifier==text) count++;
return count;
}
function valueFixUndefined(text)
{
return text;
}
// set modified properties
function propUpdate()
{
if (g.selected.length==1)
{
var error='';
var state=g.selected[0];
historyAdd(state.fwprop.type+'prop'+state.id);
if (state.fwprop.type=='state')
{
state.fwprop.identifier=$('#epropStateID').val();
state.fwprop.note=$('#epropStateNote').val();
state.fwprop.entryType=$('#epropEntryType').val();
state.fwprop.entryFunc=$('#epropEntryFunc').val();
state.fwprop.entryCode=$('#epropEntryCode').val();
state.fwprop.entryDesc=$('#epropEntryDesc').val();
state.fwprop.entryAp=$('#epropEntryAp').is(':checked');
state.fwprop.doType=$('#epropDoType').val();
state.fwprop.doFunc=$('#epropDoFunc').val();
state.fwprop.doCode=$('#epropDoCode').val();
state.fwprop.doDesc=$('#epropDoDesc').val();
state.fwprop.doAp=$('#epropDoAp').is(':checked');
state.fwprop.exitType=$('#epropExitType').val();
state.fwprop.exitFunc=$('#epropExitFunc').val();
state.fwprop.exitCode=$('#epropExitCode').val();
state.fwprop.exitDesc=$('#epropExitDesc').val();
state.fwprop.exitAp=$('#epropExitAp').is(':checked');
state.fwprop.embedSmId=$('#epropEmbedSmId').val()
// warn if some other state is already embeding this one
if (state.fwprop.embedSmId>0)
if (isEmbeddedError())
error=fileNameByID(state.fwprop.embedSmId)+" is either already embedded on some other state, or causes a circular dependency in combination with some other machine which acts as a parent or child to the current diagram, considering all levels up and down. Make sure you know what you're doing.";
}
if (state.fwprop.type=='note')
{
state.fwprop.note=$('#epropNoteNote').val();
}
if (state.fwprop.type=='init')
{
state.fwprop.note=$('#epropInitNote').val();
}
if (state.fwprop.type=='final')
{
state.fwprop.note=$('#epropFinalNote').val();
}
if (state.fwprop.type=='choice')
{
state.fwprop.identifier=$('#epropChoiceID').val();
state.fwprop.note=$('#epropChoiceNote').val();
}
// validity checks
if (state.fwprop.identifier)
{
if (countStatesByName(state.fwprop.identifier)>1)
msg("Duplicite "+editorSwitch("state","node")+" name '"+state.fwprop.identifier+"'","error");
else
if (error!='')
msg(error,"error",-1);
}
refreshState(state);
all_tabs_refresh();
return; // stop here
}
if (g.selectedCon)
{
var conn=g.selectedCon;
historyAdd('conprop'+conn.id);
conn.fwprop.identifier=$('#epropTrigger').val();
conn.fwprop.guardType=$('#epropTrGuardType').val();
conn.fwprop.guardFunc=$('#epropTrGuardFunc').val();
conn.fwprop.guardCode=$('#epropTrGuardCode').val();
conn.fwprop.guardDesc=$('#epropTrGuardDesc').val();
conn.fwprop.guardAp=$('#epropTrGuardAp').is(':checked');
var prevOrder=conn.fwprop.order;
var newOrder=$('#epropTrGuardOrder').val();
reorderTransitions(conn.stateFrom, prevOrder, newOrder);
conn.fwprop.order=newOrder;
conn.fwprop.actionType=$('#epropTrActionType').val();
conn.fwprop.actionFunc=$('#epropTrActionFunc').val();
conn.fwprop.actionCode=$('#epropTrActionCode').val();
conn.fwprop.actionDesc=$('#epropTrActionDesc').val();
conn.fwprop.actionAp=$('#epropTrActionAp').is(':checked');
conn.fwprop.note=$('#epropTrNote').val();
refreshConnections(conn.stateFrom);
refreshConnection(getConnectionsIndex(conn));
all_tabs_refresh();
return; // stop here
}
// if we are here so far, we're going to process global state properties
historyAdd('globalprop');
g.fwprop.smName=$('#epropSmName').val();
g.fwprop.smTags=$('#epropSmTags').val();
g.fwprop.smTitle=$('#epropSmTitle').val();
g.fwprop.preConditions=$('#epropPreConditions').val();
g.fwprop.postConditions=$('#epropPostConditions').val();
g.fwprop.autocomplete=$('#epropAutocomplete').val();
g.fwprop.smNotes=$('#epropSmNotes').val();
g.fwprop.globalvar=[];
$("#globvar, #globadd").find(".globrow").each(function(){
g.fwprop.globalvar.push({
"type": $(this).find(".globvartype").val(),
"name": $(this).find(".globvarname").val(),
"value": $(this).find(".globvarvalue").val()
}) });
updateTitle();
all_tabs_refresh();
// update all texts on states and connections
// so autosuggest tooltips are refreshed
for (var i=0; i<g.states.length; i++)
{
if (g.states[i].text) g.states[i].text.str='';
updateStateText(g.states[i]);
}
for (i=0; i<g.connections.length; i++)
{
if (g.connections[i].text) g.connections[i].text.str='';
updateConnectionText(g.connections[i]);
}
init_autocomplete();
}
function init_autocomplete_list()
{
var options=[];
for (var i in g.autocomplete) options.push(i);
options=options.sort(naturalSort).reverse();
if (options.length==0) { $('#autocompleteList').hide(); $('#checkSCOS').hide(); }
else
{
$('#epropAutocomplete').html( '<option><option>'+options.join('<option>'));
$('#checkSCOSsel').html( '<option><option>'+options.join('<option>'));
}
if (g.fwprop.autocomplete) $('#epropAutocomplete').val(g.fwprop.autocomplete);
}