Only register each Sone once!
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 21 Oct 2010 12:12:49 +0000 (14:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 21 Oct 2010 12:12:49 +0000 (14:12 +0200)
src/main/resources/templates/include/viewSone.html

index e054122..896f670 100644 (file)
                $("#sone .sone#" + soneId + " .last-update span.time").text(lastUpdated);
        }
 
+       registeredSones = {};
+
        $(document).ready(function() {
                $("#sone .sone").each(function() {
-                       getStatus($(this).attr("id"));
+                       soneId = $(this).attr("id");
+                       if (registeredSones[soneId]) {
+                               return;
+                       }
+                       registeredSones[soneId] = true;
+                       (function(soneId) {
+                               setTimeout(function() {
+                                       getStatus(soneId);
+                               }, 5000);
+                       })(soneId);
                });
        });
 </script>