From: David ‘Bombe’ Roden Date: Thu, 21 Oct 2010 12:20:26 +0000 (+0200) Subject: Make update interval depend on the age of the Sone. X-Git-Tag: 0.1-RC1~115 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e433f18b1d3bdce3c6b03dafb81b8ea98a23c70e;hp=4c10e20e66c17da19aa94b5d81de385d2d885eee;p=Sone.git Make update interval depend on the age of the Sone. --- 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); }); }