<commit_before>/*jshint -W097 */
'use strict';

var React = require('react');
var _ = require('lodash');

var LessonsColumn = React.createClass({
    getInitialState: function() {
        if (this.props.lessons) {
            return { lessons: _.clone(this.props.lessons).concat([ '' ]) };
        } else {
            return { lessons: [ '', '', '', '', '', '', '' ] };
        }
    },
    componentWillReceiveProps: function(nextProps) {
        if (nextProps.lessons) {
            this.setState({ lessons: _.clone(nextProps.lessons).concat([ '' ]) });
        }
    },
    addRow: function() {
        // this.state.lessons.push('');
        var lessons = this.state.lessons;
        lessons.push('');
        this.setState({ lessons: lessons });
    },
    handleFocus: function(index, e) {
        if (index === (this.state.lessons.length - 1)) {
            this.addRow();
        }
    },
    handleChange: function(index, e) {
        var lessons = this.state.lessons;
        lessons[index] = e.target.value.trim();
        this.setState({ lessons: lessons });
    },
    serialize: function() {
        /*jshint -W119*/
        var lessons = this.state.lessons.map(lesson => {
            /*jshint +W119*/
            if (lesson === '' || lesson === '-') return null;
            else return lesson;
        });
        // remove empty lessons from the end
        var lesson = lessons[lessons.length - 1];
        if (_.isNull(lesson)) {
            while (_.isNull(lesson)) {
                lesson = lessons.pop();
            }
            if (!_.isNull(lesson)) lessons.push(lesson);
        }
        return lessons;
    },
    render: function() {<commit_msg>admin: remove trimming on entry<commit_after>/*jshint -W097 */
'use strict';

var React = require('react');
var _ = require('lodash');

var LessonsColumn = React.createClass({
    getInitialState: function() {
        if (this.props.lessons) {
            return { lessons: _.clone(this.props.lessons).concat([ '' ]) };
        } else {
            return { lessons: [ '', '', '', '', '', '', '' ] };
        }
    },
    componentWillReceiveProps: function(nextProps) {
        if (nextProps.lessons) {
            this.setState({ lessons: _.clone(nextProps.lessons).concat([ '' ]) });
        }
    },
    addRow: function() {
        // this.state.lessons.push('');
        var lessons = this.state.lessons;
        lessons.push('');
        this.setState({ lessons: lessons });
    },
    handleFocus: function(index, e) {
        if (index === (this.state.lessons.length - 1)) {
            this.addRow();
        }
    },
    handleChange: function(index, e) {
        var lessons = this.state.lessons;
        lessons[index] = e.target.value;
        this.setState({ lessons: lessons });
    },
    serialize: function() {
        /*jshint -W119*/
        var lessons = this.state.lessons.map(lesson => {
            /*jshint +W119*/
            if (lesson === '' || lesson === '-') return null;
            else return lesson.trim();
        });
        // remove empty lessons from the end
        var lesson = lessons[lessons.length - 1];
        if (_.isNull(lesson)) {
            while (_.isNull(lesson)) {
                lesson = lessons.pop();
            }
            if (!_.isNull(lesson)) lessons.push(lesson);
        }
        return lessons;
    },
    render: function() {
{'fraction_non_alphanumeric': 0.16745702430349732, 'fraction_numerical': 0.006520450503852994, 'mean_word_length': 1.872340425531915, 'pattern_counts': {'":': 0, '<': 3, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4258490', 'n_tokens_mistral': 1005, 'n_tokens_neox': 992, 'n_words': 200}