<commit_before>App.TimeNeededList = [
    {value: 0.25, title: gettext("15 minutes")},
    {value: 0.5, title: gettext("half an hour")},
    {value: 1, title: gettext("up to one hour")},
    {value: 2, title: gettext("two hours")},
    {value: 4, title: gettext("half a day")},
    {value: 8, title: gettext("one day")},
    {value: 16, title: gettext("two days")},
    {value: 40, title: gettext("one week")},
    {value: 80, title: gettext("two weeks")},
    {value: 160, title: gettext("one month")}

];

App.TimeNeededSelectView = Em.Select.extend({
    content: App.TimeNeededList,
    optionValuePath: "content.value",
    optionLabelPath: "content.title"
});


App.IsAuthorMixin = Em.Mixin.create({
    isAuthor: function () {
        var username = this.get('currentUser.username');
        var authorname = this.get('author.username');
        if (username) {
            return (username == authorname);
        }
        return false;
    }.property('author.username', 'currentUser.username')
});

// It Provides different validations
// standart empty fields validation (_requiredFieldsChecker and blockingErrors)
// validation based on fields errors (validateErrors, enabled by calling enableValidation)
// for examples (go to bb_accounts/controllers.js
App.ControllerValidationMixin = Ember.Mixin.create({

    fixedFieldsMessage: gettext('That\'s better'),

    // In your controller define fieldsToWatch (a list of fields you want to watch)
    // you will be able to use then: errorsFixed and blockSubmit
    // errorsFixed: true if there were errors which are now fixed
    errorsFixed: false,

    // blockErrors: true if there are still blocking errors which prevent to submit
    blockingErrors: true,

    // to prevent the error validation we set validationEnabled to false
    // set to true to enable it
    validationEnabled: false,

    // used in validateErrors function
    errorDictionaryFields: ['property', 'validateProperty', 'message', 'priority'],

    // set validationEnable to true, this has to be called from the controller to enable the validation
    // I use it since we want to be in control when to start the validation, for example just after
    // pressing a submit button
    enableValidation: function() {
        this.set('validationEnabled', true)
    },

    // set the strength of the field, use this in the template
    fieldStrength: function(field) {

        var specialChar = (/(?=.*[!@#$%^&*])/)
        var upperAndLowerChar = (/(?=.*[A-Z])(?=.*[a-z])/)
        var numberChar = (/(?=.*[0-9])/)

        // field not fulfilled
        if (!field){
            return ""
        }

        if (field.length < 6 ){
            return gettext("weak");
        }

        var strength = 0;

        if (field.search(upperAndLowerChar) == 0) {
            strength += 1;
        }

        if (field.search(numberChar) == 0) {
            strength += 1;
        }

        if (field.search(specialChar) == 0) {
            strength += 1;
        }

        if (strength == 1) {
            return gettext("fair");
        }

        if (strength == 2) {
            return gettext("strong");
        }

        return gettext("weak")
    },

    _apiErrors: function(errors) {
        // we just show one error at the time
        var firstError = Em.Object.create();
        var resultErrors = Em.Object.create(errors);<commit_msg>added another fair state<commit_after>App.TimeNeededList = [
    {value: 0.25, title: gettext("15 minutes")},
    {value: 0.5, title: gettext("half an hour")},
    {value: 1, title: gettext("up to one hour")},
    {value: 2, title: gettext("two hours")},
    {value: 4, title: gettext("half a day")},
    {value: 8, title: gettext("one day")},
    {value: 16, title: gettext("two days")},
    {value: 40, title: gettext("one week")},
    {value: 80, title: gettext("two weeks")},
    {value: 160, title: gettext("one month")}

];

App.TimeNeededSelectView = Em.Select.extend({
    content: App.TimeNeededList,
    optionValuePath: "content.value",
    optionLabelPath: "content.title"
});


App.IsAuthorMixin = Em.Mixin.create({
    isAuthor: function () {
        var username = this.get('currentUser.username');
        var authorname = this.get('author.username');
        if (username) {
            return (username == authorname);
        }
        return false;
    }.property('author.username', 'currentUser.username')
});

// It Provides different validations
// standart empty fields validation (_requiredFieldsChecker and blockingErrors)
// validation based on fields errors (validateErrors, enabled by calling enableValidation)
// for examples (go to bb_accounts/controllers.js
App.ControllerValidationMixin = Ember.Mixin.create({

    fixedFieldsMessage: gettext('That\'s better'),

    // In your controller define fieldsToWatch (a list of fields you want to watch)
    // you will be able to use then: errorsFixed and blockSubmit
    // errorsFixed: true if there were errors which are now fixed
    errorsFixed: false,

    // blockErrors: true if there are still blocking errors which prevent to submit
    blockingErrors: true,

    // to prevent the error validation we set validationEnabled to false
    // set to true to enable it
    validationEnabled: false,

    // used in validateErrors function
    errorDictionaryFields: ['property', 'validateProperty', 'message', 'priority'],

    // set validationEnable to true, this has to be called from the controller to enable the validation
    // I use it since we want to be in control when to start the validation, for example just after
    // pressing a submit button
    enableValidation: function() {
        this.set('validationEnabled', true)
    },

    // set the strength of the field, use this in the template
    fieldStrength: function(field) {

        var specialChar = (/(?=.*[!@#$%^&*])/)
        var upperAndLowerChar = (/(?=.*[A-Z])(?=.*[a-z])/)
        var numberChar = (/(?=.*[0-9])/)

        // field not fulfilled
        if (!field){
            return ""
        }

        if (field.length < 6 ){
            return gettext("weak");
        }

        var strength = 0;

        if (field.search(upperAndLowerChar) == 0) {
            strength += 1;
        }

        if (field.search(numberChar) == 0) {
            strength += 1;
        }

        if (field.search(specialChar) == 0) {
            strength += 1;
        }

        if (strength = 0) {
            return gettext("fair");
        }

        if (strength == 1) {
            return gettext("fair");
        }

        if (strength == 2) {
            return gettext("strong");
        }

        return gettext("weak")
    },

    _apiErrors: function(errors) {
        // we just show one error at the time
        var firstError = Em.Object.create();
        var resultErrors = Em.Object.create(errors);
{'fraction_non_alphanumeric': 0.1294460641399417, 'fraction_numerical': 0.009475218658892129, 'mean_word_length': 2.5275064267352185, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6638870', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1921, 'n_words': 627}