From ca54f38e77d4525cf129844d54069f3a33dff800 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Tue, 17 Mar 2015 23:12:29 -0700 Subject: [PATCH 1/2] better future data warning --- static/js/client.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index 8d07beb5d..c8f1b825b 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1080,22 +1080,26 @@ 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)) { + console.info('>>>>offset', offset, parts); + 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 +1354,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() { From 1f01d030c621f9fbf42e945cb0fb79bbe6c5381b Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Tue, 17 Mar 2015 23:14:56 -0700 Subject: [PATCH 2/2] remove debug --- static/js/client.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index c8f1b825b..96a39931b 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1095,9 +1095,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; 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' }; - console.info('>>>>offset', offset, parts); if (offset > DAY_IN_SECS * 7) { - parts.removeClass = 'current urgent'; + 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';