<commit_before>/**
 * @author mrdoob / http://mrdoob.com/
 */

var Editor = function () {

	var Signal = signals.Signal;

	this.signals = {

		editorCleared: new Signal(),

		// libraries

		libraryAdded: new Signal(),

		// includes

		includeAdded: new Signal(),
		includeSelected: new Signal(),
		includeChanged: new Signal(),
		includeRemoved: new Signal(),
		includesCleared: new Signal(),

		// effects

		effectRenamed: new Signal(),
		effectRemoved: new Signal(),
		effectSelected: new Signal(),
		effectCompiled: new Signal(),

		// actions

		fullscreen: new Signal(),
		exportState: new Signal(),

		// animations

		animationRenamed: new Signal(),
		animationAdded: new Signal(),
		animationModified: new Signal(),
		animationRemoved: new Signal(),
		animationSelected: new Signal(),

		// curves

		curveAdded: new Signal(),

		// events

		playingChanged: new Signal(),
		playbackRateChanged: new Signal(),
		timeChanged: new Signal(),
		timelineScaled: new Signal(),

		windowResized: new Signal()

	};

	this.config = new Config( 'framejs-editor' );

	this.player = new FRAME.Player();
	this.duration = 500;

	this.libraries = [];
	this.includes = [];
	this.effects = [];
	this.timeline = new FRAME.Timeline();

	this.selected = null;

	// signals

	var scope = this;

	this.signals.animationModified.add( function () {

		scope.timeline.reset();
		scope.timeline.sort();
		scope.timeline.update( scope.player.currentTime );

	} );

	this.signals.effectCompiled.add( function () {

		scope.timeline.update( scope.player.currentTime );

	} );

	this.signals.timeChanged.add( function () {

		scope.timeline.update( scope.player.currentTime );

	} );

	// Animate

	var prevTime = 0;

	function animate( time ) {

		scope.player.tick( time - prevTime );

		if ( scope.player.isPlaying ) {

			scope.signals.timeChanged.dispatch( scope.player.currentTime );

		}

		prevTime = time;

		requestAnimationFrame( animate );

	}

	requestAnimationFrame( animate );

};

Editor.prototype = {

	play: function () {

		this.player.play();
		this.signals.playingChanged.dispatch( true );

	},

	stop: function () {

		this.player.pause();
		this.signals.playingChanged.dispatch( false );

	},

	speedUp: function () {

		this.player.playbackRate += 0.1;
		this.signals.playbackRateChanged.dispatch( this.player.playbackRate );

	},

	speedDown: function () {

		this.player.playbackRate -= 0.1;
		this.signals.playbackRateChanged.dispatch( this.player.playbackRate );

	},

	setTime: function ( time ) {

		// location.hash = time;

		this.player.currentTime = Math.max( 0, time );
		this.signals.timeChanged.dispatch( this.player.currentTime );

	},

	// libraries

	addLibrary: function ( url, content ) {

		var script = document.createElement( 'script' );
		script.id = 'library-' + this.libraries.length;
		script.textContent = content;
		document.head.appendChild( script );

		this.libraries.push( url );
		this.signals.libraryAdded.dispatch();

	},

	// includes

	addInclude: function ( name, source ) {

		var script = document.createElement( 'script' );
		script.id = 'include-' + this.includes.length;
		script.textContent = '( function () { ' + source + ' } )()';
		document.head.appendChild( script );

		this.includes.push( { name: name, source: source } );
		this.signals.includeAdded.dispatch();

	},

	selectInclude: function ( include ) {

		this.signals.includeSelected.dispatch( include );

	},

	reloadIncludes: function () {

		var includes = this.includes;<commit_msg>editor: Editor: Add missing removeInclude() function<commit_after>/**
 * @author mrdoob / http://mrdoob.com/
 */

var Editor = function () {

	var Signal = signals.Signal;

	this.signals = {

		editorCleared: new Signal(),

		// libraries

		libraryAdded: new Signal(),

		// includes

		includeAdded: new Signal(),
		includeSelected: new Signal(),
		includeChanged: new Signal(),
		includeRemoved: new Signal(),
		includesCleared: new Signal(),

		// effects

		effectRenamed: new Signal(),
		effectRemoved: new Signal(),
		effectSelected: new Signal(),
		effectCompiled: new Signal(),

		// actions

		fullscreen: new Signal(),
		exportState: new Signal(),

		// animations

		animationRenamed: new Signal(),
		animationAdded: new Signal(),
		animationModified: new Signal(),
		animationRemoved: new Signal(),
		animationSelected: new Signal(),

		// curves

		curveAdded: new Signal(),

		// events

		playingChanged: new Signal(),
		playbackRateChanged: new Signal(),
		timeChanged: new Signal(),
		timelineScaled: new Signal(),

		windowResized: new Signal()

	};

	this.config = new Config( 'framejs-editor' );

	this.player = new FRAME.Player();
	this.duration = 500;

	this.libraries = [];
	this.includes = [];
	this.effects = [];
	this.timeline = new FRAME.Timeline();

	this.selected = null;

	// signals

	var scope = this;

	this.signals.animationModified.add( function () {

		scope.timeline.reset();
		scope.timeline.sort();
		scope.timeline.update( scope.player.currentTime );

	} );

	this.signals.effectCompiled.add( function () {

		scope.timeline.update( scope.player.currentTime );

	} );

	this.signals.timeChanged.add( function () {

		scope.timeline.update( scope.player.currentTime );

	} );

	// Animate

	var prevTime = 0;

	function animate( time ) {

		scope.player.tick( time - prevTime );

		if ( scope.player.isPlaying ) {

			scope.signals.timeChanged.dispatch( scope.player.currentTime );

		}

		prevTime = time;

		requestAnimationFrame( animate );

	}

	requestAnimationFrame( animate );

};

Editor.prototype = {

	play: function () {

		this.player.play();
		this.signals.playingChanged.dispatch( true );

	},

	stop: function () {

		this.player.pause();
		this.signals.playingChanged.dispatch( false );

	},

	speedUp: function () {

		this.player.playbackRate += 0.1;
		this.signals.playbackRateChanged.dispatch( this.player.playbackRate );

	},

	speedDown: function () {

		this.player.playbackRate -= 0.1;
		this.signals.playbackRateChanged.dispatch( this.player.playbackRate );

	},

	setTime: function ( time ) {

		// location.hash = time;

		this.player.currentTime = Math.max( 0, time );
		this.signals.timeChanged.dispatch( this.player.currentTime );

	},

	// libraries

	addLibrary: function ( url, content ) {

		var script = document.createElement( 'script' );
		script.id = 'library-' + this.libraries.length;
		script.textContent = content;
		document.head.appendChild( script );

		this.libraries.push( url );
		this.signals.libraryAdded.dispatch();

	},

	// includes

	addInclude: function ( name, source ) {

		var script = document.createElement( 'script' );
		script.id = 'include-' + this.includes.length;
		script.textContent = '( function () { ' + source + ' } )()';
		document.head.appendChild( script );

		this.includes.push( { name: name, source: source } );
		this.signals.includeAdded.dispatch();

	},

	removeInclude: function ( include ) {

		var index = this.includes.indexOf( include );

		this.includes.splice( index, 1 );

		var script = document.getElementById( 'include-' + index );
		document.head.removeChild( script );

		this.signals.includeRemoved.dispatch();

	},

	selectInclude: function ( include ) {

		this.signals.includeSelected.dispatch( include );

	},

	reloadIncludes: function () {

		var includes = this.includes;
{'fraction_non_alphanumeric': 0.1456137949911044, 'fraction_numerical': 0.0026002463391268647, 'mean_word_length': 3.561797752808989, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1159021', 'n_tokens_mistral': 2629, 'n_tokens_neox': 2224, 'n_words': 484}