]> git.babelmonkeys.de Git - xmppchat.git/commitdiff
/me support
authorFlorian Zeitz <florob@babelmonkeys.de>
Sat, 28 Nov 2009 21:27:21 +0000 (22:27 +0100)
committerFlorian Zeitz <florob@babelmonkeys.de>
Sat, 28 Nov 2009 21:27:21 +0000 (22:27 +0100)
 * Support for the /me command
 * Fix escaping
 * New strophe.js version

js/main.js
js/strophejs

index c64776da37ac3b9bcffbce38cf17703797323adb..6072c6704f404a13ae48428c9fb0aefe1e5a5e6c 100644 (file)
@@ -72,16 +72,23 @@ function addBubble(nick) {
 
 function handleMessage(msg) {
        var html = '';
-       var sender = Strophe.getResourceFromJid(msg.getAttribute('from'));
+       var sender = Strophe.xmlescape(Strophe.getResourceFromJid(msg.getAttribute('from')));
        var type = msg.getAttribute('type');
-       var body = Strophe.getText(msg.getElementsByTagName('body')[0]);
+       var body = Strophe.xmlescape(Strophe.getText(msg.getElementsByTagName('body')[0]));
 
        html += '<div class="msg">';
        if (sender) {
-               html += '<span class="sender">';
-               html += sender;
-               html += ':</span> ';
-               html += body + '</div>';
+               if (body.search(/^\/me/) == 0) {
+                       body = body.replace(/^\/me/, sender);
+                       html += '<span class="sender">';
+                       html += body;
+                       html += '</span></div>';
+               } else {
+                       html += '<span class="sender">';
+                       html += sender;
+                       html += ':</span> ';
+                       html += body + '</div>';
+               }
        } else {
                html += '<span class="server">';
                html += body + '</span></div>';
index f31e73fd12ca779b6cd93043496eda001e3b1aee..77fd14321c069bf88d0bf6041af8951c22420cb3 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f31e73fd12ca779b6cd93043496eda001e3b1aee
+Subproject commit 77fd14321c069bf88d0bf6041af8951c22420cb3