<commit_before>;
define(['epl/Settings', 'lib/knockout', 'lib/knockout.validation'], function (Settings, ko) {

return (function () {
    /**
    * Creates the ViewModel to back the Create Account screen.
    * @return void
    */
    var CreateAccountViewModel = function () {
        var self = this;

        // Load the ReCaptcha Library
        $.getScript("http://www.google.com/recaptcha/api/js/recaptcha_ajax.js")
        .done(function(script, textStatus) {
            Recaptcha.create("6LeKB94SAAAAAJobmSzc9kLGeGizn8VWjbiKDJ9p", 
            "recaptcha-section",
            {
            theme: "red"
            });
        });
        
        // Set up an empty account and login
        self.account = new Account();
        self.login = new Login();
        // Add knockout validation to the account
        ko.validation.configure({ insertMessages: false });
        self.account.errors = ko.validation.group(self.account);
        self.login.errors = ko.validation.group(self.login);

        // On submit, validate and save the account
        self.createAccountSubmit = function () {
            if (!self.account.isValid()) {
                self.account.errors.showAllMessages();
                return false;
            }

            // Disable the submit button to prevent resubmission
            $('#createAccountSubmit').attr('disabled', true);

            // Append the ReCaptcha Information
            self.account.recaptcha_challenge = $("#recaptcha-section #recaptcha_challenge_field").val();
            self.account.recaptcha_response = $("#recaptcha-section #recaptcha_response_field").val();
            // Create the account
            $.ajax(Settings.apiAccountUrl + "create", {
                data: ko.toJSON(self.account),
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                success: function () {
                    top.location="#createAccountSuccess";
                    top.location.reload(true);
                }, 
                error: function (xhr) {
                     $('#createAccountSubmit').attr('disabled', false);
                    // Response code 409 indicates duplicate user.
                    if (xhr.status == 409) {
                        $("#ajaxErrorCreateAccount").text("Username is already taken. Please choose another username.");
                    } else if(xhr.status == 410) {
                        $("#ajaxErrorCreateAccount").text("Email is already in use. Please choose another email."); 
                    } else if(xhr.status == 401){
                        $("#ajaxErrorCreateAccount").text("Captcha incorrect, please try again.");
                    } else {
                        $("#ajaxErrorCreateAccount").text("An error occurred while creating a new user." +<commit_msg>login test<commit_after>;
define(['epl/Settings', 'lib/knockout', 'lib/knockout.validation'], function (Settings, ko) {

return (function () {
    /**
    * Creates the ViewModel to back the Create Account screen.
    * @return void
    */
    var CreateAccountViewModel = function () {
        var self = this;

        self.createRecaptchaSection = function() {
            Recaptcha.create("<KEY>", 
            "recaptcha-section",
            {
            theme: "red"
            });
        }

        // Load the ReCaptcha Library
        $.getScript("http://www.google.com/recaptcha/api/js/recaptcha_ajax.js")
        .done(function(script, textStatus) {
            self.createRecaptchaSection();
        });
        
        // Set up an empty account and login
        self.account = new Account();
        self.login = new Login();
        // Add knockout validation to the account
        ko.validation.configure({ insertMessages: false });
        self.account.errors = ko.validation.group(self.account);
        self.login.errors = ko.validation.group(self.login);

        // On submit, validate and save the account
        self.createAccountSubmit = function () {
            if (!self.account.isValid()) {
                self.account.errors.showAllMessages();
                return false;
            }

            // Disable the submit button to prevent resubmission
            $('#createAccountSubmit').attr('disabled', true);

            // Append the ReCaptcha Information
            self.account.recaptcha_challenge = $("#recaptcha-section #recaptcha_challenge_field").val();
            self.account.recaptcha_response = $("#recaptcha-section #recaptcha_response_field").val();
            // Create the account
            $.ajax(Settings.apiAccountUrl + "create", {
                data: ko.toJSON(self.account),
                type: "POST",
                dataType: "json",
                contentType: "application/json",
                success: function () {
                    top.location="#createAccountSuccess";
                    top.location.reload(true);
                }, 
                error: function (xhr) {
                    self.createRecaptchaSection();
                     $('#createAccountSubmit').attr('disabled', false);
                    // Response code 409 indicates duplicate user.
                    if (xhr.status == 409) {
                        $("#ajaxErrorCreateAccount").text("Username is already taken. Please choose another username.");
                    } else if(xhr.status == 410) {
                        $("#ajaxErrorCreateAccount").text("Email is already in use. Please choose another email."); 
                    } else if(xhr.status == 401){
                        $("#ajaxErrorCreateAccount").text("Captcha incorrect, please try again.");
                    } else {
                        $("#ajaxErrorCreateAccount").text("An error occurred while creating a new user." +
{'fraction_non_alphanumeric': 0.11942347288949898, 'fraction_numerical': 0.005147563486616335, 'mean_word_length': 1.7743931461208948, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '6603406', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1385, 'n_words': 333}