<commit_before>/**
 * MartIrc constructor
 *
 * @contructor
 *
 */
MartIrc = function() {
    if (! (this instanceof arguments.callee)) {
        return new arguments.callee(arguments);
    }

    var self = this;

    self.server = new Server();
    self.channels = new Array();

    self.ircConnection = null;
    self.storage = new Storage();
    self.utils = new Utils();

    self.init();
    self.bindEvents();
};

/**
 * MartIrc init
 *
 */
MartIrc.prototype.init = function() {
    var self = this;

    if(self.storage.getNickname()){
	$('#nickname').val(self.storage.getNickname());
    }

    $('input[name=connectOnStartup]').attr('checked', self.storage.getConnectOnStartup());

    if(self.storage.getConnectOnStartup()){
	self.connect();
    }
};

MartIrc.prototype.bindEvents = function() {
    var self = this;

    $('#connectButton').click(function() {
        self.connect();
    });

    $('#connectOnStartup').click(function(event) {
	self.storage.setConnectOnStartup($('input[name=connectOnStartup]').is(':checked'));
    });

    $('#nickname').change(function(event) {
	self.storage.setNickname($('#nickname').val());
    });

    $('#prompt form').submit(function(event) {
        event.preventDefault();

        self.parseOutgoingMessage();
    });

    $('#chat .current-title img').live('click', function(event) {
        self.removeChannel(null);
    });

    $('#channels a.user, #channels a.channel, #users .list.active a').live('click', function(event) {
        self.createChannel($(this).text());
    });

    $('#channels a.server').live('click', function(event) {
        self.server.focus();
    });

    $('#prompt form input').focus();
};

MartIrc.prototype.connect = function() {
    var self = this;

    if (self.ircConnection && self.ircConnection.connected()) {
        self.ircConnection.disconnect();
<commit_msg>Fix: remove all channels and users when reseting connection<commit_after>/**
 * MartIrc constructor
 *
 * @contructor
 *
 */
MartIrc = function() {
    if (! (this instanceof arguments.callee)) {
        return new arguments.callee(arguments);
    }

    var self = this;

    self.server = new Server();
    self.channels = new Array();

    self.ircConnection = null;
    self.storage = new Storage();
    self.utils = new Utils();

    self.init();
    self.bindEvents();
};

/**
 * MartIrc init
 *
 */
MartIrc.prototype.init = function() {
    var self = this;

    if(self.storage.getNickname()){
	$('#nickname').val(self.storage.getNickname());
    }

    $('input[name=connectOnStartup]').attr('checked', self.storage.getConnectOnStartup());

    if(self.storage.getConnectOnStartup()){
	self.connect();
    }
};

MartIrc.prototype.bindEvents = function() {
    var self = this;

    $('#connectButton').click(function() {
        self.connect();
    });

    $('#connectOnStartup').click(function(event) {
	self.storage.setConnectOnStartup($('input[name=connectOnStartup]').is(':checked'));
    });

    $('#nickname').change(function(event) {
	self.storage.setNickname($('#nickname').val());
    });

    $('#prompt form').submit(function(event) {
        event.preventDefault();

        self.parseOutgoingMessage();
    });

    $('#chat .current-title img').live('click', function(event) {
        self.removeChannel(null);
    });

    $('#channels a.user, #channels a.channel, #users .list.active a').live('click', function(event) {
        self.createChannel($(this).text());
    });

    $('#channels a.server').live('click', function(event) {
        self.server.focus();
    });

    $('#prompt form input').focus();
};

MartIrc.prototype.connect = function() {
    var self = this;

    if (self.ircConnection && self.ircConnection.connected()) {
        self.ircConnection.disconnect();

	for(name in self.channels){
	    self.channels[name].destroy();
	}

	self.channels = new Array();
	self.users = new Array();

	self.server.focus();

{'fraction_non_alphanumeric': 0.19040326697294538, 'fraction_numerical': 0.0, 'mean_word_length': 3.2830601092896177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4470795', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1203, 'n_words': 199}