logs/script.js
author Stiletto <blasux@blasux.ru>
Wed, 24 Oct 2012 15:07:07 +0400
changeset 10 6b0d56b01ba0
parent 9 d3260253f0bd
permissions -rw-r--r--
C generation

window.onload = function () {
    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];
            if (nicktd) {
                var nick = nicktd.textContent;
                var sum = 0;
                for( var j = 0, iTop = nick.length; j < iTop; j++ ) {
                    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>';
                });
            }
        }
    }
};