From ba3b1b68c897a567e5de87f621d8121b7a14530f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 23 Nov 2021 19:57:07 -0500 Subject: [PATCH] Detect whether the save operation succeeded by checking the response status of the XHR transaction. Also made the default Citadel server dev.citadel.org instead of uncensored.citadel.org because I am posting a lot of test messages. --- webcit-ng/api.txt | 1 + webcit-ng/static/js/view_forum.js | 16 +++++++++++----- webcit-ng/webcit.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index 4bcde192a..8daab3466 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -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 diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index 618e3b8b0..0e8f36c22 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -216,8 +216,8 @@ function open_reply_box(prefix, msgnum, is_quoted) { "
" // end header - + "
" // begin body - + "This is where the reply text will go." + + "
" // begin body + + "\n" // empty initial content + "
" // 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; - } diff --git a/webcit-ng/webcit.h b/webcit-ng/webcit.h index 94bd4b873..6a781b1c2 100644 --- a/webcit-ng/webcit.h +++ b/webcit-ng/webcit.h @@ -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 -- 2.39.2