Only show riders when tracking timestamp is newer than 3 hours ago

This commit is contained in:
Râu Cao 2022-09-15 10:01:28 +02:00
parent a8c0aefbd6
commit 0cb10203c7
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
1 changed files with 6 additions and 0 deletions

View File

@ -245,6 +245,11 @@ async function main() {
map.addOverlay(overlayElement);
}
function isRecentTimestamp (tst) {
// newer than 2 hours ago?
return (tst * 1000) > (Date.now() - 2*60*60*1000);
}
function updateData(startInterval=false) {
fetch('https://r2b22.kip.pe/last.json')
.then(response => response.json())
@ -255,6 +260,7 @@ async function main() {
for (const item of data) {
if (!tourStatus.participants.includes(item.name)) continue;
if (!isRecentTimestamp(item.tst)) continue;
createParticipantHTML(item.name);
createParticipantOverlay(item.name);
const overlay = peopleOverlays[item.name];