From fd5860dbb46063f229492354af88f1ad3701772c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 14 Nov 2010 11:59:51 +0100 Subject: [PATCH] Update local Sones every 5 seconds. --- src/main/resources/static/javascript/sone.js | 16 +++++++++++----- src/main/resources/templates/include/head.html | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 361fc53..01c04a1 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -100,17 +100,20 @@ function getTranslation(key, callback) { * * @param soneId * The ID of the Sone + * @param local + * true if the Sone is local, false + * otherwise */ -function getSoneStatus(soneId) { +function getSoneStatus(soneId, local) { $.getJSON("ajax/getSoneStatus.ajax", {"sone": soneId}, function(data, textStatus) { updateSoneStatus(soneId, data.name, data.status, data.modified, data.lastUpdated); /* seconds! */ updateInterval = 60; - if (data.modified || (data.status == "downloading") || (data.status == "inserting")) { + if (local || data.modified || (data.status == "downloading") || (data.status == "inserting")) { updateInterval = 5; } setTimeout(function() { - getSoneStatus(soneId); + getSoneStatus(soneId, local); }, updateInterval * 1000); }); } @@ -157,15 +160,18 @@ var watchedSones = {}; * * @param soneId * The ID of the Sone to watch + * @param local + * true if the Sone is local, false + * otherwise */ -function watchSone(soneId) { +function watchSone(soneId, local) { if (watchedSones[soneId]) { return; } watchedSones[soneId] = true; (function(soneId) { setTimeout(function() { - getSoneStatus(soneId); + getSoneStatus(soneId, local); }, 5000); })(soneId); } diff --git a/src/main/resources/templates/include/head.html b/src/main/resources/templates/include/head.html index 8061409..858851a 100644 --- a/src/main/resources/templates/include/head.html +++ b/src/main/resources/templates/include/head.html @@ -18,7 +18,7 @@ /* these functions are necessary for updating Sone statuses. */ $(document).ready(function() { $("#sone .sone").each(function() { - watchSone($(this).find(".id").text()); + watchSone($(this).find(".id").text(), $(this).hasClass("local")); }); }); -- 2.7.4