logs/script.js
author Stiletto <blasux@blasux.ru>
Mon, 05 Nov 2012 23:54:44 +0400
changeset 12 d3e36b368fc5
parent 9 d3260253f0bd
permissions -rw-r--r--
iq, commands, makefile up
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     1
window.onload = function () {
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     2
    var log = document.getElementById("log");
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     3
    var rows = log.getElementsByTagName("tr");
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     4
    var rownum = rows.length;
9
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
     5
    var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
3
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     6
    for (var i = 0; i < rownum; i++) {
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     7
        var row = rows[i];
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
     8
        if (row.getAttribute("class") == "message") {
9
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
     9
            /*var nicktd = row.getElementsByClassName("nick")[0];
3
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    10
            if (nicktd) {
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    11
                var nick = nicktd.textContent;
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    12
                var sum = 0;
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    13
                for( var j = 0, iTop = nick.length; j < iTop; j++ ) {
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    14
                    sum += 0x56 ^ nick.charCodeAt(j);
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    15
                }
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    16
                nicktd.setAttribute("class","nick nick"+(sum % 10));
9
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    17
            }*/
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    18
            var texttd = row.getElementsByClassName("text")[0];
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    19
            if (texttd) {
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    20
                texttd.innerHTML = texttd.innerHTML.replace(urlRegex, function(url) {
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    21
                            return '<a href="' + url + '">' + url + '</a>';
d3260253f0bd Moved nick colors to vala code
Stiletto <blasux@blasux.ru>
parents: 3
diff changeset
    22
                });
3
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    23
            }
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    24
        }
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    25
    }
dd7a02c6d476 muc log, updated example config
Stiletto <blasux@blasux.ru>
parents:
diff changeset
    26
};