Display the date when either it or the recipient changes.

This is somewhat experimental and we may need to work on the condition
when it shows up (or move it elsewhere).

Also, maybe it should say "Today/Yesterday" for times super close to
now -- the main issue with doing this is whether it needs to update
without your reloading the page to avoid being super confusing.

(imported from commit e29faf30c83b9574e5d233213f42a24175f9a616)
This commit is contained in:
Tim Abbott 2012-10-05 14:44:29 -04:00
parent d9f03d9842
commit c02c6cc954
3 changed files with 25 additions and 8 deletions

View File

@ -3,7 +3,7 @@
// Global variables, categorized by place of definition.
var globals =
// Third-party libraries
' $ jQuery Spinner Handlebars'
' $ jQuery Spinner Handlebars XDate'
// index.html
+ ' initial_pointer email class_list people_list have_initial_messages'

View File

@ -54,7 +54,7 @@
<span class="zephyr_sender_email invisible">{{sender_email}}</span>
</span>
{{/include_sender}}
<span class="zephyr_time" title="{{full_date_str}}">{{timestr}}</span>
<span class="zephyr_time" title="{{full_date_str}}">{{{timestr}}}</span>
<div class="zephyr_content">{{{content}}}</div>
</td>
</tr>

View File

@ -229,6 +229,27 @@ function clear_table(table_name) {
message_groups[table_name] = [];
}
function add_display_time(zephyr, prev) {
var two_digits = function (x) { return ('0' + x).slice(-2); };
var time = new XDate(zephyr.timestamp * 1000);
var include_date = zephyr.include_recipient;
if (prev !== undefined) {
var prev_time = new XDate(prev.timestamp * 1000);
if (time.toDateString() !== prev_time.toDateString()) {
include_date = true;
}
}
if (include_date) {
zephyr.timestr = time.toString("MMM dd") + "&nbsp;&nbsp;" +
time.toString("HH:mm");
} else {
zephyr.timestr = time.toString("HH:mm");
}
zephyr.full_date_str = time.toLocaleString();
}
function add_to_table(zephyrs, table_name, filter_function, where) {
if (zephyrs.length === 0)
return;
@ -291,6 +312,8 @@ function add_to_table(zephyrs, table_name, filter_function, where) {
ids_where_next_is_same_sender.push(prev.id);
}
add_display_time(zephyr, prev);
zephyr.dom_id = table_name + zephyr.id;
zephyrs_to_render.push(zephyr);
@ -381,12 +404,6 @@ function add_zephyr_metadata(dummy, zephyr) {
break;
}
var time = new Date(zephyr.timestamp * 1000);
var two_digits = function (x) { return ('0' + x).slice(-2); };
zephyr.timestr = two_digits(time.getHours())
+ ':' + two_digits(time.getMinutes());
zephyr.full_date_str = time.toLocaleString();
zephyr_dict[zephyr.id] = zephyr;
}