From: Art Cancro Date: Fri, 22 Jul 2022 18:42:49 +0000 (-0400) Subject: Display "brief" datestamps in mailbox: date if not today, time if today. X-Git-Tag: v958~42 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=3635230539b18deb49b46b39f30aad91149c0ff3;p=citadel.git Display "brief" datestamps in mailbox: date if not today, time if today. --- diff --git a/webcit-ng/static/js/roomlist.js b/webcit-ng/static/js/roomlist.js index 3c0764ae8..485f08e50 100644 --- a/webcit-ng/static/js/roomlist.js +++ b/webcit-ng/static/js/roomlist.js @@ -58,7 +58,7 @@ function display_room_list_renderer(floor_list, room_list) { + " w3-left\">" + escapeHTML(room_list[i].name) + "" - + convertTimestamp(room_list[i].mtime) + + string_timestamp(room_list[i].mtime) + ""; } } diff --git a/webcit-ng/static/js/util.js b/webcit-ng/static/js/util.js index 629f07134..25589056a 100644 --- a/webcit-ng/static/js/util.js +++ b/webcit-ng/static/js/util.js @@ -78,14 +78,25 @@ function escapeJS(text) { // Convert a UNIX timestamp to the browser's local time // See also: https://timestamp.online/article/how-to-convert-timestamp-to-datetime-in-javascript -// In the future we could let the user select from several available formats. -function convertTimestamp(timestamp) { +// format should be: 0=full (date+time), 1=brief (date if not today, time if today) +function string_timestamp(timestamp, format) { var ts = new Date(timestamp * 1000); - return(ts.toLocaleString()); + if (format == 1) { + var now_ts = new Date(Date.now()); + if (ts.toLocaleDateString() == now_ts.toLocaleDateString()) { + return(ts.toLocaleTimeString()); + } + else { + return(ts.toLocaleDateString()); + } + } + else { + return(ts.toLocaleString()); + } } -// An old version of convertTimestamp() did it the hard way. +// An old version of string_timestamp() did it the hard way. // It used https://gist.github.com/kmaida/6045266 as a reference. // check git history prior to 2022-jul-03 if you want to see it. diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index 18602b8ea..783fbc7de 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -187,7 +187,7 @@ function forum_render_one(msg, existing_div) { + msg.from + "" // end username + "" - + convertTimestamp(msg.time) + + string_timestamp(msg.time,0) + "" // end msgdate + "" // end header info on left side + "" // begin buttons on right side @@ -296,7 +296,7 @@ function open_reply_box(parent_div, is_quoted, references, msgid) { + current_user // user = me ! + "" + "" - + convertTimestamp(Date.now() / 1000) // the current date/time (temporary for display) + + string_timestamp((Date.now() / 1000),0) // the current date/time (temporary for display) + "" + "" // end header info on left side + "" // begin buttons on right side diff --git a/webcit-ng/static/js/view_mail.js b/webcit-ng/static/js/view_mail.js index 6566808e2..8522e77a8 100644 --- a/webcit-ng/static/js/view_mail.js +++ b/webcit-ng/static/js/view_mail.js @@ -27,23 +27,17 @@ function mail_render_one(msg, target_div) { + msg.from + "" // end username + "" - + convertTimestamp(msg.time) + + string_timestamp(msg.time,0) + "" // end msgdate + "" // end header info on left side + "" // begin buttons on right side - + "" // Reply - + "" + + "" // Reply (mail is always Quoted) + + "" + " " + _("Reply") + "" - + "" // ReplyQuoted - + "" - + " " - + _("ReplyQuoted") - + ""; - if (can_delete_messages) { outmsg += "" @@ -121,7 +115,7 @@ function mail_render_row(msg) { + ">" + "" + msg["subject"] + "" + "" + msg["author"] + " <" + msg["addr"] + ">" - + "" + convertTimestamp(msg["time"]) + "" + + "" + string_timestamp(msg["time"],1) + "" + "" + msg["msgnum"] + "" + ""; return(row); @@ -217,7 +211,10 @@ function render_mailbox_display() { } -// Enter a new mail message (called by the dispatcher in views.js) -function mail_entmsg() { - alert("no handler for entering new mail yet"); +// Compose a new mail message (called by the Reply button here, or by the dispatcher in views.js) +function mail_compose(is_quoted, references, msgid) { + console.log("mail_compose() called"); + console.log("is_quoted: " + is_quoted); + console.log("references: " + references); + console.log("msgid: " + msgid); } diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index 3096bfe02..9c3261bc2 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -53,7 +53,7 @@ function entmsg_dispatcher() { forum_entmsg(); break; default: - mail_entmsg(); + mail_compose(false, "", ""); break; } }