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);
});
}
$("#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>