<commit_before>chromeMyAdmin.directive("loginForm", function() {
    "use strict";

    return {
        restrict: "E",
        templateUrl: "templates/login_form.html"
    };
});

chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLClientService", "favoriteService", "Events", function($scope, $timeout, mySQLClientService, favoriteService, Events) {
    "use strict";

    // Private methods

    var showErrorMessage = function(message) {
        $scope.safeApply(function() {
            $scope.errorMessage = message;
        });
    };

    var hideMessage = function() {
        $scope.safeApply(function() {
            $scope.successMessage = "";
            $scope.errorMessage = "";
        });
    };

    var showSuccessMessage = function(message) {
        $scope.safeApply(function() {
            $scope.successMessage = message;
        });
    };

    var onConnected = function(initialHandshakeRequest) {
        $scope.safeApply(function() {
            var connectionInfo = {
                name: $scope.name,
                hostName: $scope.hostName,
                port: $scope.portNumber,
                userName: $scope.userName,
                initialHandshakeRequest: initialHandshakeRequest
            };
            $scope.notifyConnectionChanged(connectionInfo);
        });
    };

    var assignEventHandlers = function() {
        $scope.$on(Events.FAVORITE_SELECTED, function(event, favorite) {
            $scope.safeApply(function() {
                $scope.name = favorite.name;
                $scope.hostName = favorite.hostName;
                $scope.portNumber = favorite.port;
                $scope.userName = favorite.userName;
                $scope.password = <PASSWORD>;
            });
        });
        $scope.$on(Events.LOGIN, function(event, data) {
            doConnect();
        });
    };

    var showAboutMe = function() {
        var manifest = chrome.runtime.getManifest();
        var aboutMe = manifest.name + " version " + manifest.version;
        aboutMe += " (C) " + manifest.author + " 2014, all rights reserved.";
        $scope.aboutMe = aboutMe;
    };

    var doConnect = function() {
        hideMessage();
        mySQLClientService.login(
            $scope.hostName,
            Number($scope.portNumber),
            $scope.userName,
            $scope.password
        ).then(function(initialHandshakeRequest) {
            onConnected(initialHandshakeRequest);
        }, function(reason) {
            showErrorMessage("Connection failed: " + reason);
        });
    };

    // Public methods

    $scope.initialize = function() {
        $scope.successMessage = "";
        $scope.errorMessage = "";
        assignEventHandlers();
        showAboutMe();
    };

    $scope.connect = function() {
        doConnect();
    };

    $scope.doTestConnection = function() {
        hideMessage();
        mySQLClientService.login(
            $scope.hostName,
            Number($scope.portNumber),
            $scope.userName,
            $scope.password
        ).then(function(initialHandshakeRequest) {
            showSuccessMessage("Connection was successfully.");
            mySQLClientService.logout();
        }, function(reason) {
            showErrorMessage("Connection failed: " + reason);
        });
    };
<commit_msg>Set default port number on the login panel.<commit_after>chromeMyAdmin.directive("loginForm", function() {
    "use strict";

    return {
        restrict: "E",
        templateUrl: "templates/login_form.html"
    };
});

chromeMyAdmin.controller("LoginFormController", ["$scope", "$timeout", "mySQLClientService", "favoriteService", "Events", function($scope, $timeout, mySQLClientService, favoriteService, Events) {
    "use strict";

    // Private methods

    var showErrorMessage = function(message) {
        $scope.safeApply(function() {
            $scope.errorMessage = message;
        });
    };

    var hideMessage = function() {
        $scope.safeApply(function() {
            $scope.successMessage = "";
            $scope.errorMessage = "";
        });
    };

    var showSuccessMessage = function(message) {
        $scope.safeApply(function() {
            $scope.successMessage = message;
        });
    };

    var onConnected = function(initialHandshakeRequest) {
        $scope.safeApply(function() {
            var connectionInfo = {
                name: $scope.name,
                hostName: $scope.hostName,
                port: $scope.portNumber,
                userName: $scope.userName,
                initialHandshakeRequest: initialHandshakeRequest
            };
            $scope.notifyConnectionChanged(connectionInfo);
        });
    };

    var assignEventHandlers = function() {
        $scope.$on(Events.FAVORITE_SELECTED, function(event, favorite) {
            $scope.safeApply(function() {
                $scope.name = favorite.name;
                $scope.hostName = favorite.hostName;
                $scope.portNumber = favorite.port;
                $scope.userName = favorite.userName;
                $scope.password = <PASSWORD>;
            });
        });
        $scope.$on(Events.LOGIN, function(event, data) {
            doConnect();
        });
    };

    var showAboutMe = function() {
        var manifest = chrome.runtime.getManifest();
        var aboutMe = manifest.name + " version " + manifest.version;
        aboutMe += " (C) " + manifest.author + " 2014, all rights reserved.";
        $scope.aboutMe = aboutMe;
    };

    var doConnect = function() {
        hideMessage();
        mySQLClientService.login(
            $scope.hostName,
            Number($scope.portNumber),
            $scope.userName,
            $scope.password
        ).then(function(initialHandshakeRequest) {
            onConnected(initialHandshakeRequest);
        }, function(reason) {
            showErrorMessage("Connection failed: " + reason);
        });
    };

    // Public methods

    $scope.initialize = function() {
        $scope.successMessage = "";
        $scope.errorMessage = "";
        $scope.portNumber = 3306;
        assignEventHandlers();
        showAboutMe();
    };

    $scope.connect = function() {
        doConnect();
    };

    $scope.doTestConnection = function() {
        hideMessage();
        mySQLClientService.login(
            $scope.hostName,
            Number($scope.portNumber),
            $scope.userName,
            $scope.password
        ).then(function(initialHandshakeRequest) {
            showSuccessMessage("Connection was successfully.");
            mySQLClientService.logout();
        }, function(reason) {
            showErrorMessage("Connection failed: " + reason);
        });
    };

{'fraction_non_alphanumeric': 0.12629552857565887, 'fraction_numerical': 0.0017767249037607344, 'mean_word_length': 1.998224589436307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6537124', 'n_tokens_mistral': 1788, 'n_tokens_neox': 1732, 'n_words': 295}