changeset 76:b0a1fa90c77d

Livemap: Cancel prior XHR when changing client/secret
author Lewin Bormann <lbo@spheniscida.de>
date Sat, 05 Dec 2020 12:49:00 +0100
parents afefa4d60653
children 6cae472afb75
files assets/livemap.html
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/assets/livemap.html	Sat Dec 05 11:46:33 2020 +0100
+++ b/assets/livemap.html	Sat Dec 05 12:49:00 2020 +0100
@@ -113,6 +113,7 @@
         xhr.send();
     }
 
+    var lastXHR = null;
     // Ask for updates. This request will hang until timeout is reached or
     // an update arrives.
     function waitforupdate() {
@@ -129,11 +130,13 @@
         xhr.open('GET', url, true);
         xhr.onreadystatechange = function() { xhrcallback(xhr) };
         xhr.send();
+        lastXHR = xhr;
     }
 
     // "Go!" was clicked - clear markers and fetch data for new source.
     function buttonGoClicked() {
         clearAllMarkers();
+        lastXHR.abort();
         updateURL(getClient(), getSecret());
         // Accelerate display.
         backfill();