logs/script.js
changeset 9 d3260253f0bd
parent 3 dd7a02c6d476
--- a/logs/script.js	Wed Oct 24 01:03:02 2012 +0400
+++ b/logs/script.js	Wed Oct 24 14:08:16 2012 +0400
@@ -2,10 +2,11 @@
     var log = document.getElementById("log");
     var rows = log.getElementsByTagName("tr");
     var rownum = rows.length;
+    var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
     for (var i = 0; i < rownum; i++) {
         var row = rows[i];
         if (row.getAttribute("class") == "message") {
-            var nicktd = row.getElementsByClassName("nick")[0];
+            /*var nicktd = row.getElementsByClassName("nick")[0];
             if (nicktd) {
                 var nick = nicktd.textContent;
                 var sum = 0;
@@ -13,6 +14,12 @@
                     sum += 0x56 ^ nick.charCodeAt(j);
                 }
                 nicktd.setAttribute("class","nick nick"+(sum % 10));
+            }*/
+            var texttd = row.getElementsByClassName("text")[0];
+            if (texttd) {
+                texttd.innerHTML = texttd.innerHTML.replace(urlRegex, function(url) {
+                            return '<a href="' + url + '">' + url + '</a>';
+                });
             }
         }
     }