fix <time> semantics and add title attribute, closes #104
The browser shows a human-readable, absolute timestamp when hovering the "time ago" element
This commit is contained in:
parent
0f1b95a125
commit
881788a049
@ -101,7 +101,7 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
|
|||||||
|
|
||||||
// update datetime every 60 seconds
|
// update datetime every 60 seconds
|
||||||
var refresh = function() {
|
var refresh = function() {
|
||||||
$(".permalink > date", el).textContent = utils.ago(
|
$(".permalink > time", el).textContent = utils.ago(
|
||||||
globals.offset.localTime(), new Date(parseInt(comment.created, 10) * 1000));
|
globals.offset.localTime(), new Date(parseInt(comment.created, 10) * 1000));
|
||||||
setTimeout(refresh, 60*1000);
|
setTimeout(refresh, 60*1000);
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,13 @@ define(["libjs-jade-runtime", "app/utils", "jade!app/text/postbox", "jade!app/te
|
|||||||
load("comment-loader", tt_comment_loader);
|
load("comment-loader", tt_comment_loader);
|
||||||
|
|
||||||
set("bool", function(arg) { return arg ? true : false; });
|
set("bool", function(arg) { return arg ? true : false; });
|
||||||
|
set("humanize", function(date) {
|
||||||
|
if (typeof date !== "object") {
|
||||||
|
date = new Date(parseInt(date, 10) * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return date.toString();
|
||||||
|
});
|
||||||
set("datetime", function(date) {
|
set("datetime", function(date) {
|
||||||
if (typeof date !== "object") {
|
if (typeof date !== "object") {
|
||||||
date = new Date(parseInt(date, 10) * 1000);
|
date = new Date(parseInt(date, 10) * 1000);
|
||||||
@ -30,7 +37,11 @@ define(["libjs-jade-runtime", "app/utils", "jade!app/text/postbox", "jade!app/te
|
|||||||
date.getUTCFullYear(),
|
date.getUTCFullYear(),
|
||||||
utils.pad(date.getUTCMonth(), 2),
|
utils.pad(date.getUTCMonth(), 2),
|
||||||
utils.pad(date.getUTCDay(), 2)
|
utils.pad(date.getUTCDay(), 2)
|
||||||
].join("-");
|
].join("-") + "T" + [
|
||||||
|
utils.pad(date.getUTCHours(), 2),
|
||||||
|
utils.pad(date.getUTCMinutes(), 2),
|
||||||
|
utils.pad(date.getUTCSeconds(), 2)
|
||||||
|
].join(":") + "Z";
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -12,7 +12,7 @@ div(class='isso-comment' id='isso-#{comment.id}')
|
|||||||
= bool(comment.author) ? comment.author : i18n('comment-anonymous')
|
= bool(comment.author) ? comment.author : i18n('comment-anonymous')
|
||||||
span(class="spacer") •
|
span(class="spacer") •
|
||||||
a(class='permalink' href='#isso-#{comment.id}')
|
a(class='permalink' href='#isso-#{comment.id}')
|
||||||
date(datetime='#{datetime(comment.created)}')
|
time(title='#{humanize(comment.created)}' datetime='#{datetime(comment.created)}')
|
||||||
span(class='note')
|
span(class='note')
|
||||||
= comment.mode == 2 ? i18n('comment-queued') : comment.mode == 4 ? i18n('comment-deleted') : ''
|
= comment.mode == 2 ? i18n('comment-queued') : comment.mode == 4 ? i18n('comment-deleted') : ''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user