<commit_before>
function addValue( theSel, theText, theValue ) {
    var newOpt = new Option( theText, theValue );
    var selLength = theSel.length;
    jQuery(newOpt).prop('selected', true);
    theSel.options[ selLength ] = newOpt;
}

function deleteValue( theSel, theIndex ) {
    var selLength = theSel.length;
    if(selLength>0) {
        theSel.options[ theIndex ] = null;
    }
}

/**
 * Moves selected options in the source list to the target list.
 * 
 * @param fromListId the id of the source list.
 * @param targetListId the id of the target list.
 */
function moveSelectedById( fromListId, targetListId ) {
    var fromList = document.getElementById( fromListId );
    var targetList = document.getElementById( targetListId );
    moveSelected( fromList, targetList );
}

/**
 * Moves selected options in the source list to the target list.
 * 
 * @param fromList the source list.
 * @param targetList the target list.
 */
function moveSelected( fromList, targetList ) {

    if ( fromList.selectedIndex == -1 ) {
        return;
    }
    else {
        var selLength = fromList.length;
        var selectedText = new Array();
        var selectedValues = new Array();
        var selectedCount = 0;
        var i;

        for(i=selLength-1; i>=0; i--) {
            if(fromList.options[i].selected) {
                selectedText[selectedCount] = fromList.options[i].text;
                selectedValues[selectedCount] = fromList.options[i].value;
                deleteValue(fromList, i);
                selectedCount++;
            }
        }

        for(i=selectedCount-1; i>=0; i--) {
            addValue(targetList, selectedText[i], selectedValues[i]);
        }
    }
}

/**
 * Moves all elements in a list to the target list
 * 
 * @param fromListId the id of the source list.
 * @param targetListId the id of target list.
 */
function moveAllById( fromListId, targetListId ) {
    $('#'+targetListId).append($('#'+fromListId+' >option'));
}

/**
 * Clears the list.
 * 
 * @param listId the id of the list.
 */
function clearListById( listId ) {
    $('#' + listId).children().remove();
}

/**
 * Clears the list.
 * 
 * @param list the list.
 */
function clearList( list ) {
	list.options.length = 0;
}

/**
 * Tests whether the list contains the value.
 * 
 * @param listId the id of the list.
 * @param value the value.
 */
function listContainsById( listId, value, text ) {
    var list = document.getElementById( listId );	
    return listContains( list, value, text);
}

/**
 * Tests whether the list contains the value.
 * 
 * @param list the list.
 * @param value the value.
 */
function listContains( list, value, text ) {
	if( text == undefined ) text = false;
    for ( var i = 0; i < list.options.length; i++ ) {
		if( text ){
			if ( list.options[i].text == value ) {
				return true;
			}
		}else{
			if ( list.options[i].value == value ) {
				return true;
			}
		}
        
    }
    return false;
}

/**
 * Marks all elements in a list as selected.
 * 
 * @param listId the id of the list.
 */
function selectAllById( listId ) {
    $('#' + listId).find('option').attr('selected', true);
}

/**
 * Marks all elements in a list as selected.
 * 
 * @param list the list.
 */
function selectAll( list ) {
    $(list).find('option').attr('selected', true);
}

/**
 * Marks all elements in a list as not selected.
 * 
 * @param listId the id of the list.
 */
function deselectAllById( listId ) {
    var list = document.getElementById( listId );
    deselectAll( list );
}
<commit_msg>Fix user role's authorities multi select bug.<commit_after>
function addValue( theSel, theText, theValue ) {
    var newOpt = new Option( theText, theValue );
    var selLength = theSel.length;
    jQuery(newOpt).prop('selected', true);
    theSel.options[ selLength ] = newOpt;
}

function deleteValue( theSel, theIndex ) {
    var selLength = theSel.length;
    if(selLength>0) {
        theSel.options[ theIndex ] = null;
    }
}

/**
 * Moves selected options in the source list to the target list.
 * 
 * @param fromListId the id of the source list.
 * @param targetListId the id of the target list.
 */
function moveSelectedById( fromListId, targetListId ) {
    var fromList = document.getElementById( fromListId );
    var targetList = document.getElementById( targetListId );
    moveSelected( fromList, targetList );
}

/**
 * Moves selected options in the source list to the target list.
 * 
 * @param fromList the source list.
 * @param targetList the target list.
 */
function moveSelected( fromList, targetList ) {

    if ( fromList.selectedIndex == -1 ) {
        return;
    }
    else {
        var selLength = fromList.length;
        var selectedText = new Array();
        var selectedValues = new Array();
        var selectedCount = 0;
        var i;

        for(i=selLength-1; i>=0; i--) {
            if(fromList.options[i].selected) {
                selectedText[selectedCount] = fromList.options[i].text;
                selectedValues[selectedCount] = fromList.options[i].value;
                deleteValue(fromList, i);
                selectedCount++;
            }
        }

        for(i=selectedCount-1; i>=0; i--) {
            addValue(targetList, selectedText[i], selectedValues[i]);
        }
    }
}

/**
 * Moves all elements in a list to the target list
 * 
 * @param fromListId the id of the source list.
 * @param targetListId the id of target list.
 */
function moveAllById( fromListId, targetListId ) {
    $('#'+targetListId).append($('#'+fromListId+' >option'));
}

/**
 * Clears the list.
 * 
 * @param listId the id of the list.
 */
function clearListById( listId ) {
    $('#' + listId).children().remove();
}

/**
 * Clears the list.
 * 
 * @param list the list.
 */
function clearList( list ) {
	list.options.length = 0;
}

/**
 * Tests whether the list contains the value.
 * 
 * @param listId the id of the list.
 * @param value the value.
 */
function listContainsById( listId, value, text ) {
    var list = document.getElementById( listId );	
    return listContains( list, value, text);
}

/**
 * Tests whether the list contains the value.
 * 
 * @param list the list.
 * @param value the value.
 */
function listContains( list, value, text ) {
	if( text == undefined ) text = false;
    for ( var i = 0; i < list.options.length; i++ ) {
		if( text ){
			if ( list.options[i].text == value ) {
				return true;
			}
		}else{
			if ( list.options[i].value == value ) {
				return true;
			}
		}
        
    }
    return false;
}

/**
 * Marks all elements in a list as selected.
 * 
 * @param listId the id of the list.
 */
function selectAllById( listId ) {
    $('#' + listId).find('option').prop('selected', true);
}

/**
 * Marks all elements in a list as selected.
 * 
 * @param list the list.
 */
function selectAll( list ) {
    $(list).find('option').prop('selected', true);
}

/**
 * Marks all elements in a list as not selected.
 * 
 * @param listId the id of the list.
 */
function deselectAllById( listId ) {
    var list = document.getElementById( listId );
    deselectAll( list );
}

{'fraction_non_alphanumeric': 0.13071710897797853, 'fraction_numerical': 0.002540937323546019, 'mean_word_length': 2.644547325102881, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5532846', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2157, 'n_words': 674}