Make update interval depend on the age of the Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 21 Oct 2010 12:20:26 +0000 (14:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 21 Oct 2010 12:20:26 +0000 (14:20 +0200)
src/main/resources/templates/include/viewSone.html

index 896f670..0cf4545 100644 (file)
@@ -3,9 +3,16 @@
        function getStatus(soneId) {
                $.getJSON("ajax/getSoneStatus.ajax", {"sone": soneId}, function(data, textStatus) {
                        updateStatus(soneId, data.status, data.modified, data.lastUpdated);
+                       /* seconds! */
+                       updateInterval = 60;
+                       if (data.age < 600) {
+                               updateInterval = 5;
+                       } else if (data.age < 86400) {
+                               updateInterval = 30;
+                       }
                        setTimeout(function() {
                                getStatus(soneId);
-                       }, 5000);
+                       }, updateInterval * 1000);
                });
        }