Clickable links
authorDarren <darren@darrenwhitlen.com>
Sun, 2 Sep 2012 18:29:34 +0000 (19:29 +0100)
committerDarren <darren@darrenwhitlen.com>
Sun, 2 Sep 2012 18:29:34 +0000 (19:29 +0100)
client_backbone/dev/view.js

index f18866dc07b1b555cf8650480ba1df8e3bebe52b..eb5528b4d26fa0a6c8c5fdfa11e683ff8d807eb8 100644 (file)
@@ -185,6 +185,19 @@ kiwi.view.Panel = Backbone.View.extend({
         });\r
 \r
 \r
+        // Make links clickable\r
+        msg.msg = msg.msg.replace(/((https?\:\/\/|ftp\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]*))?/gi, function (url) {\r
+            var nice;\r
+\r
+            nice = url;\r
+            if (nice.length > 100) {\r
+                nice = nice.substr(0, 100) + '...';\r
+            }\r
+\r
+            return '<a class="link_ext" target="_blank" rel="nofollow" href="' + url + '">' + nice + '</a>';\r
+        });\r
+\r
+\r
         // Convert IRC formatting into HTML formatting\r
         msg.msg = formatIRCMsg(msg.msg);\r
 \r