Skip to content

Commit b050ac3

Browse files
authored
fix: update speed overlay references (#288)
* fix: update reference to kph I didn't just update the overlay's filename as that would break peoples setups. * fix: update fix * remove comment * fix: add kmh copy
1 parent e8aee5c commit b050ac3

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

public/speed/kmh.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</span> km/h</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 speedInKmh = (speed * 3.6) | 0;
17+
document.getElementById("speed").innerText = speedInKmh > 0 ? speedInKmh : 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
@@ -20,6 +20,7 @@ function SpeedEditor({
2020
onTextStyleChange,
2121
}) {
2222
const [units, setUnits] = useState("mph");
23+
2324
const url = `https://overlays.rtirl.com/speed/${units}.html?key=${pullKey.value}`;
2425

2526
return (

0 commit comments

Comments
 (0)