diff --git a/static/js/client.js b/static/js/client.js index 8d07beb5d..96a39931b 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1080,22 +1080,25 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; } function timeAgo(time) { + var now = Date.now() , offset = time == -1 ? -1 : (now - time) / 1000 , parts = {}; - if (offset < MINUTE_IN_SECS * -5) parts = { label: 'in the future' }; + if (offset < MINUTE_IN_SECS * -5) parts = { value: 'in the future' }; else if (offset == -1) parts = { label: 'time ago' }; else if (offset <= MINUTE_IN_SECS * 2) parts = { value: 1, label: 'min ago' }; else if (offset < (MINUTE_IN_SECS * 60)) parts = { value: Math.round(Math.abs(offset / MINUTE_IN_SECS)), label: 'mins ago' }; else if (offset < (HOUR_IN_SECS * 2)) parts = { value: 1, label: 'hr ago' }; else if (offset < (HOUR_IN_SECS * 24)) parts = { value: Math.round(Math.abs(offset / HOUR_IN_SECS)), label: 'hrs ago' }; else if (offset < DAY_IN_SECS) parts = { value: 1, label: 'day ago' }; - else if (offset < (DAY_IN_SECS * 7)) parts = { value: Math.round(Math.abs(offset / DAY_IN_SECS)), label: 'day ago' }; - else if (offset < (WEEK_IN_SECS * 52)) parts = { value: Math.round(Math.abs(offset / WEEK_IN_SECS)), label: 'week ago' }; - else parts = { label: 'a long time ago' }; + else if (offset <= (DAY_IN_SECS * 7)) parts = { value: Math.round(Math.abs(offset / DAY_IN_SECS)), label: 'day ago' }; + else parts = { value: 'long ago' }; - if (offset < MINUTE_IN_SECS * -5 || offset > (MINUTE_IN_SECS * MINUTES_SINCE_LAST_UPDATE_URGENT)) { + if (offset > DAY_IN_SECS * 7) { + parts.removeClass = 'current urgent'; + parts.addClass = 'warn'; + } else if (offset < MINUTE_IN_SECS * -5 || offset > (MINUTE_IN_SECS * MINUTES_SINCE_LAST_UPDATE_URGENT)) { parts.removeClass = 'current warn'; parts.addClass = 'urgent'; } else if (offset > (MINUTE_IN_SECS * MINUTES_SINCE_LAST_UPDATE_WARN)) { @@ -1350,7 +1353,11 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; lastEntry.find('em').show().text(ago.value); } - lastEntry.find('label').text(retroMode ? 'RETRO' : ago.label); + if (retroMode || ago.label) { + lastEntry.find('label').show().text(retroMode ? 'RETRO' : ago.label); + } else { + lastEntry.find('label').hide(); + } } function init() {