From d11a2423f2cbc243fd9fb60fbd73cdc233c5fb99 Mon Sep 17 00:00:00 2001 From: Matthias Wirth Date: Thu, 23 May 2024 21:05:27 +0200 Subject: [PATCH] bit more precise data fetch interval --- html/script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/html/script.js b/html/script.js index 6c5e7b7..36c63d6 100644 --- a/html/script.js +++ b/html/script.js @@ -532,10 +532,10 @@ function fetchData(options) { return; } let currentTime = new Date().getTime(); - + const refreshMs = refreshInt() if (!options.force) { if ( - currentTime - lastFetch < refreshInt() + currentTime - lastFetch < refreshMs || pendingFetches > 0 || OLMap.getView().getInteracting() || OLMap.getView().getAnimating() @@ -543,8 +543,9 @@ function fetchData(options) { return; } } + setTimeout(fetchData, refreshMs); if (debugFetch) { - console.log('Time since last fetch: ' + (currentTime - lastFetch)/1000); + console.log('Time since last fetch: ' + (currentTime - lastFetch) + ' ms'); } lastFetch = currentTime; @@ -623,7 +624,7 @@ function fetchData(options) { } else if (globeIndex) { let indexes = globeIndexes(); - const ancient = (currentTime - 2 * refreshInt() / globeSimLoad * globeTilesViewCount) / 1000; + const ancient = (currentTime - 2 * refreshMs / globeSimLoad * globeTilesViewCount) / 1000; for (let i in indexes) { const k = indexes[i]; if (globeIndexNow[k] < ancient) {