From e433f18b1d3bdce3c6b03dafb81b8ea98a23c70e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 21 Oct 2010 14:20:26 +0200 Subject: [PATCH] Make update interval depend on the age of the Sone. --- src/main/resources/templates/include/viewSone.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/resources/templates/include/viewSone.html b/src/main/resources/templates/include/viewSone.html index 896f670..0cf4545 100644 --- a/src/main/resources/templates/include/viewSone.html +++ b/src/main/resources/templates/include/viewSone.html @@ -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); }); } -- 2.7.4