<commit_before>var channelList = [];
var socket = null;

function update(msg) 
{
    for(i in channelList) {
        console.log(msg.channel);
        if(channelList[i].toLowerCase() == msg.channel.toLowerCase())
            $("#messages"+i).append("&lt;"+msg.from+"&gt; "+scanMsg(msg.content)+"<br/>");

        scroll(i);
    }

}

function updateAll(list)
{
    for(i in list) {
        for(j in channelList) {
            if(channelList[j].toLowerCase() == list[i].channel.toLowerCase())
                $("#messages"+j).append("&lt;"+list[i].from+"&gt; "+scanMsg(list[i].msg)+"<br/>");
        }
    }

    for(i in channelList)
        scroll(i);
}

function scanMsg(msg) 
{
    var regex = /\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i;

    return msg.replace(regex," <a href=\"$&\" target=\"_blank\">$&</a> ");
}

function sendMsgToActiveChannel(msg)
{
    var activeChannel = $.trim($('#tabs>ul>li.ui-state-active>a').html());
    var data = {
        type: 'privmsg', data:
        {
            channel:activeChannel,
            message:msg
        }
    };

    socket.send(data);
}

function scroll(i) 
{
    $("#messages"+i).scrollTop(9999999);
}

function createChannels(list) 
{
    str = '<div id="tabs"><ul>';

    for(i in list) {
        str += '<li><a href="#tabs-'+i+'">'+list[i].toLowerCase()+'</a></li>';
    }

    str += '</ul>';

    for(i in list) {
        str += '<div id="tabs-'+i+'"><div id="messages'+i+'" class="messages"></div>';
        str += '<div id="inputs-'+i+'"><input type="text" id="input-text'+i+'" class="input-message"/></div>';
        str += '</div>';
    }

    str += '</div>';

    $('#tab_wrapper').html(str);

    $('#tabs').tabs({selected: 0, show: function() {
        for(i in channelList) 
        scroll(i);
    }});

    $('.input-message').each(function() {
       $(this).keypress(function(e)
        {
            code= (e.keyCode ? e.keyCode : e.which);
            if (code == 13) {
                sendMsgToActiveChannel($(this).val());
                $(this).val('');
            }
        });
    });
}

function parseIncomingMessage(incomingMessage) {
    
    console.log('message received: ' + incomingMessage.content);

    var message = {
        channel: 'server',
        content: incomingMessage.content
    }

    var compiler = new Compiler();
    console.log(compiler.compile(message.content));

    return message;
}

function doPage(nodeServerHost, nodeServerPort, ircServerHost, ircServerPort, nickname, channels)
{
    socket = new io.Socket(nodeServerHost, {port: nodeServerPort});
    socket.connect();

    var data = {
        type: 'connect', data: 
        {
            ircHost:ircServerHost, 
            ircPort:ircServerPort, 
            nick:nickname,
            channels:channels
        }
    };

    socket.send(data);

    channelList = ['server'];
    createChannels(channelList);

    socket.on('message', function(incomingMessage) {

        var message = parseIncomingMessage(incomingMessage);
        update(message);

    });
}

$(document).ready(function() {
    if(!"WebSocket" in window) {<commit_msg>The client is now able to respond to the PING<commit_after>var channelList = [];
var socket = null;

function update(msg) 
{
    for(i in channelList) {
        if(channelList[i].toLowerCase() == msg.channel.toLowerCase())
            $("#messages"+i).append("&lt;"+msg.from+"&gt; "+scanMsg(msg.content)+"<br/>");

        scroll(i);
    }

}

function updateAll(list)
{
    for(i in list) {
        for(j in channelList) {
            if(channelList[j].toLowerCase() == list[i].channel.toLowerCase())
                $("#messages"+j).append("&lt;"+list[i].from+"&gt; "+scanMsg(list[i].msg)+"<br/>");
        }
    }

    for(i in channelList)
        scroll(i);
}

function scanMsg(msg) 
{
    var regex = /\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)[-A-Z0-9+&@#\/%=~_|$?!:,.]*[A-Z0-9+&@#\/%=~_|$]/i;

    return msg.replace(regex," <a href=\"$&\" target=\"_blank\">$&</a> ");
}

function sendMsgToActiveChannel(msg)
{
    var activeChannel = $.trim($('#tabs>ul>li.ui-state-active>a').html());
    var data = {
        type: 'privmsg', data:
        {
            channel:activeChannel,
            message:msg
        }
    };

    socket.send(data);
}

function scroll(i) 
{
    $("#messages"+i).scrollTop(9999999);
}

function createChannels(list) 
{
    str = '<div id="tabs"><ul>';

    for(i in list) {
        str += '<li><a href="#tabs-'+i+'">'+list[i].toLowerCase()+'</a></li>';
    }

    str += '</ul>';

    for(i in list) {
        str += '<div id="tabs-'+i+'"><div id="messages'+i+'" class="messages"></div>';
        str += '<div id="inputs-'+i+'"><input type="text" id="input-text'+i+'" class="input-message"/></div>';
        str += '</div>';
    }

    str += '</div>';

    $('#tab_wrapper').html(str);

    $('#tabs').tabs({selected: 0, show: function() {
        for(i in channelList) 
        scroll(i);
    }});

    $('.input-message').each(function() {
       $(this).keypress(function(e)
        {
            code= (e.keyCode ? e.keyCode : e.which);
            if (code == 13) {
                sendMsgToActiveChannel($(this).val());
                $(this).val('');
            }
        });
    });
}

function parseIncomingMessage(incomingMessage) {
    
    console.log('message received: ' + incomingMessage.content);

    var message = {
        channel: 'server',
        content: incomingMessage.content
    }

    var compiler = new Compiler();
    var compiledMessage = compiler.compile(message.content);

    $(this).trigger('irc.'+compiledMessage.command, compiledMessage);

    return message;
}

function doPage(nodeServerHost, nodeServerPort, ircServerHost, ircServerPort, nickname, channels)
{
    socket = new io.Socket(nodeServerHost, {port: nodeServerPort});
    socket.connect();

    var data = {
        type: 'connect', data: 
        {
            ircHost:ircServerHost, 
            ircPort:ircServerPort, 
            nick:nickname,
            channels:channels
        }
    };

    socket.send(data);

    channelList = ['server'];
    createChannels(channelList);

    $(this).bind('irc.notice',function(event, data) { 

    });

    $(this).bind('irc.ping',function(event, data) { 
        var data = {
            type: 'message', data:
            {
                message:'PONG ' + ':' + data.params[0]
            }
        };

        console.log(data);
        socket.send(data);
    });

    socket.on('message', function(incomingMessage) {

        var message = parseIncomingMessage(incomingMessage);
        update(message);

    });
}

$(document).ready(function() {
    if(!"WebSocket" in window) {
{'fraction_non_alphanumeric': 0.20297176820208024, 'fraction_numerical': 0.004309063893016345, 'mean_word_length': 2.434183673469388, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1506348', 'n_tokens_mistral': 2258, 'n_tokens_neox': 2191, 'n_words': 351}