-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathids.js
1640 lines (1554 loc) · 72.4 KB
/
ids.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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
vIDS (virtual Information Display System) for VATSIM
Filename: ids.js
Function: Javscript backend for IDS site
Created: 4/1/21
Edited:
Changes:
*/
// Code below handles vIDS automatic data refreshes
var setRefreshTime = 15; // Defines vIDS refresh rate. Default is 15 (VATSIM JSON updates every 15 seconds)
var refreshTime = setRefreshTime;
var refreshTimer = setInterval(function(){
if(refreshTime <= 0){
refreshData(false,document.getElementById("pickMulti").value);
refreshTime = setRefreshTime;
}
var sec = " second";
if (refreshTime > 1) {
sec += "s";
}
document.getElementById("refresh_countdown").innerHTML = "Refresh in " +refreshTime + sec;
refreshTime -= 1;
}, 1000);
window.setTimeout(function() {
$(".alert").fadeTo(500, 0).slideUp(500, function(){
$(this).remove();
});
}, 2000);
/*
// Keypress listener
var keylog = '';
document.addEventListener('keydown', function(evt) {
keylog += evt.key;
if(keylog.match(/bruce/gi)) {
alert('Bruce mode!');
this.removeEventListener('keydown',arguments.callee,false);
}
});
*/
function showLocalIDS(template) { // Makes the local display visible
//alert("showing local");
loadingNotice();
document.getElementById("display_template").value = template;
var other = "";
if(template == "local") {
other = "a80";
}
else {
other = "local";
}
document.body.style.backgroundColor = "black";
document.body.style.backgroundImage = null;
//document.body.classList.add("black_background");
document.getElementById("landing_hdr").style.display = "none";
document.getElementById("landing").style.display = "none";
//document.getElementById("landing").style.visibility = "hidden";
//acknowledgeChanges(); // Clear change acknowledge (if user was monitoring multi and decided to switch displays)
document.getElementById("local_ids").style.display = "block";
$('.template_' + template).show();
$('.template_' + other).hide();
if(template == 'a80') { // Because Joe wants it this way... note
var temp = document.getElementById('grid5x1').innerHTML;
document.getElementById('grid5x1').innerHTML = document.getElementById('grid5x2').innerHTML;
document.getElementById('grid5x2').innerHTML = temp;
}
else {
if(document.getElementById('grid5x2').innerHTML.includes('Outer')) { // User was viewing A80 and has switched to local, so revert display
var temp = document.getElementById('grid5x1').innerHTML;
document.getElementById('grid5x1').innerHTML = document.getElementById('grid5x2').innerHTML;
document.getElementById('grid5x2').innerHTML = temp;
}
}
setDynamicMargin();
acknowledgeChanges(); // Clear change acknowledge (if user was monitoring multi and decided to switch displays)
}
function showMultiIDS() { // Makes the multi-airfield display visible
//alert("showing multi");
loadingNotice();
$('#launch_multi').modal('toggle');
if(document.getElementById("pickMulti").value == '?') {
$('#multi_template').modal('toggle');
}
else {
refreshData(init=false,template=document.getElementById("pickMulti").value) // IS THIS WHAT IS CAUSING THE RAPID REFRESH PROBLEM???????????????
document.body.style.backgroundColor = "black";
document.body.style.backgroundImage = null;
document.getElementById("landing_hdr").style.display = "none";
document.getElementById("landing").style.display = "none";
//document.getElementById("landing").style.visibility = "hidden";
document.getElementById("multi_ids").style.display = "block";
//alert(document.getElementById('templateCreator').value);
/*
if((document.getElementById("cid").value == ADMIN)||(document.getElementById("cid").value == document.getElementById('templateCreator').value)) { //**Note: need to add conditional in to allow creator to delete their own templates
document.getElementById("templateDeleteMenu").classList.remove('disabled');
}
else {
document.getElementById("templateDeleteMenu").classList.add('disabled');
}
*/
}
}
function launchMulti() {
//document.getElementById("pickMulti").value = "X";
//alert(document.getElementById('pickMulti').selectedIndex);
$('#launch_multi').modal('toggle');
}
function templateMod(fn) { // Modify a multi-IDS template
if(fn == 'save') {
var valid = true;
var errors = '';
if(document.getElementById('template_name').value.length < 1) {
valid = false;
errors += '- Template name must be at least 1 character long\n';
}
if(document.getElementById('template_aflds').options.length < 1) {
valid = false;
errors += '- Please add at least 1 airfield to the tempalte\n';
}
if (valid) {
// Save the tempalte and display it for the user
var name = document.getElementById('template_name').value;
var options = document.getElementById('template_aflds').options;
var payload = name + '\n' + document.getElementById('cid').value;
for(var x=0;x<options.length;x++) {
payload += '\n' + options[x].text;
}
saveConfiguration('template',payload);
$('#multi_template').modal('toggle');
document.getElementById("landing_hdr").style.display = "none";
document.getElementById("landing").style.display = "none";
document.getElementById("multi_ids").style.display = "block";
}
else {
alert('Please correct the following errors:\n\n' + errors);
}
}
else if(fn == 'add') {
if(document.getElementById('template_icao').value.length == 4) {
var option = document.createElement("option");
option.text = document.getElementById('template_icao').value;
option.value = 1; // I need to fix this...
document.getElementById('template_aflds').add(option);
document.getElementById('template_icao').value = "";
}
else {
alert('ICAO airfield identifier must be 4 characters in length');
}
}
else if(fn == 'rem') {
for(var i=document.getElementById('template_aflds').options.length-1;i>=0;i--) {
if(document.getElementById('template_aflds').options[i].selected) {
document.getElementById('template_aflds').remove(i);
}
}
}
else if(fn == 'up') {
var selected = $("#template_aflds").find(":selected");
var before = selected.prev();
if (before.length > 0)
selected.detach().insertBefore(before);
}
else if(fn == 'down') {
var selected = $("#template_aflds").find(":selected");
var next = selected.next();
if (next.length > 0)
selected.detach().insertAfter(next);
}
}
function addTemplateItem(json) {
json = JSON.parse(json);
//alert("attempting to append option to list. Template name: " + json.templ_name + " Filename: " + json.filename);
//alert(json);
el = document.getElementById('pickMulti');
var opt = document.createElement('option');
opt.value = json.filename;
opt.innerHTML = json.templ_name;
el.appendChild(opt);
el.value = json.filename;
}
function returnToLanding(closeDiv) { // Hides an active display and returns to the landing page
document.getElementById(closeDiv).style.display = "none";
document.body.style.backgroundImage = "url('" + document.getElementById("bgimg").value + "')";
document.getElementById("landing_hdr").style.display = "block";
document.getElementById("landing").style.display = "table";
//document.getElementById("landing").style.visibility = "visible";
if(closeDiv == "multi_ids") {
document.getElementById("pickMulti").value = "0";
}
}
function setActiveRunways(el) { // When in manual control (CIC mode), sets active runways and approach/departure type
var arr_sel = document.getElementById("arr_rwy");
var dep_sel = document.getElementById("dep_rwy");
arr_sel.options.length = 0;
dep_sel.options.length = 0;
var apch_types = new Array('VIS','ILS');
var dep_types = new Array('RV','ROTG');
if(el.value == "EAST") {
arr_runways = new Array('8L','9R','10','8R','9L');
dep_runways = new Array('8R','9L','10','8L','9R');
}
else if(el.value == "WEST") {
arr_runways = new Array('26R','27L','28','26L','27R');
dep_runways = new Array('26L','27R','28','26R','27L');
}
else {
var arr_runways = new Array();
var dep_runways = new Array();
}
for(var x=0; x<arr_runways.length; x++) {
for(var y=0; y<apch_types.length; y++) {
var option = document.createElement("option");
option.text = arr_runways[x] + ' ' + apch_types[y];
option.value = arr_runways[x] + ' ' + apch_types[y];
arr_sel.add(option);
}
for(var y=0; y<dep_types.length; y++) {
var option = document.createElement("option");
option.text = dep_runways[x] + ' ' + dep_types[y];
option.value = dep_runways[x] + ' ' + dep_types[y];
dep_sel.add(option);
}
}
//arr_sel.disabled = false;
//dep_sel.disabled = false;
}
function checkDuplicates(el) { // Prevents selection of duplicate approach/departure types for the same runway
// Placeholder for function to prevent duplicate approach/departure types from being selected.
}
function manualControl(el) { //Shifts IDS from automatic (populates from network data) to manual (CIC-entered data) control mode
if(el.checked) {
document.getElementById('flow').disabled = true;
document.getElementById('arr_rwy').disabled = true;
document.getElementById('dep_rwy').disabled = true;
}
else {
document.getElementById('flow').disabled = false;
document.getElementById('arr_rwy').disabled = false;
document.getElementById('dep_rwy').disabled = false;
}
}
function saveAFLD() { // Saves airfield config settings
var fta = "OFF";
var ftd = "OFF";
var intdep = "OFF";
var lahso = "OFF";
var auto = "ON";
if (document.getElementById("fta").checked) {
fta = "ON";
}
if (document.getElementById("ftd").checked) {
ftd = "ON";
}
document.getElementById("TRIPS_info").innerHTML = "FTA " + fta + "<br/>FTD " + ftd;
if (document.getElementById("ninelm2").checked) {
intdep = "ON";
}
else {
intdep = "OFF";
}
if (document.getElementById("lahso").checked) {
lahso = "ON";
}
else {
lahso = "OFF";
}
if (document.getElementById("AutoIDS").checked) {
auto = "ON";
}
else {
auto = "OFF";
}
var afld = "9L@M2 " + intdep + "<br>LAHSO " + lahso;
document.getElementById("AFLD_info").innerHTML = afld;
afld += "<br>AUTO " + auto;
document.getElementById("CIC_info").innerHTML = document.getElementById("CIC_text").value;
$('#AFLD').modal('toggle');
saveConfiguration('trips',document.getElementById("TRIPS_info").innerHTML);
saveConfiguration('afld',afld);
var arrivals = getSelectValues(document.getElementById("arr_rwy")).toString();
var departures = getSelectValues(document.getElementById("dep_rwy")).toString();
saveConfiguration('flow','\n' + document.getElementById("flow").value + '\n' + arrivals + '\n' + departures);
saveConfiguration('cic',document.getElementById("CIC_text").value);
}
function savePIREP() { // Saves a newly-entered PIREP
// Validate first!
var valid = true;
// Clear previous validation
clearPirepValidation();
if(document.getElementById("location").value.length < 3) {
valid = false;
document.getElementById("location").classList.add("is-invalid");
}
else {
document.getElementById("location").classList.add("is-valid");
}
if(document.getElementById("time").value.length < 4) {
valid = false;
document.getElementById("time").classList.add("is-invalid");
}
else {
document.getElementById("time").classList.add("is-valid");
}
if(document.getElementById("altitude").value.length < 3) {
valid = false;
document.getElementById("altitude").classList.add("is-invalid");
}
else {
document.getElementById("altitude").classList.add("is-valid");
}
if(document.getElementById("aircraft").value.length < 3) {
valid = false;
document.getElementById("aircraft").classList.add("is-invalid");
}
else {
document.getElementById("aircraft").classList.add("is-valid");
}
if(document.getElementById("conditions").value.length < 1) {
valid = false;
document.getElementById("conditions").classList.add("is-invalid");
}
else {
document.getElementById("conditions").classList.add("is-valid");
}
if (valid) {
var pirep_string = '/' + document.getElementById("urgency").value;
pirep_string += ' /OV ' + document.getElementById("location").value;
pirep_string += ' /TM ' + document.getElementById("time").value;
pirep_string += ' /' + document.getElementById("altitude").value;
pirep_string += ' /TP ' + document.getElementById("aircraft").value;
pirep_string += ' /RM ' + document.getElementById("conditions").value;
pirep_string += '\r';
if(document.getElementById("PIREP_info").innerHTML == "No PIREPs to display") {
document.getElementById("PIREP_info").innerHTML = pirep_string;
}
else {
document.getElementById("PIREP_info").innerHTML = pirep_string + document.getElementById("PIREP_info").innerHTML;
}
$('#PIREP').modal('toggle');
saveConfiguration('pirep',pirep_string.replace('/RM','/R')); // String replace deals with the /RM HTTP server error
document.getElementById("pirep_entry").reset();
clearPirepValidation();
}
}
function clearPirepValidation() { // Resets PIREP validation tooltips
var fields = new Array("location","time","altitude","aircraft","conditions");
for(var x=0;x<fields.length;x++) {
document.getElementById(fields[x]).classList.remove("is-valid");
document.getElementById(fields[x]).classList.remove("is-invalid");
}
}
function updateCtrlPos() { // Saves controller position/configuration data
// TODO: Make the positions array global so it can be used by multiple functions and not duplicated
var positions = new Array("LC-1","LC-2","LC-3","LC-4","LC-5","GC-N","GC-C","GC-S","GM","CD-1","CD-2","FD","N","S","I","P","F","X","G","Q","O","V","A","H","D","L","Y","M","W","Z","R","E","3E");
var controllers = "";
for(var x=0;x<positions.length;x++) {
if(controllers.length > 0)
controllers += "|";
controllers += document.getElementById(positions[x]).value;
}
saveConfiguration('controllers',controllers);
}
function saveTMU() { // Saves user-entered TMU notes
document.getElementById("TMU_info").innerHTML = linkify(document.getElementById("TMU_text").value);
$('#TMU').modal('toggle');
saveConfiguration('tmu',document.getElementById("TMU_text").value);
}
function saveA80CIC() { // Saves user-entered A80 CIC notes
document.getElementById("A80_CIC_info").innerHTML = document.getElementById("A80_CIC_text").value;
$('#CIC').modal('toggle');
saveConfiguration('a80cic',document.getElementById("A80_CIC_text").value);
}
function acknowledgeAlert(el) { // Clears change notification upon user ack
el.classList.remove("alert");
el.classList.remove("alert-danger");
}
function refreshData(init=false,template='0') { // Fetches current dataset from network and server and inits display update
//if(!init) { alert("Data refresh requested, template " + template); }
if(init) {
//loadingNotice();
}
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(!!document.getElementById('json_test_dump')) {
document.getElementById('json_test_dump').innerHTML = xhttp.responseText; // Dump the full JSON into a div
}
var reply = xhttp.responseText;
var error = "";
// Capture errors from PHP reply, prevent JS errors
if(reply.substring(0,1) != '{') { // JSON start with '{', lack of this means there is error text before the JSON
error = reply.substring(0,reply.indexOf('{')); // Capture the error text
reply = reply.substring(reply.indexOf('{')+1); // Trim the error off of the JSON so we can use it normally
}
//alert(reply);
updateIDSFields(init,reply); // Send this JSON to another function for parse and display
//updateIDSFields(init,xhttp.responseText); // Send this JSON to another function for parse and display
if(error.length > 0) { // An error occurred - notify the user
document.getElementById('alert').classList.add('alert-warning');
document.getElementById('alert_text').innerHTML = "A data refresh error occurred. Some vIDS fields may contain outdated information.";
}
}
else {
}
};
//alert(document.getElementById('live').checked);
var liveData = true;
if(!!document.getElementById('live')) {
liveData = document.getElementById('live').checked;
}
//xhttp.open("GET", "ajax_refresh.php?live=" + liveData, true);
//alert(template);
xhttp.open("GET", "ajax_refresh.php?live=" + liveData + "&template=" + template, true);
xhttp.send();
//if(init) { alert("Initial load data pull complete"); }
if(init) { // Check for browser type/capabilities and alert the user, if necessary
browser_detection();
}
}
function updateIDSFields(init,data) { // Called by refreshData() - updates all data fields with info retrieved from AJAX
//alert(data);
var json = JSON.parse(data);
var changes = false;
// Set Tower IDS fields
//init = false; // For testing only, this needs to be removed
changes = changeDetection(init,changes,document.getElementById("atis_code").innerHTML,json.airfield_data['KATL']['atis_code'],"atis_code");
document.getElementById("atis_code").innerHTML = json.airfield_data['KATL']['atis_code'];
changes = changeDetection(init,changes,document.getElementById("metar").innerHTML,json.airfield_data['KATL']['metar'],"metar");
document.getElementById("metar").innerHTML = json.airfield_data['KATL']['metar'];
changes = changeDetection(init,changes,document.getElementById("traffic_flow").innerHTML,json.airfield_data['KATL']['traffic_flow'],"traffic_flow");
document.getElementById("traffic_flow").innerHTML = json.airfield_data['KATL']['traffic_flow'];
var departure_rwys = "";
for(var x=0;x<json.airfield_data['KATL']['dep_rwys'].length;x++) {
departure_rwys += json.airfield_data['KATL']['dep_type'] + " " + json.airfield_data['KATL']['dep_rwys'][x] + "<br/>";
}
//changes = changeDetection(init,changes,document.getElementById("local_dep_rwys").innerHTML,departure_rwys,"local_dep_rwys");
document.getElementById("local_dep_rwys").innerHTML = departure_rwys;
// Departure splits
var origDepSplit = document.getElementById("split_dep_rwys").innerHTML;
if(json.airfield_data['KATL']['traffic_flow'] == "EAST") {
document.getElementById("splits_rwy_1").innerHTML = document.getElementById("splits_rwy_id_1").value = "8R/L";
document.getElementById("splits_rwy_2").innerHTML = document.getElementById("splits_rwy_id_2").value = "9R/L";
document.getElementById("splits_rwy_3").innerHTML = document.getElementById("splits_rwy_id_3").value = "10";
}
else if(json.airfield_data['KATL']['traffic_flow'] == "WEST") {
document.getElementById("splits_rwy_1").innerHTML = document.getElementById("splits_rwy_id_1").value = "26R/L";
document.getElementById("splits_rwy_2").innerHTML = document.getElementById("splits_rwy_id_2").value = "27R/L";
document.getElementById("splits_rwy_3").innerHTML = document.getElementById("splits_rwy_id_3").value = "28";
}
//alert(json.splits[0][0]);
if(!$('#DepartureSplit').is(':visible')) { // This conditional prevents the refresh script from updating data entry fields when a modal is in use
for(var i=1; i<4; i++) {
document.getElementById("splits_n1_" + i).checked = valueToCheckbox(json.splits[i-1][1]);
document.getElementById("splits_n1t_" + i).value = json.splits[i-1][2];
document.getElementById("splits_n2_" + i).checked = valueToCheckbox(json.splits[i-1][3]);
document.getElementById("splits_n2t_" + i).value = json.splits[i-1][4];
document.getElementById("splits_w2_" + i).checked = valueToCheckbox(json.splits[i-1][5]);
document.getElementById("splits_w2t_" + i).value = json.splits[i-1][6];
document.getElementById("splits_w1_" + i).checked = valueToCheckbox(json.splits[i-1][7]);
document.getElementById("splits_w1t_" + i).value = json.splits[i-1][8];
document.getElementById("splits_s2_" + i).checked = valueToCheckbox(json.splits[i-1][9]);
document.getElementById("splits_s2t_" + i).value = json.splits[i-1][10];
document.getElementById("splits_s1_" + i).checked = valueToCheckbox(json.splits[i-1][11]);
document.getElementById("splits_s1t_" + i).value = json.splits[i-1][12];
document.getElementById("splits_e1_" + i).checked = valueToCheckbox(json.splits[i-1][13]);
document.getElementById("splits_e1t_" + i).value = json.splits[i-1][14];
document.getElementById("splits_e2_" + i).checked = valueToCheckbox(json.splits[i-1][15]);
document.getElementById("splits_e2t_" + i).value = json.splits[i-1][16];
}
}
configDepSplit(false, true); // Recycle the display, but don't save
changes = changeDetection(init,changes,origDepSplit,document.getElementById("split_dep_rwys").innerHTML,"split_dep_rwys");
var arrival_rwys = "";
for(var x=0;x<json.airfield_data['KATL']['apch_rwys'].length;x++) {
arrival_rwys += json.airfield_data['KATL']['apch_type'] + " " + json.airfield_data['KATL']['apch_rwys'][x] + "<br/>";
}
//changes = changeDetection(init,changes,document.getElementById("local_arr_rwys").innerHTML,arrival_rwys,"local_arr_rwys");
document.getElementById("local_arr_rwys").innerHTML = arrival_rwys;
// Set controller position combines in select boxes
var controllers = json.controllers.split("|");
var positions = new Array("LC-1","LC-2","LC-3","LC-4","LC-5","GC-N","GC-C","GC-S","GM","CD-1","CD-2","FD","N","S","I","P","F","X","G","Q","O","V","A","H","D","L","Y","M","W","Z","R","E","3E");
//var controllerPos = "";
for(var x=0; x<controllers.length;x++) {
//controllerPos += "Position: " + positions[x] + " Controller selected: " + controllers[x] + "\n";
changes = changeDetection(init,changes,document.getElementById(positions[x]).value,controllers[x],positions[x]);
changes = changeDetection(init,changes,document.getElementById(positions[x]).value,controllers[x],positions[x] + "_disp");
selectOption(positions[x],controllers[x]);
document.getElementById(positions[x] + "_disp").value = (controllers[x] == '.' ? '' : controllers[x]);
}
//alert(changes);
// Set text fields
if(!json.pirep.includes('No PIREPs to display')) { // Only show change detection if something new happens, not simply if everything expires
changes = changeDetection(init,changes,document.getElementById("PIREP_info").innerHTML.replace(/(\r\n|\n|\r)/gm,""),json.pirep.replace(/(\r\n|\n|\r)/gm,""),"PIREP_info");
}
//alert("Current: \"" + document.getElementById("PIREP_info").innerHTML + "\"\nUpdate: \"" + json.pirep + "\"");
document.getElementById("PIREP_info").innerHTML = json.pirep; // Display-only (entries auto-timeout)
changes = changeDetection(init,changes,unlinkify(document.getElementById("TMU_info").innerHTML),json.tmu,"TMU_info");
//var tmuText = json.tmu.map(i => i.replace(/\n/g, '<br />')).join('');
//alert(json.tmu);
//alert(unlinkify(document.getElementById("TMU_info").innerHTML));
document.getElementById("TMU_info").innerHTML = linkify(json.tmu); //.replaceAll(/\n/g, '<br />')); // Display
if(!$('#TMU').is(':visible')) { // This conditional prevents the refresh script from updating data entry fields when a modal is in use
document.getElementById("TMU_text").innerHTML = json.tmu // Data entry
}
if(!$('#A80_CIC_info').is(':visible')) { // Only do change detection on visible elements
changes = changeDetection(init,changes,document.getElementById("A80_CIC_info").innerHTML,json.a80cic,"A80_CIC_info");
}
document.getElementById("A80_CIC_info").innerHTML = json.a80cic;
if(!$('#CIC').is(':visible')) { // This conditional prevents the refresh script from updating data entry fields when a modal is in use
document.getElementById("A80_CIC_text").value = json.a80cic; // Data entry
}
changes = changeDetection(init,changes,document.getElementById("TRIPS_info").innerHTML,json.trips['raw'],"TRIPS_info");
document.getElementById("TRIPS_info").innerHTML = json.trips['raw']; // Display
//document.getElementById("fta").checked = json.trips['FTA']; // Data entry
//alert("FTA: " + json.trips['FTA'] + "\nFTD: " + json.trips['FTD']);
//document.getElementById("ftd").checked = json.trips['FTD']; // Data entry
//document.getElementById("ninelm2").checked = json.config['9L@M2']; // Data entry
//document.getElementById("lahso").checked = json.config['LAHSO']; // Data entry
//document.getElementById("AutoIDS").checked = json.config['AUTO']; // Data entry
/*
if(!json.config['AUTO']) {
document.getElementById("flow").disabled = false;
document.getElementById("arr_rwy").disabled = false;
document.getElementById("dep_rwy").disabled = false;
}
*/
/*
if(json.config['AUTO']) {
document.getElementById("flow").disabled = true;
document.getElementById("arr_rwy").disabled = true;
document.getElementById("dep_rwy").disabled = true;
}
*/
//alert("." + json.airfield_data['KATL']['traffic_flow'].trim() + ".");
/*
document.getElementById("flow").value = json.airfield_data['KATL']['traffic_flow'].trim();
setActiveRunways(document.getElementById("flow"));
for (var i = 0; i < document.getElementById("arr_rwy").options.length; i++) {
document.getElementById("arr_rwy").options[i].selected = json.airfield_data['KATL']['apch_rwys'].indexOf(document.getElementById("arr_rwy").options[i].value) >= 0;
}
for (var i = 0; i < document.getElementById("dep_rwy").options.length; i++) {
document.getElementById("dep_rwy").options[i].selected = json.airfield_data['KATL']['dep_rwys'].indexOf(document.getElementById("dep_rwy").options[i].value) >= 0;
}
*/
//alert("Current: \"" + document.getElementById("AFLD_info").innerHTML + "\"\nUpdate: \"" + json.config['raw'] + "\"");
changes = changeDetection(init,changes,document.getElementById("AFLD_info").innerHTML,json.config['raw'],"AFLD_info");
document.getElementById("AFLD_info").innerHTML = json.config['raw']; // Display
if(!$('#CIC_info').is(':visible')) { // Only do change detection on visible elements
changes = changeDetection(init,changes,document.getElementById("CIC_info").innerHTML,json.cic,"CIC_info");
}
//changes = changeDetection(init,changes,document.getElementById("CIC_info").innerHTML,json.cic,"CIC_info");
//alert("CIC Info\nIn DOM: \"" + document.getElementById("CIC_info").innerHTML + "\"\nFrom file: \"" + json.cic.replace(/(\n)/gm,"") + "\"");
document.getElementById("CIC_info").innerHTML = json.cic; // Display
//document.getElementById("CIC_text").innerHTML = json.cic; // Data entry
if(!$('#AFLD').is(':visible')) { // This conditional prevents the refresh script from updating data entry fields when a modal is in use
document.getElementById("flow").value = json.airfield_data['KATL']['traffic_flow'].trim();
setActiveRunways(document.getElementById("flow"));
if(json.airfield_data['KATL']['apch_rwys'].length != undefined) {
for (var i = 0; i < document.getElementById("arr_rwy").options.length; i++) {
document.getElementById("arr_rwy").options[i].selected = json.airfield_data['KATL']['apch_rwys'].indexOf(document.getElementById("arr_rwy").options[i].value) >= 0;
}
}
if(json.airfield_data['KATL']['dep_rwys'].length != undefined) {
for (var i = 0; i < document.getElementById("dep_rwy").options.length; i++) {
document.getElementById("dep_rwy").options[i].selected = json.airfield_data['KATL']['dep_rwys'].indexOf(document.getElementById("dep_rwy").options[i].value) >= 0;
}
}
document.getElementById("fta").checked = json.trips['FTA']; // Data entry
document.getElementById("ftd").checked = json.trips['FTD']; // Data entry
document.getElementById("ninelm2").checked = json.config['9L@M2']; // Data entry
document.getElementById("lahso").checked = json.config['LAHSO']; // Data entry
document.getElementById("CIC_text").innerHTML = json.cic; // Data entry
document.getElementById("AutoIDS").checked = json.config['AUTO']; // Data entry
}
if(!json.config['AUTO']) {
document.getElementById("flow").disabled = false;
document.getElementById("arr_rwy").disabled = false;
document.getElementById("dep_rwy").disabled = false;
}
//alert(json.gates);
if(json.gates.length == 3) {
changes = changeDetection(init,changes,document.getElementById("dep_gate_n").innerHTML,json.gates[0],"dep_gate_n");
changes = changeDetection(init,changes,document.getElementById("dep_gate_s").innerHTML,json.gates[1],"dep_gate_s");
changes = changeDetection(init,changes,document.getElementById("dep_gate_i").innerHTML,json.gates[2],"dep_gate_i");
document.getElementById("dep_gate_n").innerHTML = json.gates[0];
document.getElementById("dep_gate_s").innerHTML = json.gates[1];
document.getElementById("dep_gate_i").innerHTML = json.gates[2];
//var txt_overrun = "";
if ($('#dep_gate_n')[0].scrollWidth > $('#dep_gate_n_container').innerWidth()) { // When true, the text overruns the box, so we want to marquee
document.getElementById("dep_gate_n_container").classList.add("start_marquee");
//txt_overrun += "N";
}
else {
document.getElementById("dep_gate_n_container").classList.remove("start_marquee");
}
if ($('#dep_gate_s')[0].scrollWidth > $('#dep_gate_s_container').innerWidth()) { // When true, the text overruns the box, so we want to marquee
document.getElementById("dep_gate_s_container").classList.add("start_marquee");
//txt_overrun += "S";
}
else {
document.getElementById("dep_gate_s_container").classList.remove("start_marquee");
}
if ($('#dep_gate_i')[0].scrollWidth > $('#dep_gate_i_container').innerWidth()) { // When true, the text overruns the box, so we want to marquee
document.getElementById("dep_gate_i_container").classList.add("start_marquee");
//txt_overrun += "I";
}
else {
document.getElementById("dep_gate_i_container").classList.remove("start_marquee");
}
/*
alert("N - Text width: " + $('#dep_gate_n')[0].scrollWidth + " Div width: " + $('#dep_gate_n_container').innerWidth() +
"\nS - Text width: " + $('#dep_gate_s')[0].scrollWidth + " Div width: " + $('#dep_gate_s_container').innerWidth() +
"\nI - Text width: " + $('#dep_gate_i')[0].scrollWidth + " Div width: " + $('#dep_gate_i_container').innerWidth() +
"\n Overruns: " + txt_overrun);
*/
// document.getElementById("dep_gate_n").value = json.gates[0];
// document.getElementById("dep_gate_s").value = json.gates[1];
// document.getElementById("dep_gate_i").value = json.gates[2];
/*
$('#dep_gate_n').marquee({ speed: 20 });
$('#dep_gate_s').marquee({ speed: 20 });
$('#dep_gate_i').marquee({ speed: 20 });
*/
if(!$('#DepartureGates').is(':visible')) { // This conditional prevents the refresh script from updating data entry fields when a modal is in use
document.getElementById("depGateN").value = json.gates[0];
document.getElementById("depGateS").value = json.gates[1];
document.getElementById("depGateI").value = json.gates[2];
}
}
// Set A80 satellite and outer field info
var underlying_fields = new Array("KPDK","KFTY","KMGE","KRYY","KLZU","KMCN","KWRB","KAHN","KCSG"); // I intentionally left LSF out... we never use it
//var underlying_fields = new Array("KPDK"); // For testing only.. real world use the line above to get all of the satellites
var openCloseStatus = "";
for(var y=0;y<underlying_fields.length;y++) {
var open_closed = "CLOSED";
if(underlying_fields[y] in json.airfield_data) {
document.getElementById(underlying_fields[y] + "_atis_code").innerHTML = json.airfield_data[underlying_fields[y]].atis_code;
//if(json.airfield_data[underlying_fields[y]].atis_code != "--") {
//open_closed = "OPEN";
//}
// New schema to make field OPEN/CLOSED status reflect real-world tower operating hours
var curDate = new Date();
var dayofweek = curDate.getUTCDay(); // 0 = Sunday, 1 = Monday
var cur24time = curDate.getUTCHours() * 100 + curDate.getUTCMinutes(); // Get UTC time and format HHmm
var opHours = document.getElementById(underlying_fields[y] + "_hours_mf").value;
//alert(underlying_fields[y] + ': ' + document.getElementById(underlying_fields[y] + "_hours_mf").value);
if ((dayofweek == 0)||(dayofweek == 6)) { // Sunday(0) or Saturday(6)
opHours = document.getElementById(underlying_fields[y] + "_hours_ss").value;
}
opHours = opHours.split('-');
var opHoursStart = parseInt(opHours[0]);
var opHoursEnd = parseInt(opHours[1]);
if((document.getElementById(underlying_fields[y] + "_hours_dstAdjust").value)&&(checkDST())) { // Adjust for DST
opHoursStart -= 100;
opHoursEnd -= -100;
}
if(opHoursEnd < opHoursStart) { // This happens when a tower closes after 0000Z
opHoursEnd += 2400;
}
if((cur24time > opHoursStart)&&(cur24time < opHoursEnd)||(cur24time < opHoursStart)&&(cur24time < opHoursEnd)) { // Airfield is open
open_closed = "OPEN";
//alert(underlying_fields[y] + ' Current UTC time: ' + cur24time + ' Field opening time: ' + opHoursStart + ' Field closing time: ' + opHoursEnd + ' Field is: ' + open_closed);
}
openCloseStatus += underlying_fields[y] + ' Current UTC time: ' + cur24time + ' Field opening time: ' + opHoursStart + ' Field closing time: ' + opHoursEnd + ' Field is: ' + open_closed + '\n';
document.getElementById(underlying_fields[y] + "_open_closed").innerHTML = open_closed;
// New schema to display del/gnd/twr status
//alert(json.airfield_data[underlying_fields[y]].tower_cab.del);
if(json.airfield_data[underlying_fields[y]].tower_cab.del) {
//alert(underlying_fields[y] + ' delivery online ' + document.getElementById(underlying_fields[y] + "_online_del").classList);
document.getElementById(underlying_fields[y] + "_online_del").classList.add('badge-del');
//alert(underlying_fields[y] + ' delivery online ' + document.getElementById(underlying_fields[y] + "_online_del").classList);
}
else {
document.getElementById(underlying_fields[y] + "_online_del").classList.remove('badge-del');
}
if(json.airfield_data[underlying_fields[y]].tower_cab.gnd) {
document.getElementById(underlying_fields[y] + "_online_gnd").classList.add('badge-gnd');
}
else {
document.getElementById(underlying_fields[y] + "_online_gnd").classList.remove('badge-gnd');
}
if(json.airfield_data[underlying_fields[y]].tower_cab.twr) {
document.getElementById(underlying_fields[y] + "_online_twr").classList.add('badge-twr');
}
else {
document.getElementById(underlying_fields[y] + "_online_twr").classList.remove('badge-twr');
}
document.getElementById(underlying_fields[y] + "_metar").innerHTML = json.airfield_data[underlying_fields[y]].metar;
/*
var active_rwys = "--";
if(json.airfield_data[underlying_fields[y]].dep_rwys != null) {
for(var z=0;z<json.airfield_data[underlying_fields[y]].dep_rwys.length;z++) {
active_rwys += json.airfield_data[underlying_fields[y]].dep_rwys[z] + " ";
}
}
*/
// New scheme to display active runways/traffic flow with the option for manual override
var active_apch_rwys = "--";
var override = false;
var afld = underlying_fields[y];
if(json.override.hasOwnProperty(afld)) { // An override exists, so display it
active_apch_rwys = json.override[afld];
override = json.override[afld];
}
else if(json.airfield_data[afld].apch_rwys != "") { // Display generated active runway and approach type
for(var rwy in json.airfield_data[afld]['apch_rwys']) {
if(active_apch_rwys.length > 0) {
active_apch_rwys += ", ";
}
active_apch_rwys += json.airfield_data[afld]['apch_rwys'][rwy] + " " + json.airfield_data[afld]['apch_type'];
}
}
document.getElementById(underlying_fields[y] + "_runway").innerHTML = active_apch_rwys;
document.getElementById(underlying_fields[y] + "_override").value = override;
}
}
//alert(openCloseStatus);
// Set MULTI-IDS fields
//var multi_disp_str = '<div class=\"landing_menu\"><a onclick=\"returnToLanding(\'multi_ids\');\"><i class=\"fas fa-bars\"></i></a></div>';
if((document.getElementById("ad").value == '1')||(document.getElementById("cid").value == json.template_creator)) {
document.getElementById("templateDeleteMenu").classList.remove('disabled');
}
else {
document.getElementById("templateDeleteMenu").classList.add('disabled');
}
var multi_disp_str = '';
//alert("KATL approach type: " + json.airfield_data['KATL']['apch_rwys'].join(", "));
//alert("Resetting Multi-IDS airfields..." + JSON.stringify(json.template));
//var airfield_listing = "";
//for(afld in json.airfield_data.template) {
if(json.template === null) { // Refresh isn't finished... show a loading message
multi_disp_str = "<div class=\"row\"><div class=\"col-lg\"><h3>Multi-IDS display is loading... please wait</h3></div></div>";
}
else {
//var defaultAirfieldNoChange = "alert('Configuration for this airfield must be set through the local vIDS display by the tower CIC.');";
// Note: I had to break-out refresh vs redraw logic below to allow users to click/drag/reorder airfields
// Create array of all airfields displayed by walking DOM and getting IDs
var nextAfld = document.getElementById('multi_ids_data').firstChild;
var displayedAirfields = new Array();
while(nextAfld) {
displayedAirfields.push(nextAfld.id);
nextAfld = nextAfld.nextSibling;
}
displayedAirfields = displayedAirfields.map(function(x){ return x.toUpperCase(); }).sort();
templateAirfields = Object.values(json.template).map(function(x){ return x.toUpperCase(); }).sort();
/*
if(JSON.stringify(displayedAirfields) === JSON.stringify(templateAirfields)) { // Displayed and template are the same, so just refresh data
//alert(displayedAirfields + "\n" + templateAirfields);
//alert('refresh');
for(afld in displayedAirfields) {
afld = displayedAirfields[afld];
//alert(afld);
document.getElementById(afld + '_ATIS').innerHTML = json.airfield_data[afld].atis_code;
document.getElementById(afld + '_WX').innerHTML = json.airfield_data[afld].winds + " " + json.airfield_data[afld].altimeter;
document.getElementById(afld + '_METAR').innerHTML = json.airfield_data[afld].metar;
var active_rwy_apch = "";
// New scheme to display active runways/traffic flow with the option for manual override
var override = false;
if(json.override.hasOwnProperty(afld)) { // An override exists, so display it
active_rwy_apch = json.override[afld];
override = json.override[afld];
}
else if(json.airfield_data[afld].apch_rwys != "") { // Display generated active runway and approach type
for(var rwy in json.airfield_data[afld]['apch_rwys']) {
if(active_rwy_apch.length > 0) {
active_rwy_apch += ", ";
}
active_rwy_apch += json.airfield_data[afld]['apch_rwys'][rwy] + " " + json.airfield_data[afld]['apch_type'];
}
}
document.getElementById(afld + '_RWYAPCH').innerHTML = active_rwy_apch;
var rvr = "";
for(var x=0; x<json.airfield_data[afld].rvr_display.length; x++) {
rvr += json.airfield_data[afld].rvr_display[x] + "<br/>";
}
document.getElementById(afld + '_RVR').innerHTML = rvr;
}
}
else { // Redraw multi-ids view
*/
if(JSON.stringify(displayedAirfields) !== JSON.stringify(templateAirfields)) { // Displayed and template are not the same, so just redraw grid
for(afld in json.template) { //json.airfield_data
afld = json.template[afld];
afld = afld.toUpperCase();
multi_disp_str += "<div id=\"" + afld + "\" class=\"row moveable\" draggable=\"true\" ondragstart=\"dragStarted(event);\" ondragover=\"draggingOver(event);\" ondrop=\"dropped(event);\">";
multi_disp_str += "<div class=\"col-lg-1\"><div class=\"vert_id\">" + json.airfield_data[afld].icao_id.substr(1,1).toUpperCase() + "</div><div class=\"vert_id\">" + json.airfield_data[afld].icao_id.substr(2,1).toUpperCase() + "</div><div class=\"vert_id\">" + json.airfield_data[afld].icao_id.substr(3,1).toUpperCase() + "</div></div>";
// multi_disp_str += "<div id=\"" + afld + "_ATIS\" class=\"col-lg-1 atis_code_m\">" + json.airfield_data[afld].atis_code + "</div>";
multi_disp_str += "<div id=\"" + afld + "_ATIS\" class=\"col-lg-1 atis_code_m\"></div>";
/*
var active_rwy_apch = "";
// New scheme to display active runways/traffic flow with the option for manual override
var override = false;
if(json.override.hasOwnProperty(afld)) { // An override exists, so display it
active_rwy_apch = json.override[afld];
override = json.override[afld];
}
else if(json.airfield_data[afld].apch_rwys != "") { // Display generated active runway and approach type
for(var rwy in json.airfield_data[afld]['apch_rwys']) {
if(active_rwy_apch.length > 0) {
active_rwy_apch += ", ";
}
active_rwy_apch += json.airfield_data[afld]['apch_rwys'][rwy] + " " + json.airfield_data[afld]['apch_type'];
}
}
else {
//active_rwy_apch = json.airfield_data[afld].apch_rwys.join(", ");
}
*/
/*
multi_disp_str += "<div class=\"col-lg-2 arrival_info\"><div id=\"" + afld + "_RWYAPCH\" class=\"apch_type\">" + active_rwy_apch + "</div><div></div>";
multi_disp_str += "<div id=\"" + afld + "_WX\" class=\"wx\">" + json.airfield_data[afld].winds + " " + json.airfield_data[afld].altimeter + "</div>" + generateDropdown(afld,defaultAirfield) + "</div>";
multi_disp_str += "<div id=\"" + afld + "_METAR\" class=\"col-lg-5 metar_m\">" + json.airfield_data[afld].metar + "</div>";
multi_disp_str += "<div class=\"col-lg-3 metar_m\">RY RVR<div id=\"" + afld + "_RVR\" class=\"rvr\">";
*/
multi_disp_str += "<div class=\"col-lg-2 arrival_info\"><div id=\"" + afld + "_RWYAPCH\" class=\"apch_type\"></div><div></div>";
multi_disp_str += "<div id=\"" + afld + "_WX\" class=\"wx\"></div>" + generateDropdown(afld,defaultAirfield);
multi_disp_str += "<span class=\"cab_status\"> <span id=\"" + afld + "_multi_online_del\" class=\"badge badge-secondary\">D</span> <span id=\"" + afld + "_multi_online_gnd\" class=\"badge badge-secondary\">G</span> <span id=\"" + afld + "_multi_online_twr\" class=\"badge badge-secondary\">T</span></span>";
multi_disp_str += "</div>";
multi_disp_str += "<div id=\"" + afld + "_METAR\" class=\"col-lg-5 metar_m\"></div>";
multi_disp_str += "<div class=\"col-lg-3 metar_m\">RY RVR<div id=\"" + afld + "_RVR\" class=\"rvr\">";
/* for(var x=0; x<json.airfield_data[afld].rvr_display.length; x++) {
multi_disp_str += json.airfield_data[afld].rvr_display[x] + "<br/>";
}
*/
multi_disp_str += " <input type=\"hidden\" id=\"" + afld + "_override\" value=\"" + override + "\" /></div></div></div>";
//airfield_listing += json.airfield_data[afld].icao_id.toUpperCase() + ", ";
}
document.getElementById('multi_ids_data').innerHTML = multi_disp_str;
}
// Refresh data fields
//while(document.getElementById('multi_ids_data').innerHTML == '') {
// Wait... causes the code to delay until the template is loaded into the DOM ;)
//}
//alert(displayedAirfields + "\n" + templateAirfields);
//alert('refresh');
for(afld in templateAirfields) {
afld = templateAirfields[afld];
if(json.airfield_data[afld] != undefined) { // Sometimes the refresh is too fast for the redraw... this prevents errors
//alert(afld);
document.getElementById(afld + '_ATIS').innerHTML = json.airfield_data[afld].atis_code;
document.getElementById(afld + '_WX').innerHTML = json.airfield_data[afld].winds + " " + json.airfield_data[afld].altimeter;
document.getElementById(afld + '_METAR').innerHTML = json.airfield_data[afld].metar;
var active_rwy_apch = "";
// New scheme to display active runways/traffic flow with the option for manual override
var override = false;
if(json.override.hasOwnProperty(afld)) { // An override exists, so display it
active_rwy_apch = json.override[afld];
override = json.override[afld];
}
else if(json.airfield_data[afld].apch_rwys != "") { // Display generated active runway and approach type
for(var rwy in json.airfield_data[afld]['apch_rwys']) {
if(active_rwy_apch.length > 0) {
active_rwy_apch += ", ";
}
active_rwy_apch += json.airfield_data[afld]['apch_rwys'][rwy] + " " + json.airfield_data[afld]['apch_type'];
}
}
document.getElementById(afld + '_RWYAPCH').innerHTML = active_rwy_apch;
var rvr = "";
for(var x=0; x<json.airfield_data[afld].rvr_display.length; x++) {
rvr += json.airfield_data[afld].rvr_display[x] + "<br/>";
}
document.getElementById(afld + '_RVR').innerHTML = rvr;
}
// Update D/G/T badge colors based on tower cab staffing
if(json.airfield_data[afld].tower_cab.del) {
document.getElementById(afld + "_multi_online_del").classList.add('badge-del');
}
else {
document.getElementById(afld + "_multi_online_del").classList.remove('badge-del');
}
if(json.airfield_data[afld].tower_cab.gnd) {
document.getElementById(afld + "_multi_online_gnd").classList.add('badge-gnd');
}
else {
document.getElementById(afld + "_multi_online_gnd").classList.remove('badge-gnd');
}
if(json.airfield_data[afld].tower_cab.twr) {
document.getElementById(afld + "_multi_online_twr").classList.add('badge-twr');
}
else {
document.getElementById(afld + "_multi_online_twr").classList.remove('badge-twr');
}
}
}
//alert(airfield_listing);
//document.getElementById('multi_ids_data').innerHTML = multi_disp_str;
if(changes) {
document.getElementById("acknowledge").style.visibility = "visible";
}
document.getElementById('loading').className = "hideLoad"; // If the loading screen is active, hide it
}
function loadingNotice() { // Moves progress bar in loading notice
// Initialize progress bar to zero
document.getElementById('loadingProgress').setAttribute("style","width:0%");
document.getElementById('loadingProgress').setAttribute("aria-valuenow",0);
var loadtime = 15; // Seconds
document.getElementById('loading').className = "showLoad";
var seconds = 0;
var t = setInterval(function() {
if(document.getElementById('loading').className == "hideLoad") {
clearInterval(t);
}
seconds += 0.25;
var percentage = (seconds/loadtime) * 100;
document.getElementById('loadingProgress').setAttribute("style","width:" + percentage + "%");
document.getElementById('loadingProgress').setAttribute("aria-valuenow",percentage);
//$('#loadingProgress').css('width', percentage+'%').attr('aria-valuenow', percentage);
if(seconds == loadtime) {
clearInterval(t);
}
},250);
}
function generateDropdown(afldId,defAfld) {
var configAfld = "airfieldConfig('" + afldId + "')";
if(afldId == defAfld) {
configAfld = "alert('Configuration for this airfield must be set through the local vIDS display by the tower CIC.');";
}
var str = "<div class=\"dropdown noclear\"><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\"><i class=\"fas fa-caret-square-down\"></i></a><ul class=\"dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\"><li class=\"dropdown-header\">" + afldId + "</li><li class=\"divider\"></li><li><a href=\"#\" onclick=\"" + configAfld + "\">Airfield Config</a></li><li><a href=\"#PROC\" onclick=\"loadProc('" + afldId + "');\" data-toggle=\"modal\">Instrument Procedures</a></li></ul></div>";
return str;
}
function airfieldConfig(afldId) {
document.getElementById("override_active").checked = false;
document.getElementById("override_rwy_apch").value = "";
document.getElementById("ac_afldId").innerHTML = afldId.toUpperCase();
document.getElementById("override_afld_id").value = afldId.toUpperCase();
if(document.getElementById(afldId.toUpperCase() + "_override").value != 'false') {
document.getElementById("override_active").checked = true;
document.getElementById("override_rwy_apch").value = document.getElementById(afldId.toUpperCase() + "_override").value;
}
$('#AirfieldConfig').modal('toggle');
}
function saveAfldConfigOverride(action) {
var override = new Array(document.getElementById("override_afld_id").value);
if(action) { // Save a new override
override.push(document.getElementById("override_rwy_apch").value);
}
else { // Remove an existing override
override.push(false);
}
//alert(JSON.stringify(override));
saveConfiguration('override',JSON.stringify(override));
$('#AirfieldConfig').modal('toggle');
}
function setDepartureGates(save = false) {
if(save) {
// Update fields in IDS and then save the data to file
document.getElementById("dep_gate_n").innerHTML = "<p><span>" + document.getElementById("depGateN").value + "</span></p>";
document.getElementById("dep_gate_s").innerHTML = "<p><span>" + document.getElementById("depGateS").value + "</span></p>";
document.getElementById("dep_gate_i").innerHTML = "<p><span>" + document.getElementById("depGateI").value + "</span></p>";
var gateConfig = "N:" + document.getElementById("depGateN").value + "\n";
gateConfig += "S:" + document.getElementById("depGateS").value + "\n";
gateConfig += "I:" + document.getElementById("depGateI").value;
saveConfiguration('gates',gateConfig);
//alert(document.getElementById("dep_gate_n").getElementsByTagName("p")[0].innerHTML);
}
$('#DepartureGates').modal('toggle');
}
function configDepSplit(save = false, refresh = false) {
if(save || refresh) {