<commit_before>
function AddClass( e, className )
{
	if ( ! AddClass.Contains( e, className ) )
	{
		if ( "" == e.className )
		{
			e.className = className;
		}
		else
		{
			e.className += " " + className;
		}
	}
}

AddClass.Contains
=
function( e, className )
{
	//
	//	AddClass.Contains( { className="cls active" }, "active' );
	//
	//	var st = 10 - 6;
	//
	//	0123456789
	//	cls active
	//	01234

	var contains = false;
	var st = (e.className.length - className.length) - 1;

	if ( className == e.className )
	{
		contains = true;
	}
	else
	if ( 0 <= st )
	{
		if ( -1 != e.className.indexOf( " " + className + " " ) )
		{
			contains = true;
		}
		else
		if ( 0 == e.className.indexOf( className + " " ) )
		{
			contains = true;
		}
		else
		if ( st == e.className.indexOf( " " + className ) )
		{
			contains = true;
		}
	}
	return contains;
}<commit_msg>Added new RemoveClass function and packaged related style functions in a StyleClasses object. Old function names are still valid.<commit_after>
function AddClass( e, className )
{
	if ( ! AddClass.Contains( e, className ) )
	{
		if ( "" == e.className )
		{
			e.className = className;
		}
		else
		{
			e.className += " " + className;
		}
	}
}

AddClass.Contains
=
function( e, className )
{
	//
	//	AddClass.Contains( { className="cls active" }, "active' );
	//
	//	var st = 10 - 6;
	//
	//	0123456789
	//	cls active
	//	01234

	var contains = false;
	var st = (e.className.length - className.length) - 1;

	if ( className == e.className )
	{
		contains = true;
	}
	else
	if ( 0 <= st )
	{
		if ( -1 != e.className.indexOf( " " + className + " " ) )
		{
			contains = true;
		}
		else
		if ( 0 == e.className.indexOf( className + " " ) )
		{
			contains = true;
		}
		else
		if ( st == e.className.indexOf( " " + className ) )
		{
			contains = true;
		}
	}
	return contains;
}


StyleClasses = {
    //Append class if not already in classes list.
    AddClass: AddClass,  //body remains outside StyleClasses for backwards compatibility.
    
    // Check if class is in element's classes.
    ContainsClass:AddClass.Contains,
    
    //Remove a classname from an element's list of active styling classes.
    RemoveClass: function(e, className) {
        if ( className == e.className )
        {
            e.className='';
            return true;
        }
        var maxStart = (e.className.length - className.length) - 1;
        if ( 0 <= maxStart )
        {
            var start;
            
            start = e.className.indexOf( " " + className + " ");
            if ( -1 != start )
            {
                e.className = e.className.substring(0,start) + e.className.substring(start+1+className.length);
                return true;
            }
            
            start = e.className.indexOf( className + " " );
            if ( 0 == start)
            {
                e.className = e.className.substring(1+className.length);
                return true;
            }
            
            start = e.className.indexOf( " " + className );
            if ( maxStart == start  )
            {
                e.className = e.className.substring(0, start);
                return true;
            }
        }
        return false;
    }
};

{'fraction_non_alphanumeric': 0.1389317690645261, 'fraction_numerical': 0.01605433775856746, 'mean_word_length': 1.7858985382631127, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5030365', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1037, 'n_words': 250}