<commit_before>;(function (define) {
    'use strict';
    define([
            'jquery',
            'underscore',
            'backbone',
            'common/js/utils/edx.utils.validate'
        ],
        function($, _, Backbone, EdxUtilsValidate) {

        return Backbone.View.extend({
            tagName: 'form',

            el: '',

            tpl: '',

            fieldTpl: '#form_field-tpl',

            events: {},

            errors: [],

            formType: '',

            $form: {},

            fields: [],

            // String to append to required label fields
            requiredStr: '*',

            submitButton: '',

            initialize: function( data ) {
                this.model = data.model;
                this.preRender( data );

                this.tpl = $(this.tpl).html();
                this.fieldTpl = $(this.fieldTpl).html();
                this.buildForm( data.fields );

                this.listenTo( this.model, 'error', this.saveError );
            },

            /* Allows extended views to add custom
             * init steps without needing to repeat
             * default init steps
             */
            preRender: function( data ) {
                /* Custom code goes here */
                return data;
            },

            render: function( html ) {
                var fields = html || '';

                $(this.el).html( _.template( this.tpl, {
                    fields: fields
                }));

                this.postRender();

                return this;
            },

            postRender: function() {
                var $container = $(this.el);
                this.$form = $container.find('form');
                this.$errors = $container.find('.submission-error');
                this.$submitButton = $container.find(this.submitButton);
                $('.text-city').hide();
                $('.select-country').hide();
                this.setUserCityAndCountry();
                this.showPassword();
            },

            setUserCityAndCountry: function() {
                $.get(
                   '/geo',
                   function(response) {
                      if(typeof response.country !== "undefined") {
                          $('#register-city').val(response.city);
                          $('#register-country').val(response.country);
                      }
                   }
                );
            },

            showPassword: function() {
                var password = $('#register-show_password');
                password.click(function() {
                    $('#register-password').get(0).type = (this.checked) ? 'text' : 'password';
                });
            },
<commit_msg>[#118026517] Suggest username from email<commit_after>;(function (define) {
    'use strict';
    define([
            'jquery',
            'underscore',
            'backbone',
            'common/js/utils/edx.utils.validate'
        ],
        function($, _, Backbone, EdxUtilsValidate) {

        return Backbone.View.extend({
            tagName: 'form',

            el: '',

            tpl: '',

            fieldTpl: '#form_field-tpl',

            events: {},

            errors: [],

            formType: '',

            $form: {},

            fields: [],

            // String to append to required label fields
            requiredStr: '*',

            submitButton: '',

            initialize: function( data ) {
                this.model = data.model;
                this.preRender( data );

                this.tpl = $(this.tpl).html();
                this.fieldTpl = $(this.fieldTpl).html();
                this.buildForm( data.fields );

                this.listenTo( this.model, 'error', this.saveError );
            },

            /* Allows extended views to add custom
             * init steps without needing to repeat
             * default init steps
             */
            preRender: function( data ) {
                /* Custom code goes here */
                return data;
            },

            render: function( html ) {
                var fields = html || '';

                $(this.el).html( _.template( this.tpl, {
                    fields: fields
                }));

                this.postRender();

                return this;
            },

            postRender: function() {
                var $container = $(this.el);
                this.$form = $container.find('form');
                this.$errors = $container.find('.submission-error');
                this.$submitButton = $container.find(this.submitButton);
                $('.text-city').hide();
                $('.select-country').hide();
                this.setUserCityAndCountry();
                this.showPassword();
                this.getUsernameFromEmail();
            },

            setUserCityAndCountry: function() {
                $.get(
                   '/geo',
                   function(response) {
                      if(typeof response.country !== "undefined") {
                          $('#register-city').val(response.city);
                          $('#register-country').val(response.country);
                      }
                   }
                );
            },

            showPassword: function() {
                var password = <PASSWORD>');
                password.click(function() {
                    $('#register-password').get(0).type = (this.checked) ? 'text' : 'password';
                });
            },

            getUsernameFromEmail: function() {
                var email = $('#register-email');
                email.keyup(function() {
                    if (email.val().indexOf('@') === -1) {
                        $('#register-username').val(email.val().replace(".", ""));
                    }
                });
            },

{'fraction_non_alphanumeric': 0.13463497453310697, 'fraction_numerical': 0.0020373514431239388, 'mean_word_length': 1.1099570200573066, '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': '3946841', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1344, 'n_words': 263}