- 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.
+ request.open("GET", "/ctdl/r/" + escapeHTMLURI(current_room) + "/" + msgs[i] + "/json", true);
+ request.onreadystatechange = function() {
+ if (this.readyState === 4) {
+ if ((this.status / 100) == 2) {
+ msg = JSON.parse(this.responseText);
+
+ document.getElementById(div).innerHTML =
+ "<div class=\"ctdl-msg-wrapper\">" // begin message wrapper
+ + "<div class=\"ctdl-avatar\">" // begin avatar
+ + "<img src=\"/ctdl/u/" + msg.from + "/userpic\" width=\"32\" "
+ + "onerror=\"this.parentNode.innerHTML='<i class="fa fa-user-circle fa-2x"></i> '\">"
+ + "</div>" // end avatar
+ + "<div class=\"ctdl-msg-content\">" // begin content
+ + "<div class=\"ctdl-msg-header\">" // begin header
+ + "<span class=\"ctdl-username\"><a href=\"#\">" // FIXME link to user profile
+ + msg.from
+ + "</a></span> "
+ + "<span class=\"ctdl-msgdate\">"
+ + msg.time
+ + "</span> "
+ + "</div>" // end header
+ + "<div>" // begin body
+ + msg.text
+ + "</div>" // end body
+ + "</div>" // end content
+ + "</div>" // end wrapper
+ ;