<commit_before>﻿angular.module('crypteron.register', [
    'ui.router',
    'reg'
]).config(function ($stateProvider) {
    $stateProvider.state('register', {
        url: '/register',
        views: {
            "main": {
                controller: 'RegisterCtrl',
                templateUrl: 'register/register.tpl.html'
            }
        },
        data: {
            pageTitle: 'Register',
            hideNav: true,
            bodyClass: 'register',
            public: true
        }
    });
})
.controller('RegisterCtrl', function ($scope, reg, $state, userProfile) {

    // Initialize scope variables
    $scope.registerData = {
        UserName: "",
        Email: "",
        Password: "",
        ConfirmPassword: "",
        FirstName: "",
        LastName: "",
        Gender: "",
        DOB: "",
        Specialty: "",
        isSubmitting: true
    };

    // Register method
    $scope.register = function () {
        $scope.registerData.isSubmitting = true;

        $scope.registerData.DOB = $scope.SelectedYear + '-' + pad($scope.SelectedMonth, 2) + '-' + pad($scope.SelectedDay, 2);
        reg.register($scope.registerData)
        .then(function (response) {
            // After registration, send them to login page
            $state.go('login');
        },
        function (err) {
            $scope.registerData.isSubmitting = false; // re-enable submit button
        });
    };

    //Date of Birth dropdown menu value generator
    var numberOfYears = (new Date()).getYear();
    var years = $.map($(Array(numberOfYears)), function (val, i) { return i + 1900; });
    var months = $.map($(Array(12)), function (val, i) { return i + 1; });
    var days = $.map($(Array(31)), function (val, i) { return i + 1; });

    var isLeapYear = function () {
        var year = $scope.SelectedYear || 0;
        return ((year % 400 === 0 || year % 100 !== 0) && (year % 4 === 0)) ? 1 : 0;
    };

    var getNumberOfDaysInMonth = function () {
        var selectedMonth = $scope.SelectedMonth || 0;
        return 31 - ((selectedMonth === 2) ? (3 - isLeapYear()) : ((selectedMonth - 1) % 7 % 2));
    };

    $scope.UpdateNumberOfDays = function () {
        $scope.NumberOfDays = getNumberOfDaysInMonth();
    };
    $scope.NumberOfDays = 31;
    $scope.Years = years;
    $scope.Days = days;
    $scope.Months = months;

    $scope.Username_Valid_length = true;
    $scope.Username_Valid_symbol = true;

    $scope.check_username_symbol = function () {

        if (document.getElementById("register-username").value.match(/[^0-9a-zA-Z]/) != null) {
            $scope.Username_Valid_symbol = false;
        }
        else {
            $scope.Username_Valid_symbol = true;
        }
    };

    $scope.check_username_length = function () {
        if (document.getElementById("register-username").value.length < 3 || document.getElementById("register-username").value.length > 20) {
            $scope.Username_Valid_length = false;
        }
        else {
            $scope.Username_Valid_length = true;
        }
    };

    $scope.Password_Valid = true;
    $scope.Password_Short = false;
    $scope.Password_Digit = true;
    $scope.Password_Upper = true;
    $scope.Password_Special = true;

    $scope.pw_pattern = "/^(?=*\d)(?=*[A-Z])(?=*[^A-Za-z0-9]){6,}$/";
    $scope.check_password = function () {
        if (document.getElementById("user-password").value.length < 6) {
            $scope.Password_Short = true;
        } else {
            $scope.Password_Short = false;
        }
        if (document.getElementById("user-password").value.match(/[0-9]/) == null) {
            $scope.Password_Digit = false;
        } else {
            $scope.Password_Digit = true;
        }
        if (document.getElementById("user-password").value.match(/[A-Z]/) == null) {
            $scope.Password_Upper = false;
        } else {
            $scope.Password_Upper = true;
        }<commit_msg>Fixed bug with error logging in.<commit_after>﻿angular.module('crypteron.register', [
    'ui.router',
    'reg'
]).config(function ($stateProvider) {
    $stateProvider.state('register', {
        url: '/register',
        views: {
            "main": {
                controller: 'RegisterCtrl',
                templateUrl: 'register/register.tpl.html'
            }
        },
        data: {
            pageTitle: 'Register',
            hideNav: true,
            bodyClass: 'register',
            public: true
        }
    });
})
.controller('RegisterCtrl', function ($scope, reg, $state, userProfile) {

    // Initialize scope variables
    $scope.registerData = {
        UserName: "",
        Email: "",
        Password: "",
        ConfirmPassword: "",
        FirstName: "",
        LastName: "",
        Gender: "",
        DOB: "",
        Specialty: "",
        isSubmitting: true
    };

    // Register method
    $scope.register = function () {
        $scope.registerData.isSubmitting = true;

        $scope.registerData.DOB = $scope.SelectedYear + '-' + pad($scope.SelectedMonth, 2) + '-' + pad($scope.SelectedDay, 2);
        reg.register($scope.registerData)
        .then(function (response) {
            // After registration, send them to login page
            $state.go('login');
        },
        function (err) {
            $scope.registerData.isSubmitting = false; // re-enable submit button
        });
    };

    //Date of Birth dropdown menu value generator
    var numberOfYears = (new Date()).getYear();
    var years = $.map($(Array(numberOfYears)), function (val, i) { return i + 1900; });
    var months = $.map($(Array(12)), function (val, i) { return i + 1; });
    var days = $.map($(Array(31)), function (val, i) { return i + 1; });

    var isLeapYear = function () {
        var year = $scope.SelectedYear || 0;
        return ((year % 400 === 0 || year % 100 !== 0) && (year % 4 === 0)) ? 1 : 0;
    };

    var getNumberOfDaysInMonth = function () {
        var selectedMonth = $scope.SelectedMonth || 0;
        return 31 - ((selectedMonth === 2) ? (3 - isLeapYear()) : ((selectedMonth - 1) % 7 % 2));
    };

    $scope.UpdateNumberOfDays = function () {
        $scope.NumberOfDays = getNumberOfDaysInMonth();
    };
    $scope.NumberOfDays = 31;
    $scope.Years = years;
    $scope.Days = days;
    $scope.Months = months;

    $scope.Username_Valid_length = true;
    $scope.Username_Valid_symbol = true;

    $scope.check_username_symbol = function () {

        if (document.getElementById("register-username").value.match(/[^0-9a-zA-Z]/) != null) {
            $scope.Username_Valid_symbol = false;
        }
        else {
            $scope.Username_Valid_symbol = true;
        }
    };

    $scope.check_username_length = function () {
        if (document.getElementById("register-username").value.length < 3 || document.getElementById("register-username").value.length > 20) {
            $scope.Username_Valid_length = false;
        }
        else {
            $scope.Username_Valid_length = true;
        }
    };

    $scope.Password_Valid = true;
    $scope.Password_Short = false;
    $scope.Password_Digit = true;
    $scope.Password_Upper = true;
    $scope.Password_Special = true;

    $scope.pw_pattern = "/^(?=*[0-9])(?=*[A-Z])(?=*[^A-Za-z0-9]){6,}$/";
    $scope.check_password = function () {
        if (document.getElementById("user-password").value.length < 6) {
            $scope.Password_Short = true;
        } else {
            $scope.Password_Short = false;
        }
        if (document.getElementById("user-password").value.match(/[0-9]/) == null) {
            $scope.Password_Digit = false;
        } else {
            $scope.Password_Digit = true;
        }
        if (document.getElementById("user-password").value.match(/[A-Z]/) == null) {
            $scope.Password_Upper = false;
        } else {
            $scope.Password_Upper = true;
        }
{'fraction_non_alphanumeric': 0.1579680770205219, 'fraction_numerical': 0.011907778059285534, 'mean_word_length': 2.1021611001964637, 'pattern_counts': {'":': 2, '<': 7, '<?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': '6691787', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2314, 'n_words': 453}