diff --git a/humbug/settings.py b/humbug/settings.py index ac3d80d99d..d95498e814 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -225,6 +225,7 @@ PIPELINE_JS = { 'js/zephyr.js', 'js/activity.js', 'js/colorspace.js', + 'js/timerender.js', ), 'output_filename': 'min/app.js' }, diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index a664b30f21..54ac40594b 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -54,6 +54,9 @@ var globals = // invite.js + ' invite' + // timerender.js + + ' timerender' + // ui.js + ' ui' diff --git a/zephyr/static/js/timerender.js b/zephyr/static/js/timerender.js new file mode 100644 index 0000000000..67a8b5a9a9 --- /dev/null +++ b/zephyr/static/js/timerender.js @@ -0,0 +1,17 @@ +var timerender = (function () { + +var exports = {}; + +// Given an XDate object 'time', return a DOM node that initially +// displays the human-formatted time, and is updated automatically as +// necessary (e.g. changing "Mon 11:21" to "Jan 14 11:21" after a week +// or so). + +// (But for now it just returns a static node.) +exports.render_time = function(time) { + // Wrap the text in a span because (oddly) a text node has no outerHTML attribute. + return $("").text(time.toString("MMM dd") + "\xa0\xa0" + time.toString("HH:mm")); +}; + +return exports; +}()); diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 5d97a50bf9..868b70efc3 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -349,8 +349,7 @@ function add_display_time(message, prev) { // NB: timestr is HTML, inserted into the document without escaping. if (include_date) { - message.timestr = time.toString("MMM dd") + "  " + - time.toString("HH:mm"); + message.timestr = (timerender.render_time(time))[0].outerHTML; } else { message.timestr = time.toString("HH:mm"); }