diff --git a/share/static/alice.js b/share/static/alice.js index 4107220a..51c3d5cc 100644 --- a/share/static/alice.js +++ b/share/static/alice.js @@ -11014,6 +11014,11 @@ Object.extend(Alice, { url: /(https?:\/\/[^\s<"]*)/ig }, + Months: ['Jan','Feb','Mar','Apr','May','June','July','Aug', + 'Sept','Oct','Nov','Dec'], + + Days: ['Sun', 'Mon','Tue','Wed','Thu','Fri','Sat'], + cleanupCopy: function(node) { if (!node.select("li.message").length) return; @@ -11041,11 +11046,14 @@ Object.extend(Alice, { node.cleanWhitespace(); }, - epochToLocal: function(epoch, format) { + epochToLocal: function(epoch, format, show_date) { var date = new Date(parseInt(epoch) * 1000); if (!date) return epoch; var hours = date.getHours(); + var prefix = show_date ? + sprintf("%s, %s %d, ", Alice.Days[date.getDay()], Alice.Months[date.getMonth()], date.getDate()) + : ""; if (format == "12") { var ap; @@ -11055,10 +11063,10 @@ Object.extend(Alice, { } else { ap = "a" } - return sprintf("%d:%02d%s", hours, date.getMinutes(), ap); + return sprintf("%s%d:%02d%s", prefix, hours, date.getMinutes(), ap); } - return sprintf("%02d:%02d", hours, date.getMinutes()); + return sprintf("%s%02d:%02d", prefix, hours, date.getMinutes()); }, makeLinksClickable: function(elem) { @@ -12296,6 +12304,7 @@ Alice.Application = Class.create({ var stamp = li.down('.timestamp'); if (!stamp) return; + var show_date = false; var remove = false; var seconds = stamp.innerHTML.strip(); @@ -12303,14 +12312,18 @@ Alice.Application = Class.create({ var time = new Date(seconds * 1000); var diff = (time - win.lasttimestamp) / 1000; remove = !(diff >= 300 || (diff > 60 && time.getMinutes() % 5 == 0)); - if (!remove) win.lasttimestamp = time; + if (!remove) { + var now = new Date(); + show_date = now.getDate() != win.lasttimestamp.getDate(); + win.lasttimestamp = time; + } } if (remove) { stamp.remove(); } else { - stamp.update(Alice.epochToLocal(seconds, this.options.timeformat)); + stamp.update(Alice.epochToLocal(seconds, this.options.timeformat, show_date)); stamp.style.opacity = 1; } }, diff --git a/src/js/alice/src/alice/application.js b/src/js/alice/src/alice/application.js index be686940..cc8b3e5d 100644 --- a/src/js/alice/src/alice/application.js +++ b/src/js/alice/src/alice/application.js @@ -861,6 +861,7 @@ Alice.Application = Class.create({ var stamp = li.down('.timestamp'); if (!stamp) return; + var show_date = false; var remove = false; var seconds = stamp.innerHTML.strip(); @@ -868,14 +869,18 @@ Alice.Application = Class.create({ var time = new Date(seconds * 1000); var diff = (time - win.lasttimestamp) / 1000; remove = !(diff >= 300 || (diff > 60 && time.getMinutes() % 5 == 0)); - if (!remove) win.lasttimestamp = time; + if (!remove) { + var now = new Date(); + show_date = now.getDate() != win.lasttimestamp.getDate(); + win.lasttimestamp = time; + } } if (remove) { stamp.remove(); } else { - stamp.update(Alice.epochToLocal(seconds, this.options.timeformat)); + stamp.update(Alice.epochToLocal(seconds, this.options.timeformat, show_date)); stamp.style.opacity = 1; } }, diff --git a/src/js/alice/src/alice/util.js b/src/js/alice/src/alice/util.js index e652d38b..db4f5fcb 100644 --- a/src/js/alice/src/alice/util.js +++ b/src/js/alice/src/alice/util.js @@ -5,6 +5,11 @@ Object.extend(Alice, { url: /(https?:\/\/[^\s<"]*)/ig }, + Months: ['Jan','Feb','Mar','Apr','May','June','July','Aug', + 'Sept','Oct','Nov','Dec'], + + Days: ['Sun', 'Mon','Tue','Wed','Thu','Fri','Sat'], + cleanupCopy: function(node) { if (!node.select("li.message").length) return; @@ -32,11 +37,14 @@ Object.extend(Alice, { node.cleanWhitespace(); }, - epochToLocal: function(epoch, format) { + epochToLocal: function(epoch, format, show_date) { var date = new Date(parseInt(epoch) * 1000); if (!date) return epoch; var hours = date.getHours(); + var prefix = show_date ? + sprintf("%s, %s %d, ", Alice.Days[date.getDay()], Alice.Months[date.getMonth()], date.getDate()) + : ""; if (format == "12") { var ap; @@ -46,10 +54,10 @@ Object.extend(Alice, { } else { ap = "a" } - return sprintf("%d:%02d%s", hours, date.getMinutes(), ap); + return sprintf("%s%d:%02d%s", prefix, hours, date.getMinutes(), ap); } - return sprintf("%02d:%02d", hours, date.getMinutes()); + return sprintf("%s%02d:%02d", prefix, hours, date.getMinutes()); }, makeLinksClickable: function(elem) {