-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1080 lines (907 loc) · 33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div style="clear:both;">
<link rel="stylesheet" type="text/css" href="./index_files/taskAdmin.css">
<script language="javascript" src="./index_files/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="./index_files/grouped.min.css">
<link rel="stylesheet" type="text/css" href="./index_files/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./index_files/bootstrap-theme.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
var maxTpnum=20;
var maxTpnum0=9;
var taskID="";
var taskPass="";
var userID="";
var userPin="";
var taskCat=0;
var waypoints=[];
var taskTurnpoints=[];
var taskInfo={};
var taskDefinitionStr='';
var taskName='Task Name';
var isPg=0;
var isGliding=0;
var isOther=0;
$(document).ready(function() {
taskID=localStorage.getItem('taskID');
taskPass=localStorage.getItem('taskPass');
userID=localStorage.getItem('userID');
userPin=localStorage.getItem('userPin');
waypoints=[];
var wptStr=localStorage.getItem('waypoints');
if (wptStr && wptStr!='undefined') {
waypoints = JSON.parse(wptStr);
}
if (!waypoints) waypoints=[];
taskTurnpoints=[];
wptStr=localStorage.getItem('taskTurnpoints');
if (wptStr && wptStr!='undefined') {
taskTurnpoints= JSON.parse(wptStr);
}
if (!taskTurnpoints) taskTurnpoints=[];
taskInfo={};
wptStr=localStorage.getItem('taskInfo');
if (wptStr && wptStr!='undefined') {
taskInfo= JSON.parse(wptStr);
}
if (!taskInfo) taskInfo={};
taskName=localStorage.getItem('taskName');
taskCat=localStorage.getItem('taskCat');
showRows();
updateFields();
updateTaskInfo();
$(".taskAdminTable tr:even").css("background-color", "#FAFAFF");
$(".taskAdminTable tr:odd").css("background-color", "#FFFFFF");
for(var i=0;i<taskTurnpoints.length;i++) {
$("#compTp"+i).val(taskTurnpoints[i]['tpname']);
};
$(".tpTr").each(function(index){
var i=$(this).attr('id').substr(4);
viewTypes(i);
//viewSubTypes3(i);
});
document.getElementById("sendSMSbutton").addEventListener("click", function() {
copyToClipboard(document.getElementById("taskDefinitionStr"));
});
});
function resetTunpoints() {
taskTurnpoints=[];
$("#mainTable tr:not(:first)").remove();
showRows();
updateFields();
$(".tpTr").each(function(index){
var i=$(this).attr('id').substr(4);
viewTypes(i);
});
}
function taskset() {
storeValues(0);
$.get('http://www.livetrack24.com/ajax.live_task.php',{
op:"settask",message: $("#taskDefinitionStr").val()
}, function(result) {
if (result.substr(0,8)=='Task SET') {
$("#resultDiv2").removeClass("alert-danger").show().html(result);
} else {
$("#resultDiv2").addClass("alert-danger").html(result).fadeTo(1500, 500).slideUp(1000);
}
}).fail(function() {
$("#resultDiv2").addClass("alert-danger").html("Could not set Task via internet, try SMS").fadeTo(1500, 500).slideUp(1000);
});
}
function storeTaskID() {
localStorage.setItem('taskID', $("#taskID").val());
}
function storeTaskPass() {
localStorage.setItem('taskPass', $("#taskPass").val());
}
function storeUserID() {
localStorage.setItem('userID', $("#userID").val());
}
function storeUserPin() {
localStorage.setItem('userPin', $("#userPin").val());
}
function storeValues(displayMessage) {
taskID=$("#taskID").val();
taskPass=$("#taskPass").val();
userID=$("#userID").val();
userPin=$("#userPin").val();
taskName=$("#taskName").html();
localStorage.setItem('taskID', taskID);
localStorage.setItem('taskPass', taskPass);
localStorage.setItem('userID', userID);
localStorage.setItem('userPin', userPin);
if (displayMessage) {
$("#resultDiv").removeClass("alert-danger").html('Values Stored OK').fadeTo(1500, 500).slideUp(500);
}
// getTaskDetails();
}
function time2Full(timeStr) {
return timeStr.substr(0,2)+':'+timeStr.substr(2,2);
}
function updateTaskInfo() {
$("#taskType").val(taskInfo['taskType']);
$("#taskStatus").val(taskInfo['taskStatus']);
$("#windowOpen").val( time2Full(taskInfo['windowOpen']) );
$("#windowClose").val(time2Full(taskInfo['windowClose']));
$("#startOpen").val(time2Full(taskInfo['startOpen']));
$("#landingDeadline").val(time2Full(taskInfo['landingDeadline']));
$("#minDistance").val(taskInfo['minDistance']);
}
function updateFields() {
$("#taskID").val(taskID);
$("#taskPass").val(taskPass);
$("#userID").val(userID);
$("#userPin").val(userPin);
// $("#waypoints").value(waypoints);
if (taskName) $("#taskName").html(taskName);
isPg=(taskCat==1)?1:0;
var isGliding=(taskCat==8)?1:0;
var isOther=(taskCat==1 || taskCat==8)?0:1;
if (isPg) showPg();
else if (isGliding) showGliding();
else showOther();
var selectHtml="<option value='0'>Select Turnpoint</option>\n";
for (index = 0; index < waypoints.length; ++index) {
var wpt=waypoints[index];
selectHtml+="<option value='"+wpt['name']+"'>"+wpt['name']+" - "+wpt['desc']+"</option>\n";
}
$(".tpselect").each( function($this){
$(this).html(selectHtml);
});
}
function getTaskDetails() {
if (!taskID ) return;
storeValues(0);
$.get('http://www.livetrack24.com/ajax.live_task.php',{
op:"getTaskDetails",taskID:taskID,taskPass:taskPass
}, function(result) {
var jsonResult = eval('(' + result + ')');
if ( jsonResult.result == 0 ) {
$("#resultDiv").addClass("alert-danger").html("Problem, Task is NOT loaded").fadeTo(1500, 500).slideUp(500);
return;
}
waypoints=jsonResult.waypoints;
taskName=jsonResult.name;
taskCat=jsonResult.taskCat;
localStorage.setItem('waypoints', JSON.stringify(waypoints) );
localStorage.setItem('taskName', taskName);
localStorage.setItem('taskCat',taskCat );
updateFields();
$("#resultDiv").removeClass("alert-danger").html("Loaded Task OK").fadeTo(1500, 500).slideUp(500);
}).fail(function() {
$("#resultDiv").addClass("alert-danger").html("Problem, Task is NOT loaded").fadeTo(1500, 500).slideUp(500);
});
}
function getTaskDefinition(waypoints,taskInfo) {
var taskTypes= {
'Race to Goal':'race',
'Elapsed Time':'elap',
'Open Distance':'open'
};
var taskType= taskTypes[ taskInfo['taskType'] ];
if (!taskType) taskType='race';
var taskDefStr='t1.1 '+taskType;
if (taskInfo['taskStatus']>0) {
if (taskInfo['taskStatus']==1) taskDefStr+='.p';
else if (taskInfo['taskStatus']==2) taskDefStr+='.c';
else if (taskInfo['taskStatus']==4) taskDefStr+='.s';
}
// all time are in minutes from 00:00, local times
taskDefStr+=' wo'+(taskInfo['windowOpen']);
taskDefStr+=' wc'+(taskInfo['windowClose']);
taskDefStr+=' so'+(taskInfo['startOpen']);
taskDefStr+=' tc'+(taskInfo['landingDeadline']);
// t1.1 race wo1340 wc+200 so+20 tc1900 d03 b42.ss.r6000 b43 b55 b54 a06.es.r1000 a06.gl.r200
for (index = 0; index < waypoints.length; ++index) {
var wpt=waypoints[index];
if (wpt['radius']!=400 && wpt['radius']!='' && wpt['radius']!=0 ) radStr='.r'+wpt['radius'];
else radStr='';
tpName=wpt['tpname'].substr(0,3).toLowerCase();
if (wpt['wType']=='START') {
tpName+='.ss';
} else if (wpt['wType']=='ES') {
if (wpt['gradientRatio'] > 0) {
tpName+='.ce.g';
gradientStr= Math.round( wpt['gradientRatio'] * 10 );
if (gradientStr % 10 == 0) gradientStr = Math.round( wpt['gradientRatio'] );
tpName+=gradientStr;
if (wpt['radius']>0) $radStr='.r'+wpt['radius'];
else radStr='';
} else {
tpName+='.es';
}
} else if (wpt['wType']=='GOAL' && wpt['shapeType']==2) {
tpName+='.gl';
}
taskDefStr+=' '+tpName+radStr;
}
return taskDefStr;
}
function conv_min2Time_2(mins) {
return sprintf("%02d%02d",mins/60,mins%60);
}
function createTaskDefinition() { // get the task from the form elements
storeValues(0);
var taskTurnpoints=[];
var tpNum=0;
for(var i=0; i<maxTpnum;i++) {
var row=$("#row_"+i);
var tpType=$("#tp"+i+"_type").val();
var tpName=$("#compTp"+i).val();
var shapeType=$("#tp"+i+"_shapeType").val();
var radius=$("#tp"+i+"_radius").val();
var angle=$("#tp"+i+"_angle").val();
var angle2=$("#tp"+i+"_angle2").val();
var shapeType2= $("#tp"+i+"_shapeType2").val();
var gradientRatio=$("#tp"+i+"_gradientRatio").val();
if (tpType!=0 && tpName!=0) {
taskTurnpoints[tpNum]= {
'wType':tpType,
'tpname':tpName,
'shapeType':shapeType,
'radius':radius,
'angle':angle,
'angle2':angle2,
'shapeType2':shapeType2,
'gradientRatio':gradientRatio
};
tpNum++;
}
}
taskInfo={};
taskInfo['taskType'] =$("#taskType").val(); // 'race';
taskInfo['taskStatus']=$("#taskStatus").val();
taskInfo['windowOpen']=timeProccess($("#windowOpen").val());
taskInfo['windowClose']=timeProccess($("#windowClose").val());
taskInfo['startOpen']=timeProccess($("#startOpen").val());
taskInfo['landingDeadline']=timeProccess($("#landingDeadline").val());
taskInfo['minDistance']=$("#minDistance").val();
localStorage.setItem('taskTurnpoints', JSON.stringify(taskTurnpoints) );
localStorage.setItem('taskInfo', JSON.stringify(taskInfo) );
taskDefinitionStr="LIVE "+userID+" "+userPin+" task "+taskID+" "+taskPass+ " "+taskInfo['minDistance']+" ";
taskDefinitionStr+= getTaskDefinition(taskTurnpoints,taskInfo);
$("#taskDefinitionStr").val(taskDefinitionStr);
copyToClipboard(document.getElementById("taskDefinitionStr"));
$("#resultDiv2").removeClass("alert-danger").html("Created Task Definition and copied it into the clipboard").fadeTo(2000, 500).slideUp(500);
}
function timeProccess(atime) {
var goodTime=atime.substr(0,2)+atime.substr(3,2);
return goodTime;
}
function addTurnpoints() {
$(".tpTr").show();
$("#AddTPbutton").hide();
}
function showPg() {
$(".tpAngle").hide();
//$(".tpGradient").show();
}
function showGliding() {
// $(".tpAngle").show();
$(".tpGradient").hide();
}
function showOther() {
$(".tpAngle").hide();
$(".tpGradient").hide();
}
function selectTurnpoint(idx) {
var sl=$('#compTp'+idx);
/*
tp_id= sl.options[sl.selectedIndex].value ; // Which menu item is selected
if (tp_id==-1) return;
var tpNameField=$('#tp'+idx+'_name');
var tpLatField=$('#tp'+idx+'_lat');
var tpLonField=$('#tp'+idx+'_lon');
var tpNameTpField=$('#tp'+idx+'_tpname');
tpNameField.value=tpName[tp_id];
tpLatField.value=tpLat[tp_id];
tpLonField.value=tpLon[tp_id];
tpNameTpField.value=tpNameTp[tp_id];
*/
}
function viewTypes(idx) {
var obj=$("#tp"+idx+"_shapeType");
var val=obj.val();
$("#tp"+idx+"_radiusText").hide();
$("#tp"+idx+"_angle2").parent().hide();
$("#tp"+idx+"_shapeType2").hide();
if (val==0){ // cylinder
$("#tp"+idx+"_gradientRatio").parent().hide();
$("#tp"+idx+"_angle").parent().hide();
} else if (val==1){ //cone
$("#tp"+idx+"_gradientRatio").parent().show();
$("#tp"+idx+"_angle").parent().hide();
} else if (val==2){ // line
$("#tp"+idx+"_gradientRatio").parent().hide();
$("#tp"+idx+"_angle").parent().hide();
$("#tp"+idx+"_radiusText").show();
} else if (val==3){ // wedge
$("#tp"+idx+"_gradientRatio").parent().hide();
$("#tp"+idx+"_angle").parent().show();
viewSubTypes3(idx);
}
}
function viewSubTypes3(idx) {
var val0=$("#tp"+idx+"_shapeType").val();
if (val0!=3) {
$("#tp"+idx+"_shapeType2").hide();
return;
}
$("#tp"+idx+"_shapeType2").show();
var val=$("#tp"+idx+"_shapeType2").val();
if (val==3){ // fixed value
$("#tp"+idx+"_angle2").parent().show();
} else {
$("#tp"+idx+"_angle2").parent().hide();
}
}
function showRows() {
realTpNum=taskTurnpoints.length;
showAddButton=0;
var html="";
for(var i=0; i<maxTpnum;i++) {
var style="";
if (realTpNum< maxTpnum0 && i>maxTpnum0) {
style=" style='display:none;' ";
showAddButton=1;
}
html+=" \
<tr id='row_"+i+"' class='tpTr' "+style+" > \
<td align='right' valign='top'> \
<strong>"+(i+1)+"</strong> \
</td> \
<td align='left' valign='middle'> \
";
var sel_0='', sel_1='', sel_2='', sel_3='', sel_4='', sel_5 = '';
var sel2_0='', sel2_1='', sel2_2='', sel2_3='';
var radius='';
var angle='';
var angle2='';
var shapeType2=0;
var gradientRatio='';
if (taskTurnpoints[i]) {
var type = taskTurnpoints[i]['wType'];
if (type == 'TAKEOFF') sel_1 = 'selected';
else if (type == 'START') sel_2 = 'selected';
else if (type == 'WAYPT') sel_3 = 'selected';
else if (type == 'ES') sel_4 = 'selected';
else if (type == 'GOAL') sel_5 = 'selected';
else sel_0 = 'selected';
radius=taskTurnpoints[i]['radius'];
angle=taskTurnpoints[i]['angle'];
angle2=taskTurnpoints[i]['angle2'];
gradientRatio=taskTurnpoints[i]['gradientRatio'];
var shapeType = taskTurnpoints[i]['shapeType'];
if (shapeType == 0) sel2_0 = 'selected';
else if (shapeType == 1) sel2_1 = 'selected';
else if (shapeType == 2) sel2_2 = 'selected';
else if (shapeType == 3) sel2_3 = 'selected';
else sel2_0 = 'selected';
}
//if (taskTurnpoints[i]['gradientRatio']>0) {
// taskTurnpoints[i]['shapeType'] = 1; // cone;
//}
/*
'wType':tpType,
'tpname':tpName,
'shapeType':shapeType,
'radius':radius,
'angle':angle,
'angle2':angle2,
'shapeType2':shapeType2,
'gradientRatio':gradientRatio
*/
html+="\n" +
"<select name='tp"+i+"_type' id='tp"+i+"_type'>\
<option value='0' "+sel_0+">- not used -</option>\n";
if ( taskCat<=4) html+="<option "+sel_1+">TAKEOFF</option>\n";
html+="<option "+sel_2+">START</option>\n";
html+="<option "+sel_3+">WAYPT</option>\n";
if ( taskCat==1) html+="<option "+sel_4+">ES</option>\n";
html+="<option "+sel_5+">GOAL</option> \
</select> \
</td> \
<td class='' align='left' valign='middle'> \
<select class='tpselect' onChange='javascript:selectTurnpoint("+i+");' name='compTp"+i+"' id='compTp"+i+"'> \
<option value='0'>Select Turnpoint from the list</option> \
</select> \
</td>\
<td class='tpType' align='left' valign='middle'> \
<select onchange='javascript:viewTypes("+i+");' name='tp"+i+"_shapeType' id='tp"+i+"_shapeType' > \
<option "+sel2_0+" value='0'>Cylinder</option> \
<option "+sel2_1+" value='1'>Cone</option> \
<option "+sel2_2+" value='2'>Line</option> \
<option "+sel2_3+" value='3'>Wedge</option> \
</select> \
<div class='tpGradient' style='display:none;'> \
<span class='label label-warning'>Gradient</span> \
<input name='tp"+i+"_gradientRatio' id='tp"+i+"_gradientRatio' type='text' size='3' value='"+gradientRatio+"'> \
</div> \
<select onchange='javascript:viewSubTypes3("+i+");' name='tp"+i+"_shapeType2' id='tp"+i+"_shapeType2' > \
<option value='0'>Symmetrical</option> \
<option value='1'>To Previous Point</option> \
<option value='2'>To Next Point</option> \
<option value='3'>Fixed Value</option> \
</select> \
<div class='tpAngle'> \
<span class='label label-warning'>Angle</span> \
<input name='tp"+i+"_angle' id='tp"+i+"_angle' type='text' size='3' value='"+angle+"' > \
</div> \
<div class='tpAngle'> \
<span class='label label-warning'>A12 Direction</span> \
<input name='tp"+i+"_angle2' id='tp"+i+"_angle2' type='text' size='3' value='"+angle2+"' > \
</div> \
</td> \
<td align='left' valign='middle'> \
<input class='tpRadius' id='tp"+i+"_radius' type='text' size='5' value='"+radius+"' >\
<span class='label label-warning' style='display:none;' id='tp"+i+"_radiusText'>Each Side Width</span>\
</td> \
</tr>";
}
if (showAddButton) {
html+="<tr>\
<td colspan='5' align='left' valign='middle'> \
<a href='javascript:addTurnpoints();' class='btn btn-warning btn-sm' id='AddTPbutton'>Add more Turnpoints</a>\
</td>\
</tr>";
}
html+="<tr>\
<td colspan='5' align='left' valign='middle'> \
<a href='javascript:resetTunpoints();' class='btn btn-danger btn-sm' id='resetTurnpoints'>Delete Task Turnpoints</a>\
</td>\
</tr>";
$('#headerRow').after(html);
}
function toogleStartGates() {
$(".moreStarts").toggle();
$(".lessStarts").toggle();
}
function copyToClipboard(elem) {
// create hidden text element, if it doesn't already exist
var targetId = "_hiddenCopyText_";
var isInput = elem.tagName === "INPUT" || elem.tagName === "TEXTAREA";
var origSelectionStart, origSelectionEnd;
if (isInput) {
// can just use the original source element for the selection and copy
target = elem;
origSelectionStart = elem.selectionStart;
origSelectionEnd = elem.selectionEnd;
} else {
// must use a temporary form element for the selection and copy
target = document.getElementById(targetId);
if (!target) {
var target = document.createElement("textarea");
target.style.position = "absolute";
target.style.left = "-9999px";
target.style.top = "0";
target.id = targetId;
document.body.appendChild(target);
}
target.textContent = elem.textContent;
}
// select the content
var currentFocus = document.activeElement;
target.focus();
target.setSelectionRange(0, target.value.length);
// copy the selection
var succeed;
try {
succeed = document.execCommand("copy");
} catch(e) {
succeed = false;
}
// restore original focus
if (currentFocus && typeof currentFocus.focus === "function") {
currentFocus.focus();
}
if (isInput) {
// restore prior selection
elem.setSelectionRange(origSelectionStart, origSelectionEnd);
} else {
// clear temporary content
target.textContent = "";
}
return succeed;
}
</script>
<style type="text/css">
.wptTable, .wptTable td , input ,select {
font-size:14px;
}
.taskAdminTable td {
padding-left:5px;
}
#mainTable {
background-color: #ffffff;
}
#mainForm {
/*width:800px;*/
}
body {background: #ffffff;}
.moreStarts{ display:none; }
.buttonDiv {
text-align: center;
}
.buttonDiv * {
margin-top: 10px;
}
#taskID {
background-color: #FFA466;
}
</style>
<div class="container" id="mainForm">
<div class="panel panel-primary">
<div class="panel-heading">
<div align="left" id="taskName">Task Name should appear here after Step 2</div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-6 col-md-3">Task ID</div>
<div class="col-xs-6 col-md-3"><input type="text" size="7" onkeyup="javascript:storeTaskID();" onchange="javascript:storeTaskID();" id="taskID" name="taskID" value=""></div>
<div class="col-xs-6 col-md-3">Task Password</div>
<div class="col-xs-6 col-md-3"><input type="text" size="7" onkeyup="javascript:storeTaskPass();" onchange="javascript:storeTaskPass();" id="taskPass" name="taskPass" value=""></div>
</div>
<div class="row">
<div class="col-xs-6 col-md-3">UserID</div>
<div class="col-xs-6 col-md-3"><input type="text" size="7" onkeyup="javascript:storeUserID();" onchange="javascript:storeUserID();" id="userID" name="userID" value=""></div>
<div class="col-xs-6 col-md-3">User Pin</div>
<div class="col-xs-6 col-md-3"><input type="text" size="7" onkeyup="javascript:storeUserPin();" onchange="javascript:storeUserPin();" id="userPin" name="userPin" value=""></div>
</div>
<div class="buttonDiv">
<!-- <a class="btn btn-lg btn-primary" href="javascript:storeValues(1);">1. Store Values (check TaskID !!!)</a> <BR> -->
<a class="btn btn-lg btn-warning" href="javascript:getTaskDetails();">1. Get Task Waypoints (only once)</a>
</div>
<div class="row">
<div class="col-xs-12">
<a class="btn btn-lg btn-primary" href="javascript:$('#instructions').toggle();">Instructions</a>
<div id="instructions" style="display:none;">
<ul>
<ul>
<li>To find your userID go to "My Account" -> "Edit account" and look at the url. Your userID is the numbers after user_id/ </li>
<li>Your User Pin is the "Mobile Pin 1" that can be found on "My Account" -> "Edit account"</li>
<li>Important: make sure that you have some SMS credits on your account and the phone number you have entered in your profile is
correct. LiveTrack24 will use your SMS credits and your declered phone number to send you back a confirmation of the task definition</li>
<li>When you click on the red button to send the SMS, you will be redirected to the default SMS app of yuor phone.
The phone number will be already be filled in, and the content of the SMS message will be copied to the clipboard. You will need
to manually paste it into the message and send the SMS. The cost of the SMS is a normal international SMS.
</li>
</ul>
</div>
</div>
</div>
<div id="resultDiv" class="alert alert-success" style="display:none;"></div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<div align="left" >Task Definition</div>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<textarea style="width:100%; height: auto;" id="taskDefinitionStr"></textarea>
<div class='buttonDiv'>
<a class='btn btn-lg btn-primary' href="javascript:createTaskDefinition();">2. Create Task Definition</a><BR>
<a class='btn btn-lg btn-primary' href="javascript:taskset();">3a. SET TASK via INTERNET</a><BR>
<a id="sendSMSbutton" class='btn btn-lg btn-danger' href="sms:+306972098522">3b. SET TASK via SMS</a>
</div>
</div>
</div>
<BR>
<div id="resultDiv2" class="alert alert-success" style="display:none;"></div>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<div align="left" >Task Type & Times</div>
</div>
<div class="panel-body">
<table align="center" class='mainText' cellspacing='0' cellpadding="5">
<tr class='green0'>
<td align="right" valign="top"><strong>Type of Task</strong></td>
<td align="left" valign="top">
<strong>
<select name="taskType" type="text" id="taskType" >
<option value='Race to Goal'>Race to Goal</option>
<option value='Elapsed Time' $sel >Elapsed Time</option>
<option value='Open Distance'>Open Distance</option>
</select>
</strong>
</td>
</tr >
<tr class='green0'>
<td align="right" valign="top"><strong>Task Status</strong></td>
<td align="left" valign="top"><strong>
<select name="taskStatus" type="text" id="taskStatus" >
<option value='0'>Active</option>
<option value='1'>Provisional</option>
<option value='2'>Canceled</option>
<option value='4'>Stopped</option>
</select>
</td>
</tr>
<tr class='green0'>
<td align="right" valign="top" colspan="2">
<div class="alert alert-warning">
Enter All Times in hh:mm and in Local Timezone
</div>
</td>
</tr>
<tr class='green0'>
<td align="right" valign="top"><strong>Window Open</strong></td>
<td align="left" valign="top"><input name="windowOpen" type="text" id="windowOpen" value="12:00" size="10" maxlength="10" />
</td>
</tr>
<tr class='green0'>
<td align="right" valign="top"><strong>Window Close</strong></td>
<td align="left" valign="top"><input name="windowClose" type="text" id="windowClose" value="15:00" size="10" maxlength="10" />
</td>
</tr>
<tr class='green0'>
<td align="right" valign="top"><strong>Start Gate Open</strong></td>
<td align="left" valign="top">
<input name="startOpen" type="text" id="startOpen" value="13:00" size="10" maxlength="10" />
</td>
</tr>
<tr class="lessStarts">
<td colspan="2" align="left" valign="top">
<a id="buttonMoreStarts" class='btn btn-primary'href="javascript:toogleStartGates();">More Start gates ?</a>
</td>
</tr>
<tr class="moreStarts">
<td colspan="2" align="left" valign="top">
<a id="buttonMoreStarts" class='btn btn-primary'href="javascript:toogleStartGates();">Less Start gates ?</a>
<div class="alert alert-warning">
Enter All Times in hh:mm and in Local Timezone
Leave as 00:00 or blank if no multiple start gates
</div>
</td>
</tr>
<tr class="moreStarts">
<td align="right" valign="top"><strong>Start Gate Open #2</strong></td>
<td align="left" valign="top">
<input name="startOpen2" type="text" id="startOpen2" value="" size="10" maxlength="10" />
</td>
</tr>
<tr class="moreStarts">
<td align="right" valign="top"><strong>Start Gate Open #3</strong></td>
<td align="left" valign="top">
<input name="startOpen3" type="text" id="startOpen3" value="" size="10" maxlength="10" />
</td>
</tr>
<tr class="moreStarts">
<td align="right" valign="top"><strong>Start Gate Open #4</strong></td>
<td align="left" valign="top">
<input name="startOpen4" type="text" id="startOpen4" value="" size="10" maxlength="10" />
</td>
</tr>
<tr class="moreStarts">
<td align="right" valign="top"><strong>Start Gate Open #5</strong></td>
<td align="left" valign="top">
<input name="startOpen5" type="text" id="startOpen5" value="" size="10" maxlength="10" />
</td>
</tr>
<tr class="moreStarts">
<td align="right" valign="top"><strong>Start Gate Open #6</strong></td>
<td align="left" valign="top">
<input name="startOpen6" type="text" id="startOpen6" value="" size="10" maxlength="10" />
</td>
</tr>
<tr class='green0'>
<td align="right" valign="top"><strong>Landing Deadline</strong></td>
<td align="left" valign="top"><input name="landingDeadline" type="text" id="landingDeadline" value="20:00" size="10" maxlength="10" />
</td>
</tr>
<tr>
<td align="right" valign="top"><strong>Min Distance (in Km)</strong></td>
<td align="left" valign="top"><strong>
<input name="minDistance" type="text" id="minDistance" value="5" size="10" maxlength="10" />
</strong></td>
</tr>
</table>
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<div align="left" >Task Tunrpoints</div>
</div>
<div class="panel-body">
<table id="mainTable" width="100%" align="center" class='mainText taskAdminTable' cellspacing='0'>
<tr id="headerRow">
<th>#</th>
<th>Type</th>
<th>Turnpoint</th>
<th class="tpType" >Type</th>
<th>Radius (in m)</th>
</tr>
</table>
</div>
</div>
</div>
<script>
/**
@license
sprintf.js from the php.js project - https://github.com/kvz/phpjs
Directly from https://github.com/kvz/phpjs/blob/master/functions/strings/sprintf.js
php.js is copyright 2012 Kevin van Zonneveld.
*/
function sprintf () {
// http://kevin.vanzonneveld.net
// + original by: Ash Searle (http://hexmen.com/blog/)
// + namespaced by: Michael White (http://getsprink.com)
// + tweaked by: Jack
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Paulo Freitas
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Brett Zamir (http://brett-zamir.me)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: Dj
// + improved by: Allidylls
// * example 1: sprintf("%01.2f", 123.1);
// * returns 1: 123.10
// * example 2: sprintf("[%10s]", 'monkey');
// * returns 2: '[ monkey]'
// * example 3: sprintf("[%'#10s]", 'monkey');
// * returns 3: '[####monkey]'
// * example 4: sprintf("%d", 123456789012345);
// * returns 4: '123456789012345'
var regex = /%%|%(\d+\$)?([-+\'#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuideEfFgG])/g;
var a = arguments,
i = 0,
format = a[i++];
// pad()
var pad = function (str, len, chr, leftJustify) {
if (!chr) {
chr = ' ';
}
var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
return leftJustify ? str + padding : padding + str;
};
// justify()
var justify = function (value, prefix, leftJustify, minWidth, zeroPad, customPadChar) {
var diff = minWidth - value.length;
if (diff > 0) {
if (leftJustify || !zeroPad) {
value = pad(value, minWidth, customPadChar, leftJustify);
} else {
value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
}
}
return value;
};
// formatBaseX()
var formatBaseX = function (value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
// Note: casts negative numbers to positive ones
var number = value >>> 0;
prefix = prefix && number && {
'2': '0b',
'8': '0',
'16': '0x'
}[base] || '';
value = prefix + pad(number.toString(base), precision || 0, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
};
// formatString()
var formatString = function (value, leftJustify, minWidth, precision, zeroPad, customPadChar) {
if (precision != null) {
value = value.slice(0, precision);
}
return justify(value, '', leftJustify, minWidth, zeroPad, customPadChar);
};
// doFormat()
var doFormat = function (substring, valueIndex, flags, minWidth, _, precision, type) {
var number;
var prefix;
var method;
var textTransform;
var value;
if (substring == '%%') {
return '%';
}
// parse flags
var leftJustify = false,
positivePrefix = '',
zeroPad = false,
prefixBaseX = false,
customPadChar = ' ';
var flagsl = flags.length;
for (var j = 0; flags && j < flagsl; j++) {
switch (flags.charAt(j)) {
case ' ':
positivePrefix = ' ';
break;
case '+':
positivePrefix = '+';
break;
case '-':
leftJustify = true;
break;
case "'":
customPadChar = flags.charAt(j + 1);
break;
case '0':
zeroPad = true;
break;
case '#':
prefixBaseX = true;
break;
}
}
// parameters may be null, undefined, empty-string or real valued
// we want to ignore null, undefined and empty-string values
if (!minWidth) {