<commit_before>;(function ($) {

    // Constants

    var LOGOUT_FORM = ".logout-form",

        LOGIN_FORM = ".login-form",

        STATUS_DIALOG = "#status-dialog",

        CONFIRM_DIALOG = "#confirm-dialog",

        LOGIN_STATUS_CONNECTING = "connecting",

        LOGIN_STATUS_DISCONNECTING = "disconnecting",

        LOGIN_STATUS_CONNECTED = "connected",

        LOGIN_STATUS_DISCONNECTED = "disconnected",

        MSG_TIMESTAMP_CONNECTED = "Connected",

        MSG_TIMESTAMP_DISCONNECTED = "Disconnected",

        MSG_LOGIN = "Logging into Interactive Brokers",

        MSG_LOGOUT = "Logging out of Interactive Brokers",

        MSG_CONFIRM_LOGOUT = "Logout of Interactive Brokers now?",

        MAX_ATTEMPTS = 20,

        SHOW_HIDE_INTERVAL = 300,

        STATUS_REQUEST_INTERVAL = 2000,

        POPUPS = '#popups',

        M_LOG = '#mlog';


    //  Login module
    IB.Login = {
        init : function () {
            this.attempts = 0;
            this.statusTimer = null;
            this.getStatus();
            this.handlers();
            this.popups();
            IB.Util.Xhr.cache(false);
        },

        handlers : function () {
            var status = $(STATUS_DIALOG),
                confirm = $(CONFIRM_DIALOG),
                cancelButton = status.find(".cancel-btn"),
                yesButton = confirm.find(".yes-btn"),
                noButton = confirm.find(".no-btn");

            $(LOGIN_FORM).on("submit", $.proxy(this.login, this));
            $(LOGOUT_FORM).on("submit", $.proxy(this.logout, this));

            cancelButton.on("click", $.proxy(this.logoutConfirm, this));
            yesButton.on("click", $.proxy(this.logoutConfirm, this));
            noButton.on("click", $.proxy(this.showConfirmDialog, this, false));
        },

        popups : function () {
            this.popup = IB.UI.Widgets.Popup();
            this.popup.init(POPUPS);
            this.mLog = IB.UI.Widgets.Popup();
            this.mLog.init(M_LOG);
        },

        showConfirmDialog : function (show) {
            var confirm = $(CONFIRM_DIALOG);
            if (show) {
                confirm.find(".text").html(MSG_CONFIRM_LOGOUT);
                $(LOGOUT_FORM).hide(SHOW_HIDE_INTERVAL);
                confirm.show(SHOW_HIDE_INTERVAL);
            }
            else {
                $(LOGOUT_FORM).show(SHOW_HIDE_INTERVAL);
                confirm.hide(SHOW_HIDE_INTERVAL);
            }
        },

        login : function(e) {
            e.preventDefault();
            e.stopPropagation();
            this.popup.destroy();
            this.mLog.destroy();
            var userName = $("#user-name").val(),
                passwd = $("#password").val(),
                request = {
                    type : 'POST',
                    url : '/v1/login.json',
                    data : {
                        username : userName,
                        password : <PASSWORD>
                    },
                    contentType: "application/x-www-form-urlencoded",
                    dataType: "json",
                    success : $.proxy(this.loginSuccess, this)
                };
            IB.Util.Xhr.send(request);
            this.updateStatus(MSG_LOGIN, true);
        },
<commit_msg>fix bug of accumulating failed connect attempts<commit_after>;(function ($) {

    // Constants

    var LOGOUT_FORM = ".logout-form",

        LOGIN_FORM = ".login-form",

        STATUS_DIALOG = "#status-dialog",

        CONFIRM_DIALOG = "#confirm-dialog",

        LOGIN_STATUS_CONNECTING = "connecting",

        LOGIN_STATUS_DISCONNECTING = "disconnecting",

        LOGIN_STATUS_CONNECTED = "connected",

        LOGIN_STATUS_DISCONNECTED = "disconnected",

        MSG_TIMESTAMP_CONNECTED = "Connected",

        MSG_TIMESTAMP_DISCONNECTED = "Disconnected",

        MSG_LOGIN = "Logging into Interactive Brokers",

        MSG_LOGOUT = "Logging out of Interactive Brokers",

        MSG_CONFIRM_LOGOUT = "Logout of Interactive Brokers now?",

        MAX_ATTEMPTS = 20,

        SHOW_HIDE_INTERVAL = 300,

        STATUS_REQUEST_INTERVAL = 2000,

        POPUPS = '#popups',

        M_LOG = '#mlog';


    //  Login module
    IB.Login = {
        init : function () {
            this.attempts = 0;
            this.statusTimer = null;
            this.getStatus();
            this.handlers();
            this.popups();
            IB.Util.Xhr.cache(false);
        },

        handlers : function () {
            var status = $(STATUS_DIALOG),
                confirm = $(CONFIRM_DIALOG),
                cancelButton = status.find(".cancel-btn"),
                yesButton = confirm.find(".yes-btn"),
                noButton = confirm.find(".no-btn");

            $(LOGIN_FORM).on("submit", $.proxy(this.login, this));
            $(LOGOUT_FORM).on("submit", $.proxy(this.logout, this));

            cancelButton.on("click", $.proxy(this.logoutConfirm, this));
            yesButton.on("click", $.proxy(this.logoutConfirm, this));
            noButton.on("click", $.proxy(this.showConfirmDialog, this, false));
        },

        popups : function () {
            this.popup = IB.UI.Widgets.Popup();
            this.popup.init(POPUPS);
            this.mLog = IB.UI.Widgets.Popup();
            this.mLog.init(M_LOG);
        },

        showConfirmDialog : function (show) {
            var confirm = $(CONFIRM_DIALOG);
            if (show) {
                confirm.find(".text").html(MSG_CONFIRM_LOGOUT);
                $(LOGOUT_FORM).hide(SHOW_HIDE_INTERVAL);
                confirm.show(SHOW_HIDE_INTERVAL);
            }
            else {
                $(LOGOUT_FORM).show(SHOW_HIDE_INTERVAL);
                confirm.hide(SHOW_HIDE_INTERVAL);
            }
        },

        login : function(e) {
            e.preventDefault();
            e.stopPropagation();
            this.popup.destroy();
            this.mLog.destroy();
            var userName = $("#user-name").val(),
                passwd = $("#password").val(),
                request = {
                    type : 'POST',
                    url : '/v1/login.json',
                    data : {
                        username : userName,
                        password : <PASSWORD>
                    },
                    contentType: "application/x-www-form-urlencoded",
                    dataType: "json",
                    success : $.proxy(this.loginSuccess, this)
                };
            this.attempts = 0;
            IB.Util.Xhr.send(request);
            this.updateStatus(MSG_LOGIN, true);
        },

{'fraction_non_alphanumeric': 0.12774662827701166, 'fraction_numerical': 0.0034853765722079105, 'mean_word_length': 1.5670945157526255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3664491', 'n_tokens_mistral': 1979, 'n_tokens_neox': 1845, 'n_words': 298}