<commit_before>'use strict';



/* Controllers */
var springChatControllers = angular.module('springChat.controllers', ['monospaced.elastic', 'ui.bootstrap', 'infinite-scroll', 'toaster', 'ngRoute', 'ngAnimate', 'ngResource', 'ngCookies', 'ngSanitize']);
springChatControllers.config(function($routeProvider) {
    $routeProvider.when("/chatrooms", {
        templateUrl: "dialogsTemplate.html",
        controller: "DialogsRouteController"
    });
    $routeProvider.when("/dialog_view/:roomId/", {
        templateUrl: "chatTemplate.html",
        controller: "ChatRouteController"
    });
    $routeProvider.when("/teachers_list", {
        templateUrl: "teachersTemplate.html",
        controller: "TeachersListRouteController"
    });
    $routeProvider.when("/private_dialog_view/:chatUserId", {
        templateUrl: "redirectPage.html",
        controller: "StrictedDialogRouteController"
    });
    $routeProvider.when("/access_deny", {
        templateUrl: "accessDeny.html",
        controller: "AccessDeny"
    });

    $routeProvider.when("/consultation_view/:consultationId", {
        templateUrl: "consultationTemplate.html",
        controller: "ConsultationController"
    });



    $routeProvider.otherwise({ redirectTo: '/' });
    console.log("scope test");

});

springChatControllers.controller('TeachersListRouteController', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('TeachersListRouteController', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //  while (!chatControllerScope.$rootScope.isInited);//chatControllerScope.initStompClient();
    //  typeof chatControllerScope.socketSupport!=='undefined'
    chatControllerScope.goToTeachersList();
    $scope.pageClass = 'page-contact';
}]);


springChatControllers.controller('AccessDeny', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('AccessDeny', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //maybe add button
}]);

springChatControllers.controller('StrictedDialogRouteController', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('StrictedDialogRouteController', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //if($rootScope.isInited == true)
    chatControllerScope.goToPrivateDialog($routeParams.chatUserId);

}]);


var chatController = springChatControllers.controller('ChatController', ['$q', '$rootScope', '$scope', '$http', '$route', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($q, $rootScope, $scope, $http, $route, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('ChatController', $scope);
    $rootScope.isInited = false;
    $rootScope.baseurl = globalConfig["baseUrl"];
    $rootScope.goToUserPage = function(username) {
        var request = $http({
            method: "get",
            url: serverPrefix + "/get_id_by_username?intitaUsername=" + username,
            data: null,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        request.success(function(data) {
            if (data != null) {
                window.open(generateUrlToUserPage(data), '_blank');
                //window.top.location.href =generateUrlToUserPage(data);
                return true;
            }
        });
        return false;
    }

    $scope.toggleNewRoomModal = function() {
        $('#new_room_modal').modal('toggle');
    };

    $scope.addDialog = function() {};
    $rootScope.formatDateWithLast = formatDateWithLast;
    $rootScope.formatDate = formatDate;

    function generateUrlToUserPage(user_id) {
        var baseurl = globalConfig["baseUrl"];
        return baseurl + "/profile/" + user_id + "/";
    }

    function generateUrlToCourse(course_alias, lang) {
        var baseurl = globalConfig["baseUrl"];
        return baseurl + "/course/" + lang + "/" + course_alias + "/";
    }
    $rootScope.goToCourseByTitle = function(title, lang) {
        var request = $http({
            method: "get",
            url: serverPrefix + "/get_course_alias_by_title?title=" + encodeURIComponent(title) + "&lang=" + encodeURIComponent(lang),
            data: null,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        request.success(function(data) {
            if (data != null) {
                window.open(generateUrlToCourse(data, lang), '_blank');
                //window.top.location.href =generateUrlToCourse(data,lang);
                return true;
            }
        });

    }<commit_msg>feature: when open createDialogWindow (in dialogs list), you can close it by pressing escape<commit_after>'use strict';



/* Controllers */
var springChatControllers = angular.module('springChat.controllers', ['monospaced.elastic', 'ui.bootstrap', 'infinite-scroll', 'toaster', 'ngRoute', 'ngAnimate', 'ngResource', 'ngCookies', 'ngSanitize']);
springChatControllers.config(function($routeProvider) {
    $routeProvider.when("/chatrooms", {
        templateUrl: "dialogsTemplate.html",
        controller: "DialogsRouteController"
    });
    $routeProvider.when("/dialog_view/:roomId/", {
        templateUrl: "chatTemplate.html",
        controller: "ChatRouteController"
    });
    $routeProvider.when("/teachers_list", {
        templateUrl: "teachersTemplate.html",
        controller: "TeachersListRouteController"
    });
    $routeProvider.when("/private_dialog_view/:chatUserId", {
        templateUrl: "redirectPage.html",
        controller: "StrictedDialogRouteController"
    });
    $routeProvider.when("/access_deny", {
        templateUrl: "accessDeny.html",
        controller: "AccessDeny"
    });

    $routeProvider.when("/consultation_view/:consultationId", {
        templateUrl: "consultationTemplate.html",
        controller: "ConsultationController"
    });



    $routeProvider.otherwise({ redirectTo: '/' });
    console.log("scope test");

});

springChatControllers.controller('TeachersListRouteController', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('TeachersListRouteController', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //  while (!chatControllerScope.$rootScope.isInited);//chatControllerScope.initStompClient();
    //  typeof chatControllerScope.socketSupport!=='undefined'
    chatControllerScope.goToTeachersList();
    $scope.pageClass = 'page-contact';
}]);


springChatControllers.controller('AccessDeny', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('AccessDeny', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //maybe add button
}]);

springChatControllers.controller('StrictedDialogRouteController', ['$routeParams', '$rootScope', '$scope', '$http', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($routeParams, $rootScope, $scope, $http, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('StrictedDialogRouteController', $scope);
    var chatControllerScope = Scopes.get('ChatController');
    //if($rootScope.isInited == true)
    chatControllerScope.goToPrivateDialog($routeParams.chatUserId);

}]);


var chatController = springChatControllers.controller('ChatController', ['$q', '$rootScope', '$scope', '$http', '$route', '$location', '$interval', '$cookies', '$timeout', 'toaster', 'ChatSocket', '$cookieStore', 'Scopes', function($q, $rootScope, $scope, $http, $route, $location, $interval, $cookies, $timeout, toaster, chatSocket, $cookieStore, Scopes) {
    Scopes.store('ChatController', $scope);
    $rootScope.isInited = false;
    $rootScope.baseurl = globalConfig["baseUrl"];
    $rootScope.goToUserPage = function(username) {
        var request = $http({
            method: "get",
            url: serverPrefix + "/get_id_by_username?intitaUsername=" + username,
            data: null,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        request.success(function(data) {
            if (data != null) {
                window.open(generateUrlToUserPage(data), '_blank');
                //window.top.location.href =generateUrlToUserPage(data);
                return true;
            }
        });
        return false;
    }
    
    $scope.toggleNewRoomModal = function() {
        $('#new_room_modal').modal('toggle');       
        
        $timeout.cancel($scope.setFocusToRoomNameInput); //888
        isCreateDialogWndVisible = !isCreateDialogWndVisible;
        
        $scope.setFocusToRoomNameInput = $timeout(function() {
        	 if (isCreateDialogWndVisible == true)
         	{
         		$('#roomNameInput').focus();
         	}
        },300);       
    };
    
    var isCreateDialogWndVisible = false;

    $scope.addDialog = function() {};
    $rootScope.formatDateWithLast = formatDateWithLast;
    $rootScope.formatDate = formatDate;

    function generateUrlToUserPage(user_id) {
        var baseurl = globalConfig["baseUrl"];
        return baseurl + "/profile/" + user_id + "/";
    }

    function generateUrlToCourse(course_alias, lang) {
        var baseurl = globalConfig["baseUrl"];
        return baseurl + "/course/" + lang + "/" + course_alias + "/";
    }
    $rootScope.goToCourseByTitle = function(title, lang) {
        var request = $http({
            method: "get",
            url: serverPrefix + "/get_course_alias_by_title?title=" + encodeURIComponent(title) + "&lang=" + encodeURIComponent(lang),
            data: null,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        request.success(function(data) {
            if (data != null) {
                window.open(generateUrlToCourse(data, lang), '_blank');
                //window.top.location.href =generateUrlToCourse(data,lang);
                return true;
            }
        });

    }
{'fraction_non_alphanumeric': 0.1601569466738006, 'fraction_numerical': 0.0005350454788657035, 'mean_word_length': 3.7062526227444397, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '4813325', 'n_tokens_mistral': 3232, 'n_tokens_neox': 3202, 'n_words': 577}