-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.js
143 lines (134 loc) · 3.88 KB
/
client.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
"use strict";
COBI.init('token');
// Make clock appear in upper right corner
COBI.app.clockVisible.write(false);
// Also listen to standard controller events
COBI.devkit.overrideThumbControllerMapping.write(true);
// Disable Reordering in Experience
var inEditMode = (COBI.parameters.state() == COBI.state.edit);
// React on theme changes
COBI.app.theme.subscribe(function (value) {
$('.unit').css('color', 'rgb(' + value.baseColor.red + ',' + value.baseColor.green + ',' + value.baseColor.blue + ')');
});
// Display detailled item names if touch interaction is allowed
COBI.app.touchInteractionEnabled.subscribe(function(touchInteractionEnabled) {
// updateInterfaceVisibility(touchInteractionEnabled);
if (touchInteractionEnabled) {
$('#maingrid').removeClass('grid2');
if (inEditMode) {
$('#maingrid').addClass('grid3');
} else {
$('#maingrid').addClass('grid1');
}
} else {
$('#maingrid').removeClass('grid1 grid3');
$('#maingrid').addClass('grid2');
}
onWindowResize();
});
var biergarten = makeBiergarten('$h4cKth34lpS');
// Define id, name, events, formatting functions, units and default value for each item
var definitions = [
{
id: 'data-field1',
name: 'POI VISITS',
subscribe: biergarten.subscribe,
unsubscribe: biergarten.unsubscribe,
formatter: formatInt,
unit: 'highlights',
defaultValue: '-',
color: 0xe8596c,
value: 0,
xscale: 100,
yoff: 25,
},
{
id: 'data-field5',
name: 'Avg Speed',
subscribe: COBI.tourService.averageSpeed.subscribe,
unsubscribe: COBI.tourService.averageSpeed.unsubscribe,
formatter: formatSpeedDot1,
unit: 'Ø km/h',
defaultValue: '-',
value: 0.,
},
{
id: 'data-field6',
name: 'User Power',
subscribe: COBI.rideService.userPower.subscribe,
unsubscribe: COBI.rideService.userPower.unsubscribe,
formatter: formatInt,
unit: 'watts',
defaultValue: '-',
value: 0,
},
{
id: 'data-field7',
name: 'Cadence',
subscribe: COBI.rideService.cadence.subscribe,
unsubscribe: COBI.rideService.cadence.unsubscribe,
formatter: formatInt,
unit: 'rpm',
defaultValue: '-',
value: 0,
},
{
id: 'data-field2',
name: 'Distance',
subscribe: COBI.tourService.ridingDistance.subscribe,
unsubscribe: COBI.tourService.ridingDistance.unsubscribe,
formatter: formatDistanceDot1,
unit: 'km',
defaultValue: '-',
color: 0xd1ef7f,
xscale: 35,
yoff: 25,
value: 0
},
{
id: 'calories',
name: 'Calories',
subscribe: COBI.tourService.calories.subscribe,
unsubscribe: COBI.tourService.calories.unsubscribe,
formatter: formatInt,
unit: 'kcal',
defaultValue: '-',
value: 0
},
{
id: 'data-field4',
name: 'Ascent',
subscribe: COBI.tourService.ascent.subscribe,
unsubscribe: COBI.tourService.ascent.unsubscribe,
formatter: formatInt,
unit: 'm',
defaultValue: '-',
color: 0x58c6e2,
xscale: 50,
yoff: 25,
value: 0
},
{
id: 'heart_rate',
name: 'Heart Rate',
subscribe: COBI.rideService.heartRate.subscribe,
unsubscribe: COBI.rideService.heartRate.unsubscribe,
formatter: formatInt,
unit: 'bpm',
defaultValue: '-',
value: 0
},
{
id: 'data-field3',
name: 'Duration',
subscribe: COBI.tourService.ridingDuration.subscribe,
unsubscribe: COBI.tourService.ridingDuration.unsubscribe,
formatter: formatMins,
unit: 'min',
defaultValue: '-',
color: 0xf4cf61,
xscale: 25,
yoff: 25,
value: 0
},
];