-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.html
201 lines (175 loc) · 5.45 KB
/
frontend.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
<html>
<head>
<title>Bushido Rider</title>
<meta charset="utf-8">
<script src="bushido.usb.js"></script>
<script src="bushido.sim.js"></script>
<!-- Include the CesiumJS JavaScript and CSS files -->
<script src="https://cesium.com/downloads/cesiumjs/releases/1.74/Build/Cesium/Cesium.js" charset="UTF-8"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.74/Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<script src="lib/Chart.min.js" charset="UTF-8"></script>
<link href="lib/Chart.min.css" rel="stylesheet">
<script src="cesium.token.js"></script>
<style>
#game {
height: 100%;
width: 100%;
display: none;
flex-direction: column;
justify-content: stretch;
}
#map {
flex-grow: 1;
position: relative;
}
html {
height: 100%;
}
.cesium-viewer {
position: absolute;
width: 100%;
height: 100%;
}
#chart {
flex: 1;
max-width: 85vw;
}
.ct-series-a .ct-line,
.ct-series-a .ct-point {
stroke-width: 5px !important;
stroke: grey !important;
}
.ct-series-b .ct-line,
.ct-series-b .ct-point {
stroke-width: 20px !important;
stroke: #267fca !important;
}
#overlay {
position: absolute;
z-index: 1000;
top: 20px;
right: 20px;
width: 400px;
height: 200px;
background: rgba(255, 255, 255, 0.8);
font-size: 35px;
color: black;
padding: 40px;
}
#overlay-paused {
position: absolute;
z-index: 1000;
top: 20px;
right: 20px;
width: 400px;
height: 250px;
background: rgba(255, 255, 255, 0.8);
font-size: 35px;
color: black;
padding: 40px;
display: flex;
flex-direction: column;
justify-content: space-between;
}
#pause {
position: absolute;
z-index: 1001;
left: 50vw;
top: 50vh;
width: auto;
background: #267fca;
color: white;
opacity: 0.8;
border-radius: 20px;
font-size: 40px;
text-align: center;
padding: 10px;
animation: blink-animation 1s steps(5, start) infinite;
margin: -66px -38px;
}
#lower {
flex-shrink: 0;
height: 200px;
display: flex;
}
#forward {
width: 200px;
background-color: darkgreen;
text-align: center;
font-size: 40px;
display: flex;
flex-direction: column;
justify-content: center;
color: white;
}
#rewind {
width: 200px;
background-color: darkred;
text-align: center;
font-size: 40px;
display: flex;
flex-direction: column;
justify-content: center;
color: white;
}
@keyframes blink-animation {
to {
visibility: hidden;
}
}
</style>
<link rel="stylesheet" href="./lib/chartist.css" />
</head>
<body>
<div id="start">
<label for="gpxFile">Select GPX file:</label><input type="file" id="gpxFile" multiple="false" accept=".gpx">
<input type="button" id="startConversionButton" value="Convert to Tacx Workout"></input>
</div>
<div id="game">
<div id="pause">Paused</div>
<div id="overlay"></div>
<div id="overlay-paused"></div>
<div id="map"></div>
<div id="lower">
<div id="rewind"><span>- 1km</span></div>
<canvas id="chart"></canvas>
<div id="forward"><span>+ 1km</span></div>
</div>
</div>
<script src="./lib/spline.js"></script>
<script src="./lib/gpxParser.js"></script>
<script src='https://unpkg.com/@turf/turf/turf.min.js'></script>
<script src="./lib/chartist.js"></script>
<script>
const bushidoConnection = new BushidoUSB(console);
// let distance = 0;
// let speed = 20;
// bushidoConnection.getData = function () {
// return {
// speed: speed * 3.6,
// cadence: Math.random() * 100 % 60,
// power: Math.random() * 200,
// distance,
// };
// }
const bushidoSimulator = new BushidoSimulator(bushidoConnection, {
gpxFileInputId: "gpxFile",
overlayElementId: "overlay",
gameElementId: "game",
mapElementId: "map",
startElementId: "start",
pauseElementId: "pause",
forwardButtonId: "forward",
rewindButtonId: "rewind",
});
// window.setInterval(() => {
// if (bushidoConnection.isConnected()) {
// distance += speed;
// bushidoSimulator.onDistanceUpdated(distance);
// bushidoSimulator.onDataUpdated(bushidoConnection.getData());
// speed = Math.abs(speed + Math.random() * 10 - 5);
// }
// }, 1000);
</script>
</body>
</html>