From 0cb10203c7a78e9410ab8779ef18d31ee0d7f5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Thu, 15 Sep 2022 10:01:28 +0200 Subject: [PATCH] Only show riders when tracking timestamp is newer than 3 hours ago --- main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.js b/main.js index 8720e82..37fe88c 100644 --- a/main.js +++ b/main.js @@ -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];