]> code.citadel.org Git - citadel.git/blob - webcit-ng/static/js/view_mail.js
Beginnings of mailbox view
[citadel.git] / webcit-ng / static / js / view_mail.js
1 // Copyright (c) 2016-2022 by the citadel.org team
2 //
3 // This program is open source software.  Use, duplication, or
4 // disclosure are subject to the GNU General Public License v3.
5
6
7 // Set up the mailbox view
8 function mail_display() {
9         target_div = document.getElementById("ctdl-main");
10         target_div.innerHTML = "<div id=\"ctdl-mailbox-pane\">mailbox pane</div><div id=\"ctdl-reading-pane\">reading pane</div>";
11         mailbox_pane = document.getElementById("ctdl-mailbox-pane");
12         reading_pane = document.getElementById("ctdl-reading-pane");
13
14         activate_loading_modal();
15         url = "/ctdl/r/" + escapeHTMLURI(current_room) + "/mailbox";
16         fetch_mailbox = async() => {
17                 response = await fetch(url);
18                 msgs = await(response.json());
19                 if (response.ok) {
20
21                         box =   "<table border=1 width=100%><tr>"
22                                 + "<th>" + _("Subject") + "</th>"
23                                 + "<th>" + _("Sender") + "</th>"
24                                 + "<th>" + _("Date") + "</th>"
25                                 + "<th>#</th>"
26                                 + "</tr>";
27
28
29                         for (var i=0; i<msgs.length; ++i) {
30                                 box +=  "<tr id=\"ctdl-msgsum-" + msgs[i]["msgnum"] + "\">"
31                                         + "<td>" + msgs[i]["subject"] + "</td>"
32                                         + "<td>" + msgs[i]["author"] + " &lt;" + msgs[i]["addr"] + "&gt;</td>"
33                                         + "<td>" + convertTimestamp(msgs[i]["time"]) + "</td>"
34                                         + "<td>" + msgs[i]["msgnum"] + "</td>"
35                                         + "</tr>";
36                         }
37
38                         box +=  "</table>";
39                         mailbox_pane.innerHTML = box;
40                 }
41         }
42         fetch_mailbox();
43         deactivate_loading_modal();
44 }