From b96fcb6328fc60330a346653095a10b6e365fca7 Mon Sep 17 00:00:00 2001 From: Shane Tomlinson <stomlinson@mozilla.com> Date: Fri, 20 Jan 2012 20:51:20 +0000 Subject: [PATCH] removing relativeDate and all references to it. close #925 --- resources/static/pages/manage_account.js | 6 +- resources/static/shared/helpers.js | 89 ------------------------ resources/views/index.ejs | 2 - 3 files changed, 1 insertion(+), 96 deletions(-) diff --git a/resources/static/pages/manage_account.js b/resources/static/pages/manage_account.js index 750970448..bf53df428 100644 --- a/resources/static/pages/manage_account.js +++ b/resources/static/pages/manage_account.js @@ -79,12 +79,8 @@ BrowserID.manageAccount = (function() { var template = $("#templateUser").html(); _(emails).each(function(data, e) { - var date = helpers.relativeDate(new Date(data.created)); - var identity = _.template(template, { - email: e, - relative: date.friendly, - created: date.locale + email: e }); var idEl = $(identity).appendTo(list); diff --git a/resources/static/shared/helpers.js b/resources/static/shared/helpers.js index b9a63ca08..898456d25 100644 --- a/resources/static/shared/helpers.js +++ b/resources/static/shared/helpers.js @@ -47,88 +47,6 @@ return url; } - function relativeDate(date) { - var diff = (((new Date()).getTime() - date.getTime()) / 1000), - day_diff = Math.floor(diff / 86400), - dObj = { "friendly" : date.toLocaleDateString(), - "additional" : date.toLocaleTimeString(), - "utc" : date.toUTCString(), - "locale" : date.toLocaleString() }; - - /* some kind of error */ - if (day_diff < 0) { - dObj.friendly = "in the future!?!"; - return dObj; - } else if (isNaN(day_diff)) { - dObj.friendly = dObj.additional = "unknown"; - return dObj; - } - - if (day_diff === 0) { - if (diff < 60) { - dObj.friendly = "just now"; - return dObj; - } - if (diff < 120 + 30) { /* 1 minute plus some fuzz */ - dObj.friendly = "a minute ago"; - return dObj; - } - if (diff < 3600) { - dObj.friendly = Math.floor(diff / 60) + " minutes ago"; - return dObj; - } - if (diff < (60 * 60) * 2) { - dObj.friendly = "1 hour ago"; - return dObj; - } - if (diff < 24 * 60 * 60) { - dObj.friendly = Math.floor(diff / 3600) + " hours ago"; - return dObj; - } - } - if (day_diff === 1) { - dObj.friendly = "yesterday"; - return dObj; - } - if (day_diff < 7) { - dObj.friendly = day_diff + " days ago"; - return dObj; - } - if (day_diff < 8) { - dObj.friendly = "last week"; - return dObj; - } - /* for this scope: we want day of week and the date - plus the month (if different) */ - if (day_diff < 31) { - dObj.friendly = Math.ceil(day_diff / 7) + " weeks ago"; - return dObj; - } - - /* for this scope: we want month + date */ - if (day_diff < 62) { - dObj.friendly = "a month ago"; - return dObj; - } - if (day_diff < 365) { - dObj.friendly = Math.ceil(day_diff / 31) + " months ago"; - return dObj; - } - - /* for this scope: we want month + year */ - if (day_diff >= 365 && day_diff < 730) { - dObj.additional = date.toLocaleDateString(); - dObj.friendly = "a year ago"; - return dObj; - } - if (day_diff >= 365) { - dObj.additional = date.toLocaleDateString(); - dObj.friendly = Math.ceil(day_diff / 365) + " years ago"; - return dObj; - } - return dObj; - } - function cancelEvent(callback) { return function(event) { event && event.preventDefault(); @@ -179,13 +97,6 @@ */ toURL: toURL, - /** - * Get the date relative to now. - * @method relativeDate - * @param {Date} date - * @returns {string} date relative to now. - */ - relativeDate: relativeDate, /** * Return a function that calls preventDefault on the event and then calls * the callback with the arguments. diff --git a/resources/views/index.ejs b/resources/views/index.ejs index be6d42beb..f1b6b005d 100644 --- a/resources/views/index.ejs +++ b/resources/views/index.ejs @@ -72,8 +72,6 @@ <div class="email">{{ email }}</div> <div class="activity cf"> <button class="delete">remove</button> - <!-- removed registration info. We want to replace this with Last Used At ... --> - <!-- <abbr title="Registered: {{ created }}" class="status">Registered {{ relative }}.</abbr>--> </div> </li> </script> -- GitLab