<commit_before>( function( mw, $ ) {

mw.addFreeWheelControler = function( embedPlayer, config, callback ) {
	embedPlayer.freeWheelAds = new mw.freeWheelControler({ 
		'embedPlayer' : embedPlayer,
		'config' : config,
		'callback' :  callback
	});	
	mw.freeWheelGlobalContextInstance = embedPlayer.freeWheelAds;
};

mw.freeWheelControler = function( opt ){
	return this.init( opt );
};

mw.freeWheelControler.prototype = {
	
	// The freeWheel adManager 
	adManager: null,
	
	// The ad Context:
	adContext: null,
	
	// The ad data requested
	adDataRequested : false,
	
	// The pre video url
	contentVideoURL : null, 
	
	// local slot storage for preroll, midroll, postroll
	slots : {
		'preroll' : [],
		'postroll' : [],
		'overlay' : [],
		'midroll' : []
	},
	
	// The current active slot
	currentSlotDoneCb: null,
		
	// if an overlay slot is active:  
	overlaySlotActive: false,
	
	/**
	 * Initialize the adMannager javascript and setup adds
	 * 
	 * @param {Object} opt Object 
	 * {
	 * 	'embedPlayer' {object} the embedPlayer instance
	 * 	'config' {object} any freewheel configuration
	 * 	'callback' {function} called on load complete
	 * }
	 * @return
	 */
	init: function( opt ){
		var _this = this;
		$.extend( this, opt);
		
		// XXX temporary override config for testing
		this.config = {
			'networkId': 96749,
			'serverUrl' : 'http://sdnyadvip1-d.fwmrm.net/ad/g/1',
			'videoAssetId' : 'DemoVideoGroup.01',
			'videoDuration' : 500
		};
		
		
		// Load the ad manager url:
		// XXX todo we should be able to read this from "adManagerUrl"
		var AdManagerUrl = mw.getConfig( 'FreeWheel.AdManagerUrl' );
		
		$.getScript(AdManagerUrl, function(){
			_this.setupAds();
		});
	},
	/**
	 * Setup ads, main freeWheel control flow
	 * @return
	 */
	setupAds: function(){
		var _this = this;
		
		// Add key-values for ad targeting.
		this.addContextKeyValues();
		
		// Listen to AdManager Events
		this.addContextListners();
		
		// Set context timeout
		this.setContextTimeout();

		// Add the temporal slots for this "player"
		this.addTemporalSlots();

		// Add local companion targets
		if( mw.getConfig( 'FreeWheel.PostMessageIframeCompanions' ) ){
			this.addCompanionBindings();
		}
		
		// XXX FreeWheel sets SVLads003 as the response? 
		window['SVLads003'] = true;
		
		// Load add data ( will call onRequestComplete once ready )
		mw.log("freeWheelController::submitRequest>");
		this.getContext().submitRequest();
	},
	addPlayerBindings: function(){
		mw.log("FreeWheelControl:: addPlayerBindings");
		var _this = this;
	
		$.each(_this.slots, function( slotType, slotSet){
			if( slotType == 'midroll' || slotType == 'overlay' ){
				$( _this.embedPlayer ).bind( 'monitorEvent.freewheel', function( event ){
					_this.displayOverlayInRange( slotSet );
				});
				return true;
			}
			
			// else set of preroll or postroll clips setup normal binding: 
			$( _this.embedPlayer ).bind( 'AdSupport_' + slotType, function( event, callback ){
				// Run the freewheel slot add, then run the callback once done 
				_this.displayFreeWheelSlots( slotType, 0, function(){
					// Restore the player:
					_this.getContext().setVideoState( tv.freewheel.SDK.VIDEO_STATE_PLAYING );
					// Run the callback: 
					callback();
				});
			});
		});
		// run the player callback once we have added player bindings
		this.callback();
	},
	displayOverlayInRange: function( slotSet ){
		var _this = this;
		$.each(slotSet, function(inx, slot){
			var slotTimePosition = slot.getTimePosition();
			mw.log('displayOverlayInRange::check slot: ' + slot.getTimePosition() );
			if ( _this.embedPlayer.currentTime - slotTimePosition >= 0 && 
				_this.embedPlayer.currentTime - slotTimePosition <= 1 && <commit_msg>cleaned up debug for freewheel<commit_after>( function( mw, $ ) {

mw.addFreeWheelControler = function( embedPlayer, config, callback ) {
	embedPlayer.freeWheelAds = new mw.freeWheelControler({ 
		'embedPlayer' : embedPlayer,
		'config' : config,
		'callback' :  callback
	});	
	mw.freeWheelGlobalContextInstance = embedPlayer.freeWheelAds;
};

mw.freeWheelControler = function( opt ){
	return this.init( opt );
};

mw.freeWheelControler.prototype = {
	
	// The freeWheel adManager 
	adManager: null,
	
	// The ad Context:
	adContext: null,
	
	// The ad data requested
	adDataRequested : false,
	
	// The pre video url
	contentVideoURL : null, 
	
	// local slot storage for preroll, midroll, postroll
	slots : {
		'preroll' : [],
		'postroll' : [],
		'overlay' : [],
		'midroll' : []
	},
	
	// The current active slot
	currentSlotDoneCb: null,
		
	// if an overlay slot is active:  
	overlaySlotActive: false,
	
	/**
	 * Initialize the adMannager javascript and setup adds
	 * 
	 * @param {Object} opt Object 
	 * {
	 * 	'embedPlayer' {object} the embedPlayer instance
	 * 	'config' {object} any freewheel configuration
	 * 	'callback' {function} called on load complete
	 * }
	 * @return
	 */
	init: function( opt ){
		var _this = this;
		$.extend( this, opt);
		
		// XXX temporary override config for testing
		this.config = {
			'networkId': 96749,
			'serverUrl' : 'http://sdnyadvip1-d.fwmrm.net/ad/g/1',
			'videoAssetId' : 'DemoVideoGroup.01',
			'videoDuration' : 500
		};
		
		
		// Load the ad manager url:
		// XXX todo we should be able to read this from "adManagerUrl"
		var AdManagerUrl = mw.getConfig( 'FreeWheel.AdManagerUrl' );
		
		$.getScript(AdManagerUrl, function(){
			_this.setupAds();
		});
	},
	/**
	 * Setup ads, main freeWheel control flow
	 * @return
	 */
	setupAds: function(){
		var _this = this;
		
		// Add key-values for ad targeting.
		this.addContextKeyValues();
		
		// Listen to AdManager Events
		this.addContextListners();
		
		// Set context timeout
		this.setContextTimeout();

		// Add the temporal slots for this "player"
		this.addTemporalSlots();

		// Add local companion targets
		if( mw.getConfig( 'FreeWheel.PostMessageIframeCompanions' ) ){
			this.addCompanionBindings();
		}
		
		// XXX FreeWheel sets SVLads003 as the response? 
		window['SVLads003'] = true;
		
		// Load add data ( will call onRequestComplete once ready )
		mw.log("freeWheelController::submitRequest>");
		this.getContext().submitRequest();
	},
	addPlayerBindings: function(){
		mw.log("FreeWheelControl:: addPlayerBindings");
		var _this = this;
	
		$.each(_this.slots, function( slotType, slotSet){
			if( slotType == 'midroll' || slotType == 'overlay' ){
				$( _this.embedPlayer ).bind( 'monitorEvent.freewheel', function( event ){
					_this.displayOverlayInRange( slotSet );
				});
				return true;
			}
			
			// else set of preroll or postroll clips setup normal binding: 
			$( _this.embedPlayer ).bind( 'AdSupport_' + slotType, function( event, callback ){
				// Run the freewheel slot add, then run the callback once done 
				_this.displayFreeWheelSlots( slotType, 0, function(){
					// Restore the player:
					_this.getContext().setVideoState( tv.freewheel.SDK.VIDEO_STATE_PLAYING );
					// Run the callback: 
					callback();
				});
			});
		});
		// run the player callback once we have added player bindings
		this.callback();
	},
	displayOverlayInRange: function( slotSet ){
		var _this = this;
		$.each(slotSet, function(inx, slot){
			var slotTimePosition = slot.getTimePosition();
			if ( _this.embedPlayer.currentTime - slotTimePosition >= 0 && 
				_this.embedPlayer.currentTime - slotTimePosition <= 1 && 
{'fraction_non_alphanumeric': 0.12901912901912901, 'fraction_numerical': 0.005698005698005698, 'mean_word_length': 3.367298578199052, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3620443', 'n_tokens_mistral': 2748, 'n_tokens_neox': 2335, 'n_words': 621}