From 403bcebd8de71dcb793c3f15138bc2df6431ae06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Apr 2011 20:21:25 +0200 Subject: [PATCH] Update relative times on each status update. --- .../java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java | 2 +- src/main/resources/static/javascript/sone.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java index 09a9d2b..7d581d7 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -170,7 +170,7 @@ public class GetStatusAjaxPage extends JsonPage { synchronized (dateFormat) { jsonSone.put("lastUpdated", dateFormat.format(new Date(sone.getTime()))); } - jsonSone.put("age", (System.currentTimeMillis() - sone.getTime()) / 1000); + jsonSone.put("lastUpdatedText", GetTimesAjaxPage.getTime(webInterface, System.currentTimeMillis() - sone.getTime()).getText()); return jsonSone; } diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 5aaa6a5..8065b73 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -146,7 +146,7 @@ function filterSoneId(soneId) { * @param lastUpdated * The date and time of the last update (formatted for display) */ -function updateSoneStatus(soneId, name, status, modified, locked, lastUpdated) { +function updateSoneStatus(soneId, name, status, modified, locked, lastUpdated, lastUpdatedText) { $("#sone .sone." + filterSoneId(soneId)). toggleClass("unknown", status == "unknown"). toggleClass("idle", status == "idle"). @@ -156,7 +156,7 @@ function updateSoneStatus(soneId, name, status, modified, locked, lastUpdated) { $("#sone .sone." + filterSoneId(soneId) + " .lock").toggleClass("hidden", locked); $("#sone .sone." + filterSoneId(soneId) + " .unlock").toggleClass("hidden", !locked); if (lastUpdated != null) { - $("#sone .sone." + filterSoneId(soneId) + " .last-update span.time").text(lastUpdated); + $("#sone .sone." + filterSoneId(soneId) + " .last-update span.time").attr("title", lastUpdated).text(lastUpdatedText); } else { getTranslation("View.Sone.Text.UnknownDate", function(unknown) { $("#sone .sone." + filterSoneId(soneId) + " .last-update span.time").text(unknown); @@ -982,7 +982,7 @@ function getStatus() { if ((data != null) && data.success) { /* process Sone information. */ $.each(data.sones, function(index, value) { - updateSoneStatus(value.id, value.name, value.status, value.modified, value.locked, value.lastUpdatedUnknown ? null : value.lastUpdated); + updateSoneStatus(value.id, value.name, value.status, value.modified, value.locked, value.lastUpdatedUnknown ? null : value.lastUpdated, value.lastUpdatedText); }); /* search for removed notifications. */ $("#sone #notification-area .notification").each(function() { -- 2.7.4