From 88f5e004e01b9942db384ebdaf4c26b55b1afd48 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 23 Nov 2021 18:41:11 -0500 Subject: [PATCH] Wow! Posting a message to the server worked on the first try, even using the existing DAV operation and no new C code. That was a pleasant surprise. --- webcit-ng/api.txt | 3 +++ webcit-ng/static/js/view_forum.js | 33 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/webcit-ng/api.txt b/webcit-ng/api.txt index dc5ebc00d..4bcde192a 100644 --- a/webcit-ng/api.txt +++ b/webcit-ng/api.txt @@ -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 diff --git a/webcit-ng/static/js/view_forum.js b/webcit-ng/static/js/view_forum.js index 3711a2aed..618e3b8b0 100644 --- a/webcit-ng/static/js/view_forum.js +++ b/webcit-ng/static/js/view_forum.js @@ -227,13 +227,13 @@ function open_reply_box(prefix, msgnum, is_quoted) { + "" // end footer info on left side + "" // begin buttons on right side - + "" // FIXME save and cancel buttons - + " " + + "" + + " " // save button + _("Post message") + "" - + "" // FIXME save and cancel buttons - + " " + + "" + + " " // cancel button + _("Cancel") + "" @@ -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 = "" + document.getElementById("ctdl-editor-body").innerHTML + "\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; + +} -- 2.39.2