Wow! Posting a message to the server worked on the first try, even using the existin...
authorArt Cancro <ajc@citadel.org>
Tue, 23 Nov 2021 23:41:11 +0000 (18:41 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 23 Nov 2021 23:41:11 +0000 (18:41 -0500)
webcit-ng/api.txt
webcit-ng/static/js/view_forum.js

index dc5ebc0..4bcde19 100644 (file)
@@ -8,6 +8,9 @@ PROPFIND        /ctdl/r/ROOMNAME/               Show a bunch of crap
 GET            /ctdl/r/ROOMNAME/               Returns information about the room (name, view, etc.) in JSON format
 GET            /ctdl/r/ROOMNAME/msgs.all       JSON array of message list in room
 GET            /ctdl/r/ROOMNAME/msgs.new       JSON array of message list in room (new messages)
+GET            /ctdl/r/ROOMNAME/MSGNUM         Retrieve the content of an individual message (message headers are HTTP headers)
+PUT            /ctdl/r/ROOMNAME/xxx            DAV operation to insert a new message into a room
+GET            /ctdl/r/ROOMNAME/MSGNUM/json    Retrieve an individual message in a room, encapsulated in JSON
 GET            /ctdl/c/info                    Returns a JSON representation of the output of an INFO server command
 POST           /ctdl/a/login                   Send it a your credentials and it will log you in
 GET            /ctdl/a/whoami
index 3711a2a..618e3b8 100644 (file)
@@ -227,13 +227,13 @@ function open_reply_box(prefix, msgnum, is_quoted) {
        + "</span>"                                                     // end footer info on left side
        + "<span class=\"ctdl-msg-header-buttons\">"                    // begin buttons on right side
 
-       + "<span class=\"ctdl-msg-button\"><a href=\"#\">"              // FIXME save and cancel buttons
-       + "<i class=\"fa fa-trash\"></i> " 
+       + "<span class=\"ctdl-msg-button\"><a href=\"javascript:save_message('" +  new_div_name + "', '" + msgnum + "');\">"
+       + "<i class=\"fa fa-check\" style=\"color:green\"></i> "        // save button
        + _("Post message")
        + "</a></span>"
 
-       + "<span class=\"ctdl-msg-button\"><a href=\"#\">"              // FIXME save and cancel buttons
-       + "<i class=\"fa fa-trash\"></i> " 
+       + "<span class=\"ctdl-msg-button\"><a href=\"javascript:cancel_post('" +  new_div_name + "');\">"
+       + "<i class=\"fa fa-trash\" style=\"color:red\"></i> "          // cancel button
        + _("Cancel")
        + "</a></span>"
 
@@ -260,3 +260,28 @@ function open_reply_box(prefix, msgnum, is_quoted) {
                window.getSelection().collapse(tag.firstChild, 0);      // positions the cursor
        }, 0);
 }
+
+
+// Abort a message post (it simply destroys the div)
+function cancel_post(div_name) {
+       document.getElementById(div_name).outerHTML = "";               // make it cease to exist
+}
+
+
+// Save the posted message to the server
+function save_message(div_name, reply_to_msgnum) {
+
+       msg_text = "<html><body>" + document.getElementById("ctdl-editor-body").innerHTML + "</body></html>\n";
+       url = "/ctdl/r/" + escapeHTMLURI(current_room) + "/dummy_name_for_new_message";
+
+       var request = new XMLHttpRequest();
+       request.open("PUT", url, true);
+       request.setRequestHeader("Content-type", "text/html");
+       request.setRequestHeader("Content-length", msg_text.length);
+       request.onreadystatechange = function() {
+               alert("well, something happened");
+       };
+       request.send(msg_text);
+       request = null;
+
+}