Got it! Temporarily working with the server-side C renderer
authorArt Cancro <ajc@citadel.org>
Thu, 15 Feb 2018 03:15:18 +0000 (22:15 -0500)
committerArt Cancro <ajc@citadel.org>
Thu, 15 Feb 2018 03:15:18 +0000 (22:15 -0500)
webcit-ng/forum_view.c
webcit-ng/static/js/views.js

index 354fcea01ff63eb9b96d993b5979993f947a57c1..0eeaf8566566729a6ea6ab4e46ea07c420f48a9c 100644 (file)
@@ -297,7 +297,6 @@ void flat_view(struct http_transaction *h, struct ctdlsession *c, char *which)
 //
 void html_render_one_message(struct http_transaction *h, struct ctdlsession *c, long msgnum)
 {
-
        StrBuf *sj = NewStrBuf();
        StrBufAppendPrintf(sj, "<html><body>\r\n");
        setup_for_forum_view(c);                // FIXME way too inefficient to do this for every message !!!!!!!!!!!!!
index 12642210f40a46b3b65b7ecd6e3bc32c4347e038..171fdf93576dc4b3fe54d5c336db5249ef0b6121 100644 (file)
@@ -144,9 +144,33 @@ function forum_readmessages(target_div, gt_msg, lt_msg)
 //
 function render_messages(msgs, prefix, view)
 {
-       for (var i in msgs)
+       for (i=0; i<msgs.length; ++i)
        {
-               document.getElementById(prefix + msgs[i]).innerHTML = "<b>Message " + msgs[i] + " got rendered!!!</b>";
+               render_one(prefix+msgs[i], msgs[i], view);
        }
+}
+
 
+// We have to put each XHR for render_messages() into its own stack frame, otherwise it jumbles them together.  I don't know why.
+function render_one(div, msgnum, view)
+{
+       var request = new XMLHttpRequest();
+       request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + msgs[i] + "/html", true);
+       request.onreadystatechange = function()
+       {
+               if (this.readyState === 4)
+               {
+                       if ((this.status / 100) == 2)
+                       {
+                               document.getElementById(div).innerHTML = this.responseText;     // FIXME don't let the C server render it.  do JSON now.
+                       }
+                       else
+                       {
+                               document.getElementById(div).innerHTML = "ERROR";
+                       }
+               }
+       };
+       request.send();
+       request = null;
 }
+