Skip to content

Commit 4dbdd33

Browse files
authored
Add Minutes Per KM Support For Running (#282)
* Create minperkm.html Added a speed output for minutes per kilometer for running * Update SpeedEditor.jsx * Update minperkm.html * Update minperkm.html
1 parent 717e714 commit 4dbdd33

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

public/speed/minperkm.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="https://cdn.jsdelivr.net/npm/@rtirl/api@latest/lib/index.min.js"></script>
5+
<script defer src="../css.js"></script>
6+
</head>
7+
<body>
8+
<div id="text"><span id="speed">0:00</span> /km</div>
9+
<script>
10+
const pullKey = new URLSearchParams(window.location.search).get("key");
11+
var timer;
12+
RealtimeIRL.forPullKey(pullKey).addSpeedListener(function (speed) {
13+
14+
clearTimeout(timer); //don't reset to 0 if moving
15+
16+
const speedInMinsPerKm = (16.66666666666666667 / speed);
17+
document.getElementById("speed").innerText = (speedInMinsPerKm | 0)+':'+((speedInMinsPerKm % 1)*60 | 0).toString().padStart(2, '0');
18+
19+
timer = setTimeout(() => { //reset to 0 if not moving for 30 sec
20+
document.getElementById("speed").innerText = 0;
21+
}, 30000);
22+
23+
});
24+
</script>
25+
</body>
26+
</html>

web-editor/src/screen/SpeedEditor.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { scrollbarStyles } from "../theme/editorTheme";
1010
const speedOptions = [
1111
{ name: "MPH", value: "mph" },
1212
{ name: "KMH", value: "kph" },
13+
{ name: "MIN/KM", value: "minperkm" },
1314
];
1415

1516
function SpeedEditor({

0 commit comments

Comments
 (0)