<commit_before>/**
 * Supports the parsing of ads
 */
( function( mw, $ ) { "use strict";

	mw.KAds = function( embedPlayer, callback) {
		// Create a Player Manager
		return this.init( embedPlayer, callback );
	};

	mw.KAds.prototype = {
		// The ad types
		namedAdTimelineTypes : [ 'preroll', 'postroll', 'midroll', 'overlay' ],
		// Ad attribute map
		adAttributeMap: {
			"Interval": 'frequency',
			"StartAt": 'start'
		},
		displayedCuePoints: [],

		bindPostfix: '.KAds',
		confPrefix: 'vast',
		config:{},

		previousTime: 0,
		seekIntervalID: null,

		init: function( embedPlayer, callback ){
			var _this = this;
			// Inherit BaseAdPlugin
			mw.inherit( this, new mw.BaseAdPlugin( embedPlayer, callback ) );

			_this.embedPlayer = embedPlayer;

			// Setup the ad player:
			_this.adPlayer = new mw.KAdPlayer( embedPlayer );

			// Clear any existing bindings:
			_this.destroy();

			$( embedPlayer ).bind( 'onChangeMedia' + _this.bindPostfix, function(){
				_this.destroy();
			});

			if( ! _this.getConfig( 'preSequence' ) ) {
				_this.config[ 'preSequence' ] = 0;
			}
			if( ! _this.getConfig( 'postSequence' ) ) {
				_this.config[ 'postSequence' ] = 0;
			}

			// We can add this binding here, because we will always have vast in the uiConf when having cue points
			// Catch Ads from adOpportunity event
			if( embedPlayer.getKalturaConfig('vast', 'trackCuePoints') === true ) {
				$( embedPlayer ).bind('KalturaSupport_AdOpportunity' + _this.bindPostfix, function( event, cuePointWrapper ) {
					// Check for  protocolType == 1 ( type = vast )
					if( cuePointWrapper.cuePoint.protocolType == 1 ){
						_this.handleAdOpportunity( cuePointWrapper );
					}
				});

				$( embedPlayer ).bind('midSequenceComplete' + _this.bindPostfix, function() {
					embedPlayer.play();
				});
			}

			// Disable seek for VAST in iPhone
			if( !embedPlayer.getKalturaConfig('vast', 'allowSeekWithNativeControls') && mw.isIphone() ) {
				$( embedPlayer ).bind('AdSupport_StartAdPlayback' + _this.bindPostfix, function() {
					_this.seekIntervalID = _this.seekIntervalTrigger();
				});

				$( embedPlayer ).bind('onAdComplete' + _this.bindPostfix, function() {
					if( _this.seekIntervalID ) {
						clearInterval(_this.seekIntervalID);
					}
				});
			}

			// Reset displayedCuePoints array if adsOnReplay is true
			if( embedPlayer.getFlashvars( 'adsOnReplay' ) === true ) {
				embedPlayer.bindHelper('ended' + _this.bindPostfix, function() {
					_this.displayedCuePoints = [];
				});
			}<commit_msg>replacing bind to AdSupport_StartAdPlayback with onAdOpen since onAdOpen is call for every ad but the first is called once for all ads<commit_after>/**
 * Supports the parsing of ads
 */
( function( mw, $ ) { "use strict";

	mw.KAds = function( embedPlayer, callback) {
		// Create a Player Manager
		return this.init( embedPlayer, callback );
	};

	mw.KAds.prototype = {
		// The ad types
		namedAdTimelineTypes : [ 'preroll', 'postroll', 'midroll', 'overlay' ],
		// Ad attribute map
		adAttributeMap: {
			"Interval": 'frequency',
			"StartAt": 'start'
		},
		displayedCuePoints: [],

		bindPostfix: '.KAds',
		confPrefix: 'vast',
		config:{},

		previousTime: 0,
		seekIntervalID: null,

		init: function( embedPlayer, callback ){
			var _this = this;
			// Inherit BaseAdPlugin
			mw.inherit( this, new mw.BaseAdPlugin( embedPlayer, callback ) );

			_this.embedPlayer = embedPlayer;

			// Setup the ad player:
			_this.adPlayer = new mw.KAdPlayer( embedPlayer );

			// Clear any existing bindings:
			_this.destroy();

			$( embedPlayer ).bind( 'onChangeMedia' + _this.bindPostfix, function(){
				_this.destroy();
			});

			if( ! _this.getConfig( 'preSequence' ) ) {
				_this.config[ 'preSequence' ] = 0;
			}
			if( ! _this.getConfig( 'postSequence' ) ) {
				_this.config[ 'postSequence' ] = 0;
			}

			// We can add this binding here, because we will always have vast in the uiConf when having cue points
			// Catch Ads from adOpportunity event
			if( embedPlayer.getKalturaConfig('vast', 'trackCuePoints') === true ) {
				$( embedPlayer ).bind('KalturaSupport_AdOpportunity' + _this.bindPostfix, function( event, cuePointWrapper ) {
					// Check for  protocolType == 1 ( type = vast )
					if( cuePointWrapper.cuePoint.protocolType == 1 ){
						_this.handleAdOpportunity( cuePointWrapper );
					}
				});

				$( embedPlayer ).bind('midSequenceComplete' + _this.bindPostfix, function() {
					embedPlayer.play();
				});
			}

			// Disable seek for VAST in iPhone
			if( !embedPlayer.getKalturaConfig('vast', 'allowSeekWithNativeControls') && mw.isIphone() ) {
				$( embedPlayer ).bind('onAdOpen' + _this.bindPostfix, function() {
					_this.seekIntervalID = _this.seekIntervalTrigger();
				});

				$( embedPlayer ).bind('onAdComplete' + _this.bindPostfix, function() {
					if( _this.seekIntervalID ) {
						clearInterval(_this.seekIntervalID);
					}
				});
			}

			// Reset displayedCuePoints array if adsOnReplay is true
			if( embedPlayer.getFlashvars( 'adsOnReplay' ) === true ) {
				embedPlayer.bindHelper('ended' + _this.bindPostfix, function() {
					_this.displayedCuePoints = [];
				});
			}
{'fraction_non_alphanumeric': 0.1387596899224806, 'fraction_numerical': 0.001937984496124031, 'mean_word_length': 3.3663282571912014, 'pattern_counts': {'":': 4, '<': 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': '4616058', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1635, 'n_words': 391}