]> git.scottworley.com Git - reliable-chat/blobdiff - webclient/rc.html
Classify different kinds of messages
[reliable-chat] / webclient / rc.html
index 840851c12f39ecd4be0bcc6944728ec14531e877..e23286e1fcd2acadd016ef198d264d6a5656d270 100644 (file)
                timestamp.appendChild(document.createTextNode(timestamp_text));
                message.UI.appendChild(timestamp);
 
-               message.UI.appendChild(document.createTextNode(message.Text));
+               // Classify different message types
+               var text_span = document.createElement("span");
+               var type;
+               if (/^\*\*\* /.test(message.Text)) {
+                       type = "status";
+               } else if (/^\* /.test(message.Text)) {
+                       type = "me";
+               } else {
+                       type = "text";
+               }
+               if (Object.keys(message.ServerTimes).length == 0) {
+                       type += " self";
+               }
+               text_span.setAttribute("class", type);
+               text_span.appendChild(document.createTextNode(message.Text));
+               message.UI.appendChild(text_span);
        }
 
        function rcaddmessagetohistory(message) {