From 2fd371b10a39621f1fe4cb686c353c7158e4d49f Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 27 Nov 2014 10:34:45 +0100 Subject: [PATCH] Added absolute timestamp hints where necessary --- public_html/js/Presenters/CommentListPresenter.js | 1 + public_html/js/Presenters/PostPresenter.js | 1 + public_html/js/Presenters/TagPresenter.js | 1 + public_html/js/Presenters/UserListPresenter.js | 1 + public_html/js/Presenters/UserPresenter.js | 1 + public_html/js/Util/Misc.js | 6 ++++++ public_html/templates/comment-list-item.tpl | 2 +- public_html/templates/history.tpl | 2 +- public_html/templates/post.tpl | 11 ++++++++--- public_html/templates/tag.tpl | 3 ++- public_html/templates/user-list-item.tpl | 4 ++-- public_html/templates/user.tpl | 8 ++++++-- 12 files changed, 31 insertions(+), 10 deletions(-) diff --git a/public_html/js/Presenters/CommentListPresenter.js b/public_html/js/Presenters/CommentListPresenter.js index 82ea5f16..45ba207e 100644 --- a/public_html/js/Presenters/CommentListPresenter.js +++ b/public_html/js/Presenters/CommentListPresenter.js @@ -103,6 +103,7 @@ App.Presenters.CommentListPresenter = function( var $item = jQuery('
  • ' + templates.commentListItem({ comment: comment, formatRelativeTime: util.formatRelativeTime, + formatAbsoluteTime: util.formatAbsoluteTime, formatMarkdown: util.formatMarkdown, canVote: auth.isLoggedIn(), canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments, diff --git a/public_html/js/Presenters/PostPresenter.js b/public_html/js/Presenters/PostPresenter.js index 98c5095b..332c4373 100644 --- a/public_html/js/Presenters/PostPresenter.js +++ b/public_html/js/Presenters/PostPresenter.js @@ -164,6 +164,7 @@ App.Presenters.PostPresenter = function( postHistory: post.history, formatRelativeTime: util.formatRelativeTime, + formatAbsoluteTime: util.formatAbsoluteTime, formatFileSize: util.formatFileSize, historyTemplate: templates.history, diff --git a/public_html/js/Presenters/TagPresenter.js b/public_html/js/Presenters/TagPresenter.js index 1a182f46..6bc3e60f 100644 --- a/public_html/js/Presenters/TagPresenter.js +++ b/public_html/js/Presenters/TagPresenter.js @@ -88,6 +88,7 @@ App.Presenters.TagPresenter = function( siblings: siblings, tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')), formatRelativeTime: util.formatRelativeTime, + formatAbsoluteTime: util.formatAbsoluteTime, historyTemplate: templates.history, })); $el.find('.post-list').hide(); diff --git a/public_html/js/Presenters/UserListPresenter.js b/public_html/js/Presenters/UserListPresenter.js index 4d05fe85..1a7b02aa 100644 --- a/public_html/js/Presenters/UserListPresenter.js +++ b/public_html/js/Presenters/UserListPresenter.js @@ -77,6 +77,7 @@ App.Presenters.UserListPresenter = function( var $item = jQuery('
  • ' + templates.listItem(_.extend({ user: user, formatRelativeTime: util.formatRelativeTime, + formatAbsoluteTime: util.formatAbsoluteTime, }, privileges)) + '
  • '); $target.append($item); }); diff --git a/public_html/js/Presenters/UserPresenter.js b/public_html/js/Presenters/UserPresenter.js index 76a819b0..d40a495b 100644 --- a/public_html/js/Presenters/UserPresenter.js +++ b/public_html/js/Presenters/UserPresenter.js @@ -75,6 +75,7 @@ App.Presenters.UserPresenter = function( user: user, isLoggedIn: auth.isLoggedIn(user.name), formatRelativeTime: util.formatRelativeTime, + formatAbsoluteTime: util.formatAbsoluteTime, canChangeBrowsingSettings: userBrowsingSettingsPresenter.getPrivileges().canChangeBrowsingSettings, canChangeAccountSettings: _.any(userAccountSettingsPresenter.getPrivileges()), canDeleteAccount: userAccountRemovalPresenter.getPrivileges().canDeleteAccount})); diff --git a/public_html/js/Util/Misc.js b/public_html/js/Util/Misc.js index a4374036..11ea0429 100644 --- a/public_html/js/Util/Misc.js +++ b/public_html/js/Util/Misc.js @@ -146,6 +146,11 @@ App.Util.Misc = function(_, jQuery, marked, promise) { return future ? 'in ' + text : text + ' ago'; } + function formatAbsoluteTime(timeString) { + var time = new Date(Date.parse(timeString)); + return time.toString(); + } + function formatUnits(number, base, suffixes, callback) { if (!number && number !== 0) { return NaN; @@ -233,6 +238,7 @@ App.Util.Misc = function(_, jQuery, marked, promise) { return { promiseTemplate: promiseTemplate, formatRelativeTime: formatRelativeTime, + formatAbsoluteTime: formatAbsoluteTime, formatFileSize: formatFileSize, formatMarkdown: formatMarkdown, enableExitConfirmation: enableExitConfirmation, diff --git a/public_html/templates/comment-list-item.tpl b/public_html/templates/comment-list-item.tpl index 80102058..ff9b9c2e 100644 --- a/public_html/templates/comment-list-item.tpl +++ b/public_html/templates/comment-list-item.tpl @@ -27,7 +27,7 @@ <% } %> - + <%= formatRelativeTime(comment.creationTime) %> diff --git a/public_html/templates/history.tpl b/public_html/templates/history.tpl index 2e677d67..e7ffc503 100644 --- a/public_html/templates/history.tpl +++ b/public_html/templates/history.tpl @@ -22,7 +22,7 @@ var showDifference = function(className, difference) { <% _.each(history, function( historyEntry) { %> - + <%= formatRelativeTime(historyEntry.time) %> diff --git a/public_html/templates/post.tpl b/public_html/templates/post.tpl index 4aaf6481..992fde85 100644 --- a/public_html/templates/post.tpl +++ b/public_html/templates/post.tpl @@ -109,7 +109,9 @@
    - <%= formatRelativeTime(post.uploadTime) %> + + <%= formatRelativeTime(post.uploadTime) %> +