]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
render image urls
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 24 Jul 2014 20:31:35 +0000 (01:31 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 24 Jul 2014 20:31:35 +0000 (01:31 +0500)
html5/verto/demo/index.html
html5/verto/demo/verto.js

index 415def7224457b4e2bf6e5e637c4d82ad0caacde..af26f5b2b1f2c901764a4c8ad924e4ea25e2ba7a 100644 (file)
        color: #ff3333;
 }
 
+.chatimg
+{
+       max-width:100px;
+}
+
 .l1
 {
        border:1;
index 52ffd640072a75a70a479e62a5fd7d819c6b8988..de27cabbb1832523c3fd0b5831f7f026693e63e8 100644 (file)
@@ -112,12 +112,19 @@ var callbacks = {
             }
             break;
         case $.verto.enum.message.info:
-           var body = data.body.replace(/(http[s]{0,1}:\/\/\S+)/g, "<a target='_blank' href='$1'>$1<\/a>");
+           var body = data.body;
+
+           if (body.match(/\.gif|\.jpg|\.jpeg|\.png/)) {
+               body = body.replace(/(http[s]{0,1}:\/\/\S+)/g, "<a target='_blank' href='$1'>$1<br><img border='0' class='chatimg' src='$1'><\/a>");
+           } else {
+               body = body.replace(/(http[s]{0,1}:\/\/\S+)/g, "<a target='_blank' href='$1'>$1<\/a>");
+           }
 
            if (body.slice(-1) !== "\n") {
                body += "\n";
            }
            body = body.replace(/(?:\r\n|\r|\n)/g, '<br />');
+           
            var from = data.from_msg_name || data.from;
            
             $("#chatwin").append("<span class=chatuid>" + from + ":</span><br>" + body);