-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
105 lines (100 loc) · 3.85 KB
/
main.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
/*
function onLap() { trace('--- onLap ---'); }
function onAutoLap() { trace('--- onAutoLap ---'); }
function onInterval() { trace('--- onInterval ---'); }
function onPoolLength() { trace('--- onPoolLength ---'); }
function onExerciseStart() { trace('--- onExerciseStart ---'); }
function onExercisePause() { trace('--- onExercisePause ---'); }
function onExerciseContinue() { trace('--- onExerciseContinue ---'); }
function onExerciseEnd() { trace('--- onExerciseEnd ---'); }
function onExercisePause() { trace('--- onExerciseEnd ---'); }
function onExerciseContinue() { trace('--- onExerciseEnd ---'); }
*/
var FirstSectorLap, SecondSectorLap, ThirdSectorLap, FourthSectorLap, LastLapDistance;
function evaluate(input) {
if (((input.Distance - LastLapDistance) >= 99)&&((input.Distance - LastLapDistance)< 104)){
FirstSectorLap = input.CurrentDuration;
}else if (((input.Distance - LastLapDistance)>= 199)&&((input.Distance - LastLapDistance)< 204)){
SecondSectorLap = input.CurrentDuration - FirstSectorLap;
}else if (((input.Distance - LastLapDistance)>= 299)&&((input.Distance - LastLapDistance)< 304)){
ThirdSectorLap = input.CurrentDuration - (FirstSectorLap + SecondSectorLap ) ;
}else if (((input.Distance - LastLapDistance)>= 399)&&((input.Distance - LastLapDistance)< 404)){
FourthSectorLap = input.CurrentDuration - (FirstSectorLap + SecondSectorLap + ThirdSectorLap);
// Trigger lap once
LastLapDistance = input.Distance;
$.put("/Activity/Trigger", 0);
}
}
function onExerciseStart(input, output) {
// Initializing Variables
output.currentLap = 1;
LastLapDistance = 0;
output.fastLap = null;
output.fastLapDuration = null;
output.FirstSector = null;
output.SecondSector = null;
output.ThirdSector = null;
output.FourthSector = null;
FirstSectorLap = null;
SecondSectorLap = null;
ThirdSectorLap = null;
FourthSectorLap = null;
output.fastLapOneHundred = null;
output.fastLapTwoHundred = null;
output.fastLapThreeHundred = null;
output.fastLapFourHundred = null;
}
function onLap(input, output) {
if (output.currentLap == 1) {
output.fastLapDuration = input.PreviousDuration;
output.fastLap = output.currentLap;
output.fastLapOneHundred = output.currentLap;
output.fastLapTwoHundred = output.currentLap;
output.fastLapThreeHundred = output.currentLap;
output.fastLapFourHundred = output.currentLap;
output.FirstSector = FirstSectorLap;
output.SecondSector = SecondSectorLap;
output.ThirdSector = ThirdSectorLap;
output.FourthSector = FourthSectorLap;
}else {
if (input.PreviousDuration < output.fastLapDuration) {
output.fastLapDuration = input.PreviousDuration;
output.fastLap = output.currentLap;
}
if (FirstSectorLap < output.FirstSector) {
output.FirstSector = FirstSectorLap;
output.fastLapOneHundred = output.currentLap;
}
if (SecondSectorLap < output.SecondSector){
output.SecondSector = SecondSectorLap;
output.fastLapTwoHundred = output.currentLap;
}
if (ThirdSectorLap < output.ThirdSector){
output.ThirdSector = ThirdSectorLap;
output.fastLapThreeHundred = output.currentLap;
}
if (FourthSectorLap < output.FourthSector){
output.FourthSector = FourthSectorLap;
output.fastLapFourHundred = output.currentLap;
}
}
output.currentLap = output.currentLap + 1;
FirstSectorLap = null;
SecondSectorLap = null;
ThirdSectorLap = null;
FourthSectorLap = null;
}
function getUserInterface(input, output) {
return {
template: 't'
};
}
// This is called also when user backs from exercise start panel without starting
// exercise. onExerciseEnd() is not working at all as zapp gets disabled before
// it is called (and it would be called only when exercise is really started).
function getSummaryOutputs(input, output) {
return [
{
},
];
}