forked from glidernet/ogn-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ogn.js
2527 lines (2143 loc) · 87 KB
/
ogn.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
/*
____ _____ _ _ _ _ _ _ _
/ __ \ / ____| (_) | | | \ | | | | | |
| | | |_ __ ___ _ __ | | __| |_ __| | ___ _ __ | \| | ___| |___ _____ _ __| | __
| | | | '_ \ / _ \ '_ \ | | |_ | | |/ _` |/ _ \ '__| | . ` |/ _ \ __\ \ /\ / / _ \| '__| |/ /
| |__| | |_) | __/ | | | | |__| | | | (_| | __/ | | |\ | __/ |_ \ V V / (_) | | | <
\____/| .__/ \___|_| |_| \_____|_|_|\__,_|\___|_| |_| \_|\___|\__| \_/\_/ \___/|_| |_|\_\
| |
|_|
*/
// Extend Number object with methods to convert between degrees & radians
Number.prototype.toRadians = function() { return this * Math.PI / 180; };
Number.prototype.toDegrees = function() { return this * 180 / Math.PI; };
var map;
var map_id = 0;
var autoc = "";
var acaff = "";
var cton = false;
//var tcolor = ["000000", "FF0000", "00FF00", "0000FF", "FFFF00", "00FFFF", "FF00FF", "C0C0C0", "FFFFFF"];
var tcolor = ["000000","FF0000","00B000","0000FF","808000","008080","FF00FF","606060","505028","500000","800080","FF8040","80B000","4040FF","804000","000080"];
var ccolor = 0;
var aflist = true;
var vallpolon = true;
var vallpoloff = true;
var vallmaron = true;
var vallmaroff = true;
var lside = 0; // 0=right 1=left
var online = []; // ([cn,alt*1,cn+"_"+ps,colcn,afdif]);
var offline = []; // ([cn,alt*1,cn+"_"+ps,colcn,afdif]);
var receivers = [];
var all = 0;
var stick = 0;
var barogram = 0;
var pathl = 30; // path length 5' (30points)
var polwidth = 2; // polyline width (path)
var polwidth2 = 4; // polyline width mouseover
var lastpol; // last polyline name display in divInfo
var lastpolon; // last polyline highlighted
var unit = "m"; // metric units
var onoff = 1; // 1: online, 2: offline, 3: Menu
var onoffaff = "OnLine";
var triasc = 1; // 1: asc 2: desc
var tricol = 0; // 0:tri sur cn 1: tri sur alti
var ett1 = "<CENTER><IMG style=\"z-index:50\" onclick=\"alist();\" SRC=\"" + tld + "/pict/min.png\"> <IMG style=\"z-index:50\" onclick=\"sideclick();\" SRC=\"" + tld + "/pict/dbarrow.gif\"> <A HREF=\"" + tld + "/help-fr.html\" target=\"_blank\"><IMG style=\"z-index:50\" SRC=\"" + tld + "/pict/hel.png\"></A> <span id=\"onoff\" onclick=\"onofff();\"></span></CENTER>";
var w = 0; // watchdog variable
var tmgm, tmwd;
var nbreq = 0; // nb request launch
var wlt = 0; // tasks white list
var wlist = [];
var vasp = false;
var vrec = false;
var vrecl = false;
var vstm = false;
var vapt = false;
var vwin = false;
var vpre = false;
var vtem = false;
var vrai = false;
var hnew = false;
selrec = "";
var ftype = ["unknown", "Glider/MotorGlider", "Tow Plane", "Helicopter", "Parachute", "Drop Plane", "Hangglider", "Paraglider", "Plane", "Jet", "UFO", "Balloon", "Airship", "Drone", "unknown", "Static Object"];
var ftypec = ["_b", "", "_g", "_r", "_b", "_b", "_p", "_p", "_b", "_b", "_b", "_b", "_b", "_k", "_b", "_b"];
var initialResolution = 2 * Math.PI * 6378137 / 256; // == 156543.0339
var originShift = 2 * Math.PI * 6378137 / 2.0; // == 20037508.34
var m2ft={"m":1, "i":3.2808};
var am2ft={"m":"m", "i":"ft"};
var kh2kt={"m":1, "i":0.53996};
var akh2kt={"m":"km/h", "i":"kt"};
var m2kt={"m":1, "i":1.94384};
var am2kt={"m":"m/s", "i":"kt"};
var unitlist = {"m":"metric", "i":"nautical"}
var hashc="",hashz="",hashm="",hasho="",hashb="",hashs="",hashl="",hasht="",hl=" ",hashw="",hashu="",hashp="",hashn="",hashy="",hasha="", hashg="";
// center zoom maptype offline bound autoset2ma layers tasks warning units pathlength nolist devtype altitudestick barogram
// close popup
function cp() {
clearTimeout(tmop);
var d = document.getElementById('popup');
d.style.display = 'none';
}
// open popup
function op(maxw) {
var d = document.getElementById('popup');
d.style.display = 'block';
d.style.width = maxw + 'px';
d.style.height = maxw + 'px';
tmop = setTimeout(cp, 15000);
}
function chunit() { // change units
if (document.getElementById('uni').checked === true) { // units imperial
unit = 'i';
hashu = "&u=i";
} else { // units metric
unit = 'm';
hashu = "";
}
scaleLineControl.setUnits(unitlist[unit]);
rehash();
}
function chstick() { // change altitude stick
if (document.getElementById('stick').checked === true) { // stick visible
stick = 1;
hasha = "&a=1";
sticksLayer.setVisible(true);
} else { // no altitude stick
stick = 0;
hasha = "";
sticksLayer.setVisible(false);
}
rehash();
}
function chbaro() { // change barogram
if (document.getElementById('baro').checked === true) { // barogram visible
document.getElementById('dbaro').style.display = "block";
document.getElementById('dbaro').style.visibility = "visible";
barogram = 1;
hashg = "&g=1";
} else { // no barogram
document.getElementById('dbaro').style.display = "none";
barogram = 0;
hashg = "";
}
rehash();
}
function chpl() { // change path length
var prevPathl = pathl;
if (document.getElementById('rp1').checked === true) { // 5 minutes
pathl = 30;
hashp = "";
} else if (document.getElementById('rp2').checked === true) { // 10 minutes
pathl = 60;
hashp = "&p=2";
} else { // all points
pathl = 99999;
hashp = "&p=3";
}
// only delete paths if new path is smaller
if (pathl < prevPathl) {
delpon();
delpoff();
}
baro_reSize();
rehash();
}
function chmap(mid) { // change map
OSMLayer.setVisible(false);
MapsForFreeLayer.setVisible(false);
MapsForFreeLayerW.setVisible(false);
OSMTopoLayer.setVisible(false);
IGNSatelliteLayer.setVisible(false);
l4UMapsLayer.setVisible(false);
StamenTerrainLayer.setVisible(false);
switch(mid)
{
case 1:
OSMTopoLayer.setVisible(true);
break;
case 2:
MapsForFreeLayer.setVisible(true);
MapsForFreeLayerW.setVisible(true);
break;
case 3:
IGNSatelliteLayer.setVisible(true);
break;
case 4:
l4UMapsLayer.setVisible(true);
break;
case 5:
StamenTerrainLayer.setVisible(true);
break;
default:
mid = 0;
OSMLayer.setVisible(true);
}
hashm = "&m=" + mid;
rehash();
}
function devtype() { // devices types selected
var dt = 0;
if (document.getElementById('ICAObox').checked) {
dt += 1;
}
if (document.getElementById('Flarmbox').checked) {
dt += 2;
}
if (document.getElementById('OGNbox').checked) {
dt += 4;
}
if (dt == 7) hashy = ""; // all devices
else hashy = "&y=" + dt;
reseton();
resetoff();
rehash();
}
function onofff() {
switch (onoff) {
case 1:
if (all == 1) {
onoffaff = "OffLine";
onoff = 2;
} else {
onoffaff = "Menu";
onoff = 3;
document.getElementById("ett2").style.display = "none";
document.getElementById("dtlist").style.display = "none";
document.getElementById("menu").style.display = "block";
}
break;
case 2:
onoffaff = "Menu";
onoff = 3;
document.getElementById("ett2").style.display = "none";
document.getElementById("dtlist").style.display = "none";
document.getElementById("menu").style.display = "block";
break;
case 3:
onoffaff = "OnLine";
onoff = 1;
document.getElementById("ett2").style.display = "block";
document.getElementById("dtlist").style.display = "block";
document.getElementById("menu").style.display = "none";
break;
}
afftab();
}
function delpon() { // delete all online path
var j = -1;
while (online[++j]) {
// * window["P_" + online[j][2]].getPath().clear();
window["P_" + online[j][2]].getGeometry().setCoordinates([]);
window["M_" + online[j][2]].set('tra', 0);
window["B_" + online[j][2]] =[];
}
}
function delpoff() { // delete all offline path
var j = -1;
while (offline[++j]) {
// * window["P_" + offline[j][2]].getPath().clear();
window["P_" + offline[j][2]].getGeometry().setCoordinates([]);
window["M_" + offline[j][2]].set('tra', 0);
window["B_" + offline[j][2]] =[];
}
}
function deletepath(pol) {
// * window[pol].getPath().clear();
window[pol].getGeometry().setCoordinates([]);
window["M_" + pol.substring(2)].set('tra', 0);
window["B_" + pol.substring(2)] =[];
}
function deleteallpath() {
if (onoff == 1) {
delpon();
} else {
delpoff();
}
}
function allpath() {
var j = -1;
if (onoff == 1) {
if (vallpolon === true) vallpolon = false;
else vallpolon = true;
while (online[++j]) {
setvisipol(vallpolon, "P_" + online[j][2]);
}
} else {
if (vallpoloff === true) vallpoloff = false;
else vallpoloff = true;
while (offline[++j]) {
setvisipol(vallpoloff, "P_" + offline[j][2]);
}
}
afftab();
}
function allmarker() {
var j = -1;
var opa = true;
if (onoff == 1) {
if (vallmaron === true) {
vallmaron = false;
opa = false;
}
else vallmaron = true;
while (online[++j]) {
setvisimar(opa, "M_" + online[j][2]);
setvisipol(opa, "S_" + online[j][2]);
}
} else {
if (vallmaroff === true) {
vallmaroff = false;
opa = false;
}
else vallmaroff = true;
while (offline[++j]) {
setvisimar(opa, "M_" + offline[j][2]);
setvisipol(opa, "S_" + offline[j][2]);
}
}
//map.render();
afftab();
}
function tricn() {
if (tricol == 1) triasc = 1;
else if (triasc == 1) triasc = 2;
else triasc = 1;
tricol = 0;
afftab();
}
function trialti() {
if (tricol === 0) triasc = 1;
else if (triasc == 1) triasc = 2;
else triasc = 1;
tricol = 1;
afftab();
}
function highlight(poly,wid) {
var p = poly.substring(2);
var colactive = window["M_" + p].get('icol');
var ncol = tcolor[colactive];
var visib = window[poly].get('visi');
window[poly].setStyle(new ol.style.Style({
stroke: new ol.style.Stroke({
color: [parseInt(ncol.substring(0,2), 16), parseInt(ncol.substring(2,4), 16), parseInt(ncol.substring(4), 16), visib ], // version avec canal alpha pour cacher/afficher
width: wid
})
}));
}
function focuson(poly) {
focusoff(lastpolon);
if (document.getElementById(poly) !== null) document.getElementById(poly).className = 'yel';
highlight(poly,polwidth2);
lastpolon = poly;
}
function focusoff(poly) {
if (document.getElementById(poly) !== null) document.getElementById(poly).className = 'whi';
if (document.getElementById(poly) !== null) document.getElementById(poly).className = 'whi';
if ( typeof(window[poly]) != 'undefined' ) {
highlight(poly,polwidth);
}
}
function asp() {
if (document.getElementById('aspbox').checked) {
vasp = true;
airspaceoverlay.setVisible(true);
rempl(4, "z");
} else {
vasp = false;
airspaceoverlay.setVisible(false);
rempl(4, " ");
}
rehash();
}
function apt() {
if (document.getElementById('aptbox').checked) {
vapt = true;
airportoverlay.setVisible(true);
rempl(5, "a");
} else {
vapt = false;
airportoverlay.setVisible(false);
rempl(5, " ");
}
rehash();
}
function wind() {
if (document.getElementById('winbox').checked) {
vwin = true;
windoverlay.setVisible(true);
if (map.getView().getZoom() > 7 ) map.getView().setZoom(7);
rempl(2, "v");
} else {
vwin = false;
windoverlay.setVisible(false);
rempl(2, " ");
}
rehash();
}
function pres() {
if (document.getElementById('prebox').checked) {
vpre = true;
presoverlay.setVisible(true);
if (map.getView().getZoom() > 7 ) map.getView().setZoom(7);
rempl(3, "p");
} else {
vpre = false;
presoverlay.setVisible(false);
rempl(3, " ");
}
rehash();
}
function tempe() {
if (document.getElementById('tembox').checked) {
vtem = true;
tempoverlay.setVisible(true);
if (map.getView().getZoom() > 7 ) map.getView().setZoom(7);
rempl(1, "t");
} else {
vtem = false;
tempoverlay.setVisible(false);
rempl(1, " ");
}
rehash();
}
function rain() {
if (document.getElementById('raibox').checked) {
vrai = true;
rainoverlay.setVisible(true);
if (map.getView().getZoom() > 7 ) map.getView().setZoom(7);
rempl(7, "n");
} else {
vrai = false;
rainoverlay.setVisible(false);
rempl(7, " ");
}
rehash();
}
function hidenew() {
if (document.getElementById('hnewbox').checked) hnew = true;
else hnew = false;
}
function reseton() { // delete all online markers and their path
var j = -1;
while (online[++j]) {
iconLayerSource.removeFeature(window["M_" + online[j][2]]);
delete window["M_" + online[j][2]];
sticksLayerSource.removeFeature(window["S_" + online[j][2]]);
delete window["S_" + online[j][2]];
traceLayerSource.removeFeature(window["P_" + online[j][2]]);
delete window["P_" + online[j][2]];
delete window["B_" + online[j][2]];
}
map.render();
}
function resetoff() { // delete all offline markers and their path
var j = -1;
while (offline[++j]) {
iconLayerSource.removeFeature(window["M_" + offline[j][2]]);
delete window["M_" + offline[j][2]];
sticksLayerSource.removeFeature(window["S_" + offline[j][2]]);
delete window["S_" + offline[j][2]];
traceLayerSource.removeFeature(window["P_" + offline[j][2]]);
delete window["P_" + offline[j][2]];
delete window["B_" + offline[j][2]];
}
map.render();
}
function lineoff() {
if (document.getElementById('offl').checked) {
all = 0;
resetoff();
hasho = "";
} else {
all = 1;
hasho = "&o=1";
}
rehash();
}
function bounds() {
if (document.getElementById('boundsbox').checked) {
bound = true;
if (document.getElementById('astmbox').checked) {
vstm = false;
hashs = "";
document.getElementById('astmbox').checked = false;
}
amax = parseFloat(document.getElementById('latmax').value);
amin = parseFloat(document.getElementById('latmin').value);
if (amin > amax) {
var tmp = amax;
amax = amin;
amin = tmp;
}
omax = parseFloat(document.getElementById('lonmax').value);
omin = parseFloat(document.getElementById('lonmin').value);
if (omin > omax) {
var tmp = omax;
omax = omin;
omin = tmp;
}
if (amax > 85) amax = 85;
if (amin < -85) amin = -85;
if (omax > 180) omax = 180;
if (omin < -180) omin = -180;
boundc = "&b=" + amax + "&c=" + amin + "&d=" + omax + "&e=" + omin;
document.getElementById('latmax').value = amax;
document.getElementById('latmin').value = amin;
document.getElementById('lonmax').value = omax;
document.getElementById('lonmin').value = omin;
reseton();
resetoff();
hashb = "&b=" + amax.toFixed(4) + "," + amin.toFixed(4) + "," + omax.toFixed(4) + "," + omin.toFixed(4);
} else {
bound = false;
if (vstm === false) boundc = "";
hashb = "";
}
rehash();
}
function afftab() {
var j = -1;
var dlistd = "<TABLE class=\"tt\">";
var mar = "";
var pol = "";
var affcpt = "";
switch (onoff) {
case 1:
online.sort(ASC);
if (triasc == 2) online.reverse();
while (online[++j]) {
mar = "M_" + online[j][2];
pol = "P_" + online[j][2];
stk = "S_" + online[j][2];
dlistd += "<TR id=\"" + pol + "\" onmouseover=\"focuson('" + pol + "');\" onmouseout=\"focusoff('" + pol + "');\">" +
"<TD class=\"cgv\"><input onchange=\"setvisimar(this.checked ,'" + mar + "');setvisistk(this.checked ,'" + stk + "');\" type=\"checkbox\" " + isvisib(mar) + " ></TD>" +
"<TD class=\"cgv\"><input onchange=\"setvisipol(this.checked ,'" + pol + "');\" type=\"checkbox\" " + isvisib(pol) + " ></TD>" +
"<TD class=\"cgn\" onmousedown=\"centeron('" + mar + "');\" onmouseup=\"centeroff();\" oncontextmenu=\"event.stopPropagation(); redraw('" + pol + "'); return false;\" ondblclick=\"event.stopPropagation(); autocenter('" + mar + "');\" >" + online[j][0] + "</TD>" +
"<TD class=\"cgc\"><span style='background-color: " + online[j][3] + "' ondblclick=\"deletepath('" + pol + "'); return false;\" oncontextmenu=\"this.style.backgroundColor=changecolor('" + mar + "'); return false;\"> </span></TD>" +
"<TD onclick=\"affinfo('" + mar + "')\" class=\"cga\">";
if (unit == "i") {
dlistd += (online[j][1] * m2ft[unit]).toFixed();
} // { var tv=online[j][1]*m2ft[unit]; dlistd+= tv.toFixed(); }
else dlistd += online[j][1] + "m";
dlistd += "</TD><TD class=\"cgv\"><IMG src='" + tld + "/pict/" + online[j][4] + ".gif'></TD></TR>";
}
affcpt = " (" + online.length + ")";
break;
case 2:
offline.sort(ASC);
if (triasc == 2) offline.reverse();
while (offline[++j]) {
mar = "M_" + offline[j][2];
pol = "P_" + offline[j][2];
stk = "S_" + offline[j][2];
dlistd += "<TR id=\"" + pol + "\" onmouseover=\"focuson('" + pol + "');\" onmouseout=\"focusoff('" + pol + "');\"><TD class=\"cgv\"><input onchange=\"setvisimar(this.checked ,'" + mar + "');setvisistk(this.checked ,'" + stk + "');\" type=\"checkbox\" " + isvisib(mar) + " ></TD><TD class=\"cgv\"><input onchange=\"setvisipol(this.checked ,'" + pol + "');\" type=\"checkbox\" " + isvisib(pol) + " ></TD><TD class=\"cgn\" onmousedown=\"centeron('" + mar + "');\" onmouseup=\"centeroff();\" oncontextmenu=\"event.stopPropagation(); redraw('" + pol + "'); return false;\" ondblclick=\"event.stopPropagation(); autocenter('" + mar + "');\" >" + offline[j][0] + "</TD><TD class=\"cgc\"><span style='background-color: " + offline[j][3] + "' ondblclick=\"deletepath('" + pol + "'); return false;\" oncontextmenu=\"this.style.backgroundColor=changecolor('" + mar + "'); return false;\"> </span></TD><TD onclick=\"affinfo('" + mar + "')\" class=\"cga\">";
// dlistd += "<TR id=\"" + pol + "\" onmouseover=\"focuson('" + pol + "');\" onmouseout=\"focusoff('" + pol + "');\"><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + mar + "');\" type=\"checkbox\" " + isvisib(mar) + " ></TD><TD class=\"cgv\"><input onchange=\"vpolmar(this.checked ,'" + pol + "');\" type=\"checkbox\" " + isvisib(pol) + " ></TD><TD class=\"cgn\" onmousedown=\"centeron('" + mar + "');\" onmouseup=\"centeroff();\" oncontextmenu=\"event.stopPropagation(); redraw('" + pol + "'); return false;\" ondblclick=\"event.stopPropagation(); autocenter('" + mar + "');\" >" + offline[j][0] + "</TD><TD class=\"cgc\"><span style='background-color: " + offline[j][3] + "' ondblclick=\"deletepath('" + pol + "'); return false;\" oncontextmenu=\"this.style.backgroundColor=changecolor('" + mar + "'); return false;\"> </span></TD><TD onclick=\"affinfo('" + mar + "')\" class=\"cga\">";
if (unit == "i") {
dlistd += (offline[j][1] * m2ft[unit]).toFixed();
} else dlistd += offline[j][1] + "m";
dlistd += "</TD><TD class=\"cgv\"><IMG src='" + tld + "/pict/" + offline[j][4] + ".gif'></TD></TR>";
}
affcpt = " (" + offline.length + ")";
break;
case 3:
affcpt = " ";
break;
}
dlistd += "</TABLE>";
document.getElementById("dtlist").innerHTML = dlistd;
if (aflist === true) document.getElementById("onoff").innerHTML = "<B>" + onoffaff + "</B>" + affcpt;
}
function ASC(a, b) {
a = a[tricol];
b = b[tricol];
if (a > b)
return 1;
if (a < b)
return -1;
return 0;
}
function alist() {
if (aflist === true) {
document.getElementById("ett1").innerHTML = "<CENTER><IMG style=\"z-index:50\" onclick=\"alist();\" SRC=\"" + tld + "/pict/plu.png\"></CENTER>";
document.getElementById('dlist').style.width = "20px";
document.getElementById('dlist').style.height = "20px";
if (lside == 1) document.getElementById('ac').style.left = "0px";
else document.getElementById('ac').style.right = "0px";
centeroff();
document.getElementById('dbaro').style.display = "none";
aflist = false;
hashn = "&n=0";
} else {
document.getElementById("ett1").innerHTML = ett1;
document.getElementById('dlist').style.width = "180px";
document.getElementById('dlist').style.height = "90%";
if (lside == 1) document.getElementById('ac').style.left = "180px";
else document.getElementById('ac').style.right = "180px";
if (document.getElementById('baro').checked) document.getElementById('dbaro').style.display = "block";
aflist = true;
afftab();
hashn = "";
}
rehash();
}
function sideclick() { // change list position (left<->right)
if (lside === 0) {
document.getElementById('dlist').className = "lleft";
document.getElementById('dbaro').className = "baroright";
document.getElementById('ac').className = "acleft";
document.getElementById('ac').style.right = "";
lside = 1;
} else {
document.getElementById('dlist').className = "lright";
document.getElementById('dbaro').className = "baroleft";
document.getElementById('ac').className = "acright";
document.getElementById('ac').style.left = "";
lside = 0;
}
}
function autocenter(mark) {
// ###
document.getElementById("divInfoac").innerHTML = "<B>AC</B>: " + window[mark].get('title');
autoc = mark;
// ###
document.getElementById("divInfoac").style.display = "block";
map.getView().setCenter(ol.proj.fromLonLat([window[mark].get('lon'), window[mark].get('lat')]));
}
function centeron(mark) {
cton = true;
map.getView().setCenter(ol.proj.fromLonLat([window[mark].get('lon'), window[mark].get('lat')]));
}
function centeroff() {
if (autoc !== "") {
map.getView().setCenter(ol.proj.fromLonLat([window[autoc].get('lon'), window[autoc].get('lat')], 'EPSG:4326', 'EPSG:3857'));
}
cton = false;
}
function setvisimar(chk, mar) {
var vis = ((chk === true)?1:0);
window[mar].getStyle().getImage().setOpacity(vis);
window[mar].changed();
window[mar].set('visi', vis);
}
function setvisistk(chk, stk) {
setvisipol(chk, stk);
}
function setvisipol(chk, pol) {
var vis = ((chk === true)?1:0);
var hcol = window[pol].get('col');
window[pol].setStyle(
new ol.style.Style({
stroke: new ol.style.Stroke({
color: [parseInt(hcol.substring(0,2), 16), parseInt(hcol.substring(2,4), 16), parseInt(hcol.substring(4), 16), vis],
width: polwidth
})
})
);
window[pol].changed();
window[pol].set('visi', vis);
}
function isvisib(pol) {
if (window[pol].get('visi') == 1) return "checked";
else return "";
}
function dec2dms(dec) {
dec = Math.abs(dec);
var decd = Math.floor(dec);
var decm = Math.floor((dec - decd) * 60);
var decs = Math.floor((dec - decd - (decm / 60)) * 3600);
return "" + decd + "° " + decm + "' " + decs + "\"";
}
function changecolor(mark) {
var colactive = window[mark].get('icol');
if (++colactive == tcolor.length) colactive = 0;
var ncol = tcolor[colactive];
var visib = window[window[mark].get('poly')].get('visi');
window[window[mark].get('poly')].setStyle(new ol.style.Style({
stroke: new ol.style.Stroke({
//color: '#' + hcol, // version courte initiale
color: [parseInt(ncol.substring(0,2), 16), parseInt(ncol.substring(2,4), 16), parseInt(ncol.substring(4), 16), visib ], // version avec canal alpha pour cacher/afficher
width: polwidth
})
}));
window[mark].set('icol', "" + colactive);
window[window[mark].get('poly')].set('col', "" + ncol);
return "#" + ncol;
}
function redraw(pol) {
var p = pol.substring(2);
var mrk = window["M_" + p];
var fi = mrk.get('fid');
var lo = mrk.get('lon');
mrk.set('tra', 1);
downloadUrl(tld + '/' + cxml1 + '?id=' + p + "&l=" + lo, function(data) {
var vtrace = data.documentElement.getElementsByTagName("m");
var err = parseFloat(vtrace[0].getAttribute("e"));
var idd = vtrace[0].getAttribute("i");
var encodedt = vtrace[0].getAttribute("r");
if (err === 0 && encodedt.length > 2) {
var format = new ol.format.Polyline({
//factor: 1e6
});
var line = format.readGeometry(encodedt, {
dataProjection: 'EPSG:4326',
featureProjection: 'EPSG:900913'
});
window['P_' + idd].getGeometry().setCoordinates([]);
window['P_' + idd].setGeometry(line);
}
});
}
function taskbox() {
var vtas = false;
if (document.getElementById('taskbox').checked) {
vtas = true;
if (wlt == 2) {
--wlt;
reseton();
resetoff();
}
} else {
if (wlt == 1) {
++wlt;
reseton();
resetoff();
}
}
taskLayer.setVisible(vtas);
}
function reclbox() {
if (document.getElementById('reclbox').checked) {
vrecl = true;
rempl(6, "r");
} else {
vrecl = false;
rempl(6, " ");
}
receiverLayer.setVisible(vrecl);
rehash();
}
function checkrec() {
downloadUrl(tld + '/' + rxml, function(data) {
var vlrec = data.documentElement.getElementsByTagName("m");
var err = parseFloat(vlrec[0].getAttribute("e"));
if (err === 0 && vlrec.length > 1) {
selrec = "";
// effacer markers
var j = -1;
while (receivers[++j]) {
receiverLayerSource.removeFeature(window["R_" + receivers[j][0]]);
delete window["R_" + receivers[j][0]];
}
receivers.length = 0;
for (var i = 1; i < vlrec.length; i++) {
var re = vlrec[i].getAttribute("a");
var rlat = parseFloat(vlrec[i].getAttribute("b"));
var rlon = parseFloat(vlrec[i].getAttribute("c"));
var ract = parseInt(vlrec[i].getAttribute("d"));
var rind = 2000 * ract;
selrec += "<option value='" + re + "'>" + re + "</option>";
receivers.push([re, rlat, rlon]); // lat et lon stockées mais jamais utilisées ?
window["R_" + re] = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([rlon,rlat])),
lat: rlat,
lon: rlon,
mark: "R",
info: re
});
window["R_" + re].setStyle(new ol.style.Style({
image: new ol.style.Icon({
anchor: [0.5, 1],
opacity: 1,
src: "" + tld + "/pict/rec" + ract + ".png",
})
}));
receiverLayerSource.addFeature(window["R_" + re]);
}
setTimeout(checkrec, 120000);
} else {
selrec = "<option value='_error_'>Error</option>";
setTimeout(checkrec, 20000);
}
reclbox();
});
}
function receiv() {
if (document.getElementById('recbox').checked) {
vrec = true;
} else {
vrec = false;
}
}
function affinfodata(mark) {
var mrk = window[mark];
var vz = mrk.get('vz') * m2kt[unit];
var vx = mrk.get('speed') * kh2kt[unit];
var al = mrk.get('alt') * m2ft[unit];
document.getElementById("aclt").innerHTML = mrk.get('tim');
document.getElementById("acla").innerHTML = mrk.get('lat');
document.getElementById("aclo").innerHTML = mrk.get('lon');
document.getElementById("acal").innerHTML = al.toFixed() + " " + am2ft[unit];
document.getElementById("acsp").innerHTML = vx.toFixed() + " " + akh2kt[unit];
document.getElementById("actr").innerHTML = mrk.get('track');
document.getElementById("acvz").innerHTML = ((vz >= 0) ? "+" : "–") + Math.abs(vz).toFixed(1) + " " + am2kt[unit];
var re = mrk.get('rec');
var red = "<A HREF='http://ognrange.glidernet.org/#" + re + "' target='_blank' onclick=\"event.stopPropagation();\">" + re + "</a>";
if (typeof(window["R_" + re]) != 'undefined') {
var mre = window["R_" + re];
var di = dist(mrk.get('lat'), mrk.get('lon'), mre.get('lat'), mre.get('lon'));
red += " (" + di.toFixed() + " Km)";
} else {
red += " (?)";
}
document.getElementById("acrx").innerHTML = red;
}
function affinfodata2(mark) {
var mrk = window[mark];
document.getElementById("acmo").innerHTML = mrk.get('model');
}
function affinfo(mark) {
affinfodata(mark);
var mrk = window[mark];
var rg = mrk.get('reg');
var fi = mrk.get('fid');
var vd = "block";
if (fi == rg) vd = "none";
document.getElementById("ac1").style.display = vd;
document.getElementById("accn").innerHTML = mrk.get('cn');
document.getElementById("acre").innerHTML = rg;
document.getElementById("acty").innerHTML = ftype[mrk.get('type') * 1];
document.getElementById("acmo").innerHTML = "";
if (fi != "hidden") {
//document.getElementById("acfi").innerHTML = "<A HREF='http://www.kisstech.ch/cgi-bin/flarm-txrange.cgi?command=plot&flarmid=" + fi + "' target='_blank' onclick=\"event.stopPropagation();\">" + fi + "</a>";
document.getElementById("acfi").innerHTML = "<A HREF='https://ktrax.kisstech.ch/plot?device=" + fi + "' target='_blank' onclick=\"event.stopPropagation();\">" + fi + "</a>";
document.getElementById("acif").innerHTML = "<A HREF='https://www.google.com/search?nfpr=1&q=\"" + rg + "\"' target='_blank' onclick=\"event.stopPropagation();\">Infos</a> <A HREF='https://www.google.com/search?nfpr=1&q=\"" + rg + "\"&tbm=isch' target='_blank' onclick=\"event.stopPropagation();\">Pictures</a>";
if (mrk.get('dinfo') === "") {
downloadUrl(tld + '/' + dxml + '?i=' + mark + '&f=' + fi, function(data) {
var dat = data.documentElement.getElementsByTagName("m");
var err = parseFloat(dat[0].getAttribute("g"));
var mrk = dat[0].getAttribute("i");
if (err === 0) {
window[mrk].set('model', "" + dat[0].getAttribute("c"));
affinfodata2(mrk);
document.getElementById("ac2").style.display = "block";
window[mrk].set('dinfo', "ok");
} else {
window[mrk].set('dinfo', "_");
document.getElementById("ac2").style.display = "none";
}
});
} else {
if (mrk.get('dinfo') != "_") {
affinfodata2(mark);
document.getElementById("ac2").style.display = "block";
} else {
document.getElementById("ac2").style.display = "none";
}
}
} else {
document.getElementById("acfi").innerHTML = fi;
document.getElementById("ac2").style.display = "none";
document.getElementById("acif").innerHTML = "";
document.getElementById("acmo").innerHTML = "";
}
acaff = mark;
document.getElementById("ac").style.display = "block";
}
function settomap() {
var extent = map.getView().calculateExtent(map.getSize());
var bottomLeft = ol.proj.transform(ol.extent.getBottomLeft(extent),'EPSG:3857', 'EPSG:4326');
var topRight = ol.proj.transform(ol.extent.getTopRight(extent),'EPSG:3857', 'EPSG:4326');
amax = topRight[1];
amin = bottomLeft[1];
omax = topRight[0];
omin = bottomLeft[0];
if (amax > 85) amax = 85;
if (amin < -85) amin = -85;
if (omax > 180) omax = 180;
if (omin < -180) omin = -180;
document.getElementById('latmax').value = amax;
document.getElementById('latmin').value = amin;
document.getElementById('lonmax').value = omax;
document.getElementById('lonmin').value = omin;
if (bound === true) bounds();
if (vstm === true) {
boundc = "&b=" + amax + "&c=" + amin + "&d=" + omax + "&e=" + omin;
hashs = "&s=1";
rehash();
}
}
function astm() {
if (document.getElementById('astmbox').checked) {