<commit_before>(function( window, $, _ ) {

function MultipleSelect( container ) {
    _.bindAll( this, 'addSelect', 'selected' );

    var $container = $( container );

    this.$select = $container.clone()
            .removeAttr( "multiple" );

    this.maxSelections = this.$select.find( "option" ).length;
    this.selectionCount = 1;

    this.$addButton = $( '<span role="button" class="icon-button">' +
                         '  <i class="fa fa-plus-circle"></i>' +
                         '</span>' )
                         .click( this.addButtonClicked ); // TODO: One click handler per document

    this.$select.prepend( $( '<option default="default" selected="selected" value="">...</option>' ) );

    $container.replaceWith( this.newSelect().add( this.$addButton ) );
}

MultipleSelect.prototype.newSelect = function() {
    var result = this.$select.clone();
    result.attr('id', result.attr('id') + "_" + this.selectionCount++);

    result.on('change', this.selected);
    return result;
};

MultipleSelect.prototype.addSelect = function( event ) {
    this.newSelect().insertBefore( this.$addButton );
    if ( this.selectionCount > this.maxSelections ) {
        this.$addButton.hide();
        this.addSelect = function() {};
    }
};

MultipleSelect.prototype.selected = function( event ) {
    $( event.target ).unbind('change');
    this.addSelect();
};


window.MultipleSelect = MultipleSelect;

}( window, $, _ ));<commit_msg>new select on change only if no other unselected<commit_after>(function( window, $ ) {

function MultipleSelect( originalSelect ) {

    var $originalSelect = $( originalSelect );

    this.$select = $originalSelect.clone()
            .removeAttr( "multiple" )
            .attr('data-group-id', MultipleSelect.groupSelectCount++);

    this.maxSelections = this.$select.find( "option" ).length;
    this.selectionCount = 1;

    this.$addButton = $( '<span role="button" class="icon-button">' +
                         '  <i class="fa fa-plus-circle"></i>' +
                         '</span>' )
                         .click( this.addSelect.bind( this ) );

    this.$select.prepend( $( '<option default="default" selected="selected" value="">...</option>' ) );

    $originalSelect.replaceWith( this.newSelect().add( this.$addButton ) );
}

MultipleSelect.groupSelectCount = 0;

MultipleSelect.prototype.newSelect = function() {
    var $result = this.$select.clone();

    $result.attr( 'id', $result.attr('id') + "_" + this.selectionCount++ );
    $result.on( 'change', this.selected.bind( this ) );

    return $result;
};

MultipleSelect.prototype.addSelect = function( event ) {
    this.newSelect().insertBefore( this.$addButton );
    if ( this.selectionCount > this.maxSelections ) {
        this.$addButton.hide();
        this.addSelect = function() {};
    }
};

MultipleSelect.prototype.selected = function( event ) {
    var $target = $( event.target ),
        $group = $( 'select[data-group-id="' + $target.data('group-id') + '"]' );

    if ( $target.find( 'option[value!=""]:selected' ).length ) {
        $target.unbind( 'change' );
    }

    if ( $group.find( 'option[value!=""]:selected' ).length < $group.length ) {
        return;
    }

    this.addSelect();
};


window.MultipleSelect = MultipleSelect;

}( window, $ ));
{'fraction_non_alphanumeric': 0.1782477341389728, 'fraction_numerical': 0.0009063444108761329, 'mean_word_length': 2.8679906542056073, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 17, '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': '6604874', 'n_tokens_mistral': 991, 'n_tokens_neox': 949, 'n_words': 178}