From 3da35ead77f2920042ddd54c3559d58a21abe3e3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 14 Feb 2018 22:15:18 -0500 Subject: [PATCH] Got it! Temporarily working with the server-side C renderer --- webcit-ng/forum_view.c | 1 - webcit-ng/static/js/views.js | 28 ++++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/webcit-ng/forum_view.c b/webcit-ng/forum_view.c index 354fcea01..0eeaf8566 100644 --- a/webcit-ng/forum_view.c +++ b/webcit-ng/forum_view.c @@ -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, "\r\n"); setup_for_forum_view(c); // FIXME way too inefficient to do this for every message !!!!!!!!!!!!! diff --git a/webcit-ng/static/js/views.js b/webcit-ng/static/js/views.js index 12642210f..171fdf935 100644 --- a/webcit-ng/static/js/views.js +++ b/webcit-ng/static/js/views.js @@ -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"; + 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; } + -- 2.30.2