Added absolute timestamp hints where necessary

This commit is contained in:
Marcin Kurczewski 2014-11-27 10:34:45 +01:00
parent f1647a5f7b
commit 2fd371b10a
12 changed files with 31 additions and 10 deletions

View file

@ -103,6 +103,7 @@ App.Presenters.CommentListPresenter = function(
var $item = jQuery('<li>' + templates.commentListItem({ var $item = jQuery('<li>' + templates.commentListItem({
comment: comment, comment: comment,
formatRelativeTime: util.formatRelativeTime, formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
formatMarkdown: util.formatMarkdown, formatMarkdown: util.formatMarkdown,
canVote: auth.isLoggedIn(), canVote: auth.isLoggedIn(),
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments, canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments,

View file

@ -164,6 +164,7 @@ App.Presenters.PostPresenter = function(
postHistory: post.history, postHistory: post.history,
formatRelativeTime: util.formatRelativeTime, formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
formatFileSize: util.formatFileSize, formatFileSize: util.formatFileSize,
historyTemplate: templates.history, historyTemplate: templates.history,

View file

@ -88,6 +88,7 @@ App.Presenters.TagPresenter = function(
siblings: siblings, siblings: siblings,
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')), tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
formatRelativeTime: util.formatRelativeTime, formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
historyTemplate: templates.history, historyTemplate: templates.history,
})); }));
$el.find('.post-list').hide(); $el.find('.post-list').hide();

View file

@ -77,6 +77,7 @@ App.Presenters.UserListPresenter = function(
var $item = jQuery('<li>' + templates.listItem(_.extend({ var $item = jQuery('<li>' + templates.listItem(_.extend({
user: user, user: user,
formatRelativeTime: util.formatRelativeTime, formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
}, privileges)) + '</li>'); }, privileges)) + '</li>');
$target.append($item); $target.append($item);
}); });

View file

@ -75,6 +75,7 @@ App.Presenters.UserPresenter = function(
user: user, user: user,
isLoggedIn: auth.isLoggedIn(user.name), isLoggedIn: auth.isLoggedIn(user.name),
formatRelativeTime: util.formatRelativeTime, formatRelativeTime: util.formatRelativeTime,
formatAbsoluteTime: util.formatAbsoluteTime,
canChangeBrowsingSettings: userBrowsingSettingsPresenter.getPrivileges().canChangeBrowsingSettings, canChangeBrowsingSettings: userBrowsingSettingsPresenter.getPrivileges().canChangeBrowsingSettings,
canChangeAccountSettings: _.any(userAccountSettingsPresenter.getPrivileges()), canChangeAccountSettings: _.any(userAccountSettingsPresenter.getPrivileges()),
canDeleteAccount: userAccountRemovalPresenter.getPrivileges().canDeleteAccount})); canDeleteAccount: userAccountRemovalPresenter.getPrivileges().canDeleteAccount}));

View file

@ -146,6 +146,11 @@ App.Util.Misc = function(_, jQuery, marked, promise) {
return future ? 'in ' + text : text + ' ago'; 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) { function formatUnits(number, base, suffixes, callback) {
if (!number && number !== 0) { if (!number && number !== 0) {
return NaN; return NaN;
@ -233,6 +238,7 @@ App.Util.Misc = function(_, jQuery, marked, promise) {
return { return {
promiseTemplate: promiseTemplate, promiseTemplate: promiseTemplate,
formatRelativeTime: formatRelativeTime, formatRelativeTime: formatRelativeTime,
formatAbsoluteTime: formatAbsoluteTime,
formatFileSize: formatFileSize, formatFileSize: formatFileSize,
formatMarkdown: formatMarkdown, formatMarkdown: formatMarkdown,
enableExitConfirmation: enableExitConfirmation, enableExitConfirmation: enableExitConfirmation,

View file

@ -27,7 +27,7 @@
<% } %> <% } %>
</span> </span>
<span class="date" title="<%= comment.creationTime %>"> <span class="date" title="<%= formatAbsoluteTime(comment.creationTime) %>">
<%= formatRelativeTime(comment.creationTime) %> <%= formatRelativeTime(comment.creationTime) %>
</span> </span>

View file

@ -22,7 +22,7 @@ var showDifference = function(className, difference) {
<tbody> <tbody>
<% _.each(history, function( historyEntry) { %> <% _.each(history, function( historyEntry) { %>
<tr> <tr>
<td class="time"> <td class="time" title="<%= formatAbsoluteTime(historyEntry.time) %>">
<%= formatRelativeTime(historyEntry.time) %> <%= formatRelativeTime(historyEntry.time) %>
</td> </td>

View file

@ -109,7 +109,9 @@
<br/> <br/>
<span class="date"><%= formatRelativeTime(post.uploadTime) %></span> <span class="date" title="<%= formatAbsoluteTime(post.uploadTime) %>">
<%= formatRelativeTime(post.uploadTime) %>
</span>
</div> </div>
<ul class="other-info"> <ul class="other-info">
@ -138,7 +140,9 @@
<% if (post.lastEditTime !== post.uploadTime) { %> <% if (post.lastEditTime !== post.uploadTime) { %>
<li> <li>
Edited: Edited:
<span title="<%= formatAbsoluteTime(post.lastEditTime) %>">
<%= formatRelativeTime(post.lastEditTime) %> <%= formatRelativeTime(post.lastEditTime) %>
</span>
</li> </li>
<% } %> <% } %>
@ -273,7 +277,8 @@
<h1>History</h1> <h1>History</h1>
<%= historyTemplate({ <%= historyTemplate({
history: postHistory, history: postHistory,
formatRelativeTime: formatRelativeTime formatRelativeTime: formatRelativeTime,
formatAbsoluteTime: formatAbsoluteTime,
}) %> }) %>
</div> </div>
<% } %> <% } %>

View file

@ -103,7 +103,8 @@
<h3>History</h3> <h3>History</h3>
<%= historyTemplate({ <%= historyTemplate({
history: tag.history, history: tag.history,
formatRelativeTime: formatRelativeTime formatRelativeTime: formatRelativeTime,
formatAbsoluteTime: formatAbsoluteTime,
}) %> }) %>
</div> </div>
<% } %> <% } %>

View file

@ -19,10 +19,10 @@
<%= user.name %> <%= user.name %>
<% } %> <% } %>
</h1> </h1>
<div class="date-joined" title="<%= user.registrationTime %>"> <div class="date-joined" title="<%= formatAbsoluteTime(user.registrationTime) %>">
Joined: <%= formatRelativeTime(user.registrationTime) %> Joined: <%= formatRelativeTime(user.registrationTime) %>
</div> </div>
<div class="date-seen"> <div class="date-seen" title="<%= formatAbsoluteTime(user.lastLoginTime) %>">
Last seen: <%= formatRelativeTime(user.lastLoginTime) %> Last seen: <%= formatRelativeTime(user.lastLoginTime) %>
</div> </div>
</div> </div>

View file

@ -51,12 +51,16 @@
<table> <table>
<tr> <tr>
<td>Registered:</td> <td>Registered:</td>
<td><%= formatRelativeTime(user.registrationTime) %></td> <td title="<%= formatAbsoluteTime(user.registrationTime) %>">
<%= formatRelativeTime(user.registrationTime) %>
</td>
</tr> </tr>
<tr> <tr>
<td>Seen:</td> <td>Seen:</td>
<td><%= formatRelativeTime(user.lastLoginTime) %></td> <td title="<%= formatAbsoluteTime(user.lastLoginTime) %>">
<%= formatRelativeTime(user.lastLoginTime) %>
</td>
</tr> </tr>
<% if (user.accessRank) { %> <% if (user.accessRank) { %>