<commit_before>'use strict';

angular.module('todo.controllers', ['ngResource']);

angular.module('todo.controllers').controller('TodoCtrl', function ($scope, $resource, $http, $rootScope, $location) {

    $scope.loaded = false;

    $scope.todos = [];

    var Task = $resource("/tasks/:taskId", {taskId: '@id'}, {'update': {method: 'PUT'}});

    $scope.todos = Task.query(function() {
        $scope.loaded = true;
    });

    $scope.getTodosCount = function () {
        return $scope.todos.length;
    };

    $scope.addTodo = function() {
        var task = new Task({text: $scope.formTodoText, done: false});
        task.$save(function(saved) {
            $scope.todos.push(saved);
            $scope.formTodoText = "";
        });
    };

    $scope.getRemainingCount = function() {
        return $scope.getRemaining().length;
    };

    $scope.getRemaining = function () {
        return _.filter($scope.todos, function (todo) {
            return !todo.done;
        });
    };

    var getCompleted = function() {
        return _.filter($scope.todos, function (todo) {
            return todo.done;
        });
    };

    $scope.clearCompleted = function () {
        $http({
            method: 'DELETE',
            url: '/tasks/done'
        }).success(function (tasks) {
            $scope.todos = _.map(tasks, function(task) {
                return new Task(task);
            });
        });
    };

    $scope.update = function(task) {
        task.$update();
    };

    $scope.toggle = function(task) {
        task.done = !task.done;
        task.$update();
    };

    $scope.mute = function($event) {
        $event.stopPropagation();
    };

    $scope.logoff = function() {
        $http({
            method: 'DELETE',
            url: '/login'
        }).success(function () {
            $rootScope.login = {};
            $location.path("/landing");
        });
    };
});

angular.module('todo.controllers').controller('LandingCtrl', function ($rootScope, $scope, $http, $location) {

    $scope.formData = {};

    $scope.setUsername = function() {
        $http.post('/users/authenticate/userpass', $scope.formData).success(function (login) {
            $rootScope.login = login;
            $location.path("/tasks");
        });
    }
});

angular.module('todo.controllers').controller('SignupController', function ($scope, $http, $location) {

    $scope.formData = {};

    $scope.setEmail = function() {
        $http.post('/users/signup', $scope.formData).success(function () {
            $location.path("/landing");
        });
    }
});

angular.module('todo.controllers').controller('SignupVerifiedController', function ($scope, $http, $location, $routeParams) {

    $scope.formData = {};

    $scope.signUp = function() {
        $http.post('/users/signup/' + $routeParams.token, $scope.formData).success(function () {
            $location.path("/landing");
        });
    }
});<commit_msg>Signup details controller aware of validation errors.<commit_after>'use strict';

angular.module('todo.controllers', ['ngResource']);

angular.module('todo.controllers').controller('TodoCtrl', function ($scope, $resource, $http, $rootScope, $location) {

    $scope.loaded = false;

    $scope.todos = [];

    var Task = $resource("/tasks/:taskId", {taskId: '@id'}, {'update': {method: 'PUT'}});

    $scope.todos = Task.query(function () {
        $scope.loaded = true;
    });

    $scope.getTodosCount = function () {
        return $scope.todos.length;
    };

    $scope.addTodo = function () {
        var task = new Task({text: $scope.formTodoText, done: false});
        task.$save(function (saved) {
            $scope.todos.push(saved);
            $scope.formTodoText = "";
        });
    };

    $scope.getRemainingCount = function () {
        return $scope.getRemaining().length;
    };

    $scope.getRemaining = function () {
        return _.filter($scope.todos, function (todo) {
            return !todo.done;
        });
    };

    $scope.clearCompleted = function () {
        $http({
            method: 'DELETE',
            url: '/tasks/done'
        }).success(function (tasks) {
            $scope.todos = _.map(tasks, function (task) {
                return new Task(task);
            });
        });
    };

    $scope.update = function (task) {
        task.$update();
    };

    $scope.toggle = function (task) {
        task.done = !task.done;
        task.$update();
    };

    $scope.mute = function ($event) {
        $event.stopPropagation();
    };

    $scope.logoff = function () {
        $http({
            method: 'DELETE',
            url: '/login'
        }).success(function () {
            $rootScope.login = {};
            $location.path("/landing");
        });
    };
});

angular.module('todo.controllers').controller('LandingCtrl', function ($rootScope, $scope, $http, $location) {

    $scope.formData = {};

    $scope.setUsername = function () {
        $http.post('/users/authenticate/userpass', $scope.formData).success(function (login) {
            $rootScope.login = login;
            $location.path("/tasks");
        });
    }
});

angular.module('todo.controllers').controller('SignupController', function ($scope, $http, $location) {

    $scope.formData = {};

    $scope.setEmail = function () {
        $http.post('/users/signup', $scope.formData).success(function () {
            $location.path("/landing");
        });
    }
});

angular.module('todo.controllers').controller('SignupVerifiedController', function ($scope, $http, $location, $routeParams) {

    $scope.formData = {};

    $scope.signUp = function () {
        $http.post('/users/signup/' + $routeParams.token, $scope.formData)
            .success(function () {
                $location.path("/landing");
            }).error(function (response) {
                $scope.formData.errors = response;

                if (response["password"]) {
                    $scope.formData.errors["password.<PASSWORD>"] = response["password"];
                }
            });
    }
});
{'fraction_non_alphanumeric': 0.1796308503625577, 'fraction_numerical': 0.0, 'mean_word_length': 2.2196286472148543, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '7038103', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1789, 'n_words': 287}