]> code.citadel.org Git - citadel.git/commitdiff
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 dc5ebc00d9100152720fa27479b0bfadb505b6ac..4bcde192a351eb16d00553d7ee1e8ed6bbbdb308 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 3711a2aed10f3bad9dc7bff11ae2e754a3967f96..618e3b8b02c606b75f6e3ce9c6da7a5113d8ee31 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;
+
+}