+ "</span>" // end header info on left side
+ "<span class=\"ctdl-msg-header-buttons\">" // begin buttons on right side
- + "<span class=\"ctdl-msg-button\">" // Reply (mail is always Quoted)
+ + "<span class=\"ctdl-msg-button\">" // Reply
+ "<a href=\"javascript:mail_compose(true,'"+msg.wefw+"','"+msgnum+"', reply_addr(msg), [], 'Re: '+msg.subj);\">"
+ "<i class=\"fa fa-reply\"></i> "
+ _("Reply")
+ "</a></span>"
- + "<span class=\"ctdl-msg-button\">" // Reply-All (mail is always Quoted)
+ + "<span class=\"ctdl-msg-button\">" // Reply-All
+ `<a href="javascript:mail_compose(true, msg.wefw, ${msgnum}, replyall_to(msg), msg.cccc, 'Re: ${subject}');">`
+ "<i class=\"fa fa-reply-all\"></i> "
+ _("ReplyAll")
+ "</a></span>"
- + "<span class=\"ctdl-msg-button\">" // Forward (server handles this)
+ + "<span class=\"ctdl-msg-button\">" // Forward
+ "<a href=\"javascript:mail_compose(true,'"+msg.wefw+"','"+msgnum+"', '', '', 'Fwd: '+msg.subj);\">"
+ "<i class=\"fa fa-mail-forward\"></i> "
+ _("Forward")
}
+// helper function for mail_compose() -- converts a recipient array to a string suitable for the To: or Cc: field
+function recipient_array_to_string(recps_arr) {
+
+ let returned_string = ""
+
+ if (recps_arr) {
+ is_reply = 1;
+
+ // first clean up the recipients
+ for (i=0; i<recps_arr.length; ++i) {
+ recps_arr[i] = recps_arr[i].replaceAll("<", "<").replaceAll(">", ">");
+ }
+
+ // remove dupes
+ recps_arr = Array.from(new Set(recps_arr));
+
+ // now convert it to a string
+ returned_string = "";
+ for (i=0; i<recps_arr.length; ++i) {
+ console.log("to #" + i + ": " + recps_arr[i]);
+ if (i > 0) {
+ returned_string += ", ";
+ }
+ returned_string += recps_arr[i];
+ }
+ }
+
+ return(returned_string);
+}
+
+
+
// Compose a new mail message (called by the Reply button here, or by the dispatcher in views.js)
//
// is_quoted true or false depending on whether the user selected "reply quoted" (is this appropriate for mail?)
let is_reply = 0;
+ console.log("");
+ console.log("mail_compose");
+ console.log("is_quoted: " + is_quoted);
+ console.log("references: " + references);
+ console.log("quoted_msgnum: " + quoted_msgnum);
+ console.log("m_to: " + m_to);
+ console.log("m_cc: " + m_cc);
+ console.log("m_subject: " + m_subject);
+
// m_to will be an array of zero or more recipients for the To: field. Convert it to a string.
- if (m_to) {
- is_reply = 1;
- m_to = Array.from(new Set(m_to)); // remove dupes
- m_to_str = "";
- for (i=0; i<m_to.length; ++i) {
- if (i > 0) {
- m_to_str += ", ";
- }
- m_to_str += m_to[i].replaceAll("<", "<").replaceAll(">", ">");
- }
- }
- else {
- m_to_str = "";
- }
+ m_to_str = recipient_array_to_string(m_to);
- // m_to will be an array of zero or more recipients for the Cc: field. Convert it to a string.
- if (m_cc) {
- is_reply = 1;
- m_cc = Array.from(new Set(m_cc)); // remove dupes
- m_cc_str = "";
- for (i=0; i<m_cc.length; ++i) {
- if (i > 0) {
- m_cc_str += ", ";
- }
- m_cc_str += m_cc[i].replaceAll("<", "<").replaceAll(">", ">");
- }
- }
- else {
- m_cc_str = "";
- }
+ // m_cc will be an array of zero or more recipients for the Cc: field. Convert it to a string.
+ m_cc_str = recipient_array_to_string(m_cc);
quoted_div_name = randomString();