+ if (max_msg < 9999999999)
+ {
+ request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.lt|" + max_msg, true);
+ }
+ else
+ {
+ request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/msgs.gt|" + min_msg, true);
+ }
+ request.onreadystatechange = function()
+ {
+ if (this.readyState === 4)
+ {
+ if ((this.status / 100) == 2)
+ {
+ msgs = JSON.parse(this.responseText);
+ document.getElementById(innerdivname).innerHTML = "" ;
+
+ // If we were given an explicit starting point, by all means start there.
+ // Note that we don't have to remove them from the array because we did a 'msgs gt|xxx' command to Citadel.
+ if (min_msg > 0)
+ {
+ msgs = msgs.slice(0, messages_per_page);
+ }
+
+ // show us the last 20 messages and scroll to the bottom (this will become the not-logged-in behavior)
+ else if ((logged_in) | (!logged_in) | (max_msg < 9999999999))
+ {
+ if (msgs.length > messages_per_page)
+ {
+ msgs = msgs.slice(msgs.length - messages_per_page);
+ }
+ new_old_div_name = randomString(5);
+ if (msgs.length < 1)
+ {
+ newlt = max_msg;
+ }
+ else
+ {
+ newlt = msgs[0];
+ }
+ document.getElementById(innerdivname).innerHTML +=
+ "<div id=\"" + new_old_div_name + "\">" +
+ "<a href=\"javascript:forum_readmessages('" + new_old_div_name + "', 0, " + newlt + ");\">" +
+ "link to msgs less than " + newlt + "</a></div>" ;
+ }
+
+ // Render the divs (we will fill them in later)
+ for (var i in msgs)
+ {
+ if ((msgs[i] > min_msg) && (msgs[i] < max_msg))
+ {
+ document.getElementById(innerdivname).innerHTML += "<div id=\"ctdl_msg_" + msgs[i] + "\">#" + msgs[i] + "</div>" ;
+ }
+ }
+ if (max_msg == 9999999999)
+ {
+ new_new_div_name = randomString(5);
+ if (msgs.length <= 0)
+ {
+ newgt = min_msg;
+ }
+ else
+ {
+ newgt = msgs[msgs.length-1];
+ }
+ document.getElementById(innerdivname).innerHTML +=
+ "<div id=\"" + new_new_div_name + "\">" +
+ "<a href=\"javascript:forum_readmessages('" + new_new_div_name + "', " + newgt + ", 9999999999);\">" +
+ "link to msgs greater than " + newgt + "</a></div>" ;
+ }
+
+ // Render the individual messages in the divs
+ for (var i in msgs)
+ {
+ if ((msgs[i] > min_msg) && (msgs[i] < max_msg))
+ {
+ document.getElementById("ctdl_msg_" + msgs[i]).innerHTML = "<b>Message " + msgs[i] + " got rendered!!!</b>";
+ }
+ }
+