Capture the new message number from the etag of the post transaction
authorArt Cancro <ajc@citadel.org>
Fri, 26 Nov 2021 05:51:12 +0000 (00:51 -0500)
committerArt Cancro <ajc@citadel.org>
Fri, 26 Nov 2021 05:51:12 +0000 (00:51 -0500)
webcit-ng/static/js/view_forum.js

index aacb883..8d13b10 100644 (file)
@@ -333,7 +333,13 @@ function forum_save_message(div_name, reply_to_msgnum) {
                if (request.readyState == 4) {
                        document.body.style.cursor = "default";
                        if (Math.trunc(request.status / 100) == 2) {
                if (request.readyState == 4) {
                        document.body.style.cursor = "default";
                        if (Math.trunc(request.status / 100) == 2) {
-                               alert("headers: " + request.getAllResponseHeaders());
+                               headers = request.getAllResponseHeaders().split("\n");
+                               for (var i in headers) {
+                                       if (headers[i].startsWith("etag: ")) {
+                                               new_msg_num = headers[i].split(" ")[1];
+                                               alert(new_msg_num);
+                                       }
+                               }
                                document.getElementById(div_name).outerHTML = "";               // close the editor
                        }
                        else {
                                document.getElementById(div_name).outerHTML = "";               // close the editor
                        }
                        else {