Detect whether the save operation succeeded by checking the response status of the...
authorArt Cancro <ajc@citadel.org>
Wed, 24 Nov 2021 00:57:07 +0000 (19:57 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 24 Nov 2021 00:57:07 +0000 (19:57 -0500)
webcit-ng/api.txt
webcit-ng/static/js/view_forum.js
webcit-ng/webcit.h

index 4bcde192a351eb16d00553d7ee1e8ed6bbbdb308..8daab3466a256fff1e648fd31b572ef7dad4efa7 100644 (file)
@@ -10,6 +10,7 @@ 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
+                                               (The returned ETag will be the new message number)
 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
index 618e3b8b02c606b75f6e3ce9c6da7a5113d8ee31..0e8f36c2284d5061c086b5cfe1c9bb5226fc2dc8 100644 (file)
@@ -216,8 +216,8 @@ function open_reply_box(prefix, msgnum, is_quoted) {
          "</div><br>"                                                  // end header
 
 
-       + "<div class=\"ctdl-msg-body\" id=\"ctdl-editor-body\" style=\"height:30vh; padding:5px;\" contenteditable=\"true\">"  // begin body
-       + "This is where the reply text will go."
+       + "<div class=\"ctdl-msg-body\" id=\"ctdl-editor-body\" style=\"padding:5px;\" contenteditable=\"true\">"       // begin body
+       + "\n"                                                          // empty initial content
        + "</div>"                                                      // end body
 
 
@@ -279,9 +279,15 @@ function save_message(div_name, reply_to_msgnum) {
        request.setRequestHeader("Content-type", "text/html");
        request.setRequestHeader("Content-length", msg_text.length);
        request.onreadystatechange = function() {
-               alert("well, something happened");
+               if (request.readyState == 4) {
+                       if (Math.trunc(request.status / 100) == 2) {
+                               alert("headers: " + request.getAllResponseHeaders());
+                               document.getElementById(div_name).outerHTML = "";               // close the editor
+                       }
+                       else {
+                               alert(_("An error has occurred."));     // inelegant but hopefully infrequent
+                       }
+               }
        };
        request.send(msg_text);
-       request = null;
-
 }
index 94bd4b8739ccbd621e3f2553a973637888c2a686..6a781b1c22c36a40d259a1f9506ff0314d367fd5 100644 (file)
@@ -117,7 +117,7 @@ enum {
 #define DEFAULT_SSL_CIPHER_LIST "DEFAULT"       // See http://openssl.org/docs/apps/ciphers.html
 #define WEBSERVER_PORT         80
 #define WEBSERVER_INTERFACE    "*"
-#define CTDLHOST               "uncensored.citadel.org"
+#define CTDLHOST               "dev.citadel.org"
 #define CTDLPORT               "504"
 #define DEVELOPER_ID           0
 #define CLIENT_ID              4