<commit_before>kWidget.addReadyCallback( function( playerId ){ 
	/**
	 * The main omnitureOnPage object:
	 */
	var omnitureOnPage = function( player ){
		return this.init( player );
	}
	omnitureOnPage.prototype = {
		instanceName: 'omnitureOnPage',
		sCodeLoaded: false,
		entryData: {},
		init: function( player ){
			var _this = this;
			this.kdp = player;
			this.log( 'init' );
			// unbind any existing bindings:
			this.kdp.kUnbind( '.' + this.instanceName );
			// We bind to event
			_this.bindPlayer();
			// Check for on-page s-code that already exists
			this.bind('layoutReady', function(){
				_this.sCodeCheck(function(){
					_this.setupMonitor();
					_this.bindCustomEvents();
				});
			});
		},
		cacheEntryMetadata: function(){
			this.entryData = {
				id: this.kdp.evaluate( '{mediaProxy.entry.id}' ),
				referenceId: this.kdp.evaluate( '{mediaProxy.entry.referenceId}' ),
				mediaType: this.kdp.evaluate( '{mediaProxy.entry.mediaType}' ),
				name: this.kdp.evaluate( '{mediaProxy.entry.name}' ),
				duration: this.kdp.evaluate( '{mediaProxy.entry.duration}' )
			};
		},
		getSCodeName: function(){
			return this.getConfig('s_codeVarName') || 's';
		},
		sCodeCheck: function( callback ){
			var _this = this;

			// Run sCode check once
			if( this.sCodeLoaded ) {
				return ;
			}

			var doneCallback = function() {
				_this.log( 'sCodeCheck found' );
				// check if media module is found
				if( !window[ _this.getSCodeName() ] || !window[ _this.getSCodeName() ]['Media'] ){
					_this.log( "Error: s.Media module missing !!");
					return ;
				}
				// Override s_code object with local configuration
				var configFuncName = _this.getConfig('s_codeConfigFunc');
				if( configFuncName && typeof window[ configFuncName ] == 'function' ) {
					var localConfig = window[ configFuncName ]();
					for( var k in localConfig ) {
						window[ _this.getSCodeName() ][ k ] = localConfig[ k ];
					}
				}

				_this.sCodeLoaded = true;

				if(callback) {
					callback();
				}
			};
			// check if already on the page: 
			if( window[ this.getSCodeName() ] && window[ this.getSCodeName() ]['Media'] ){
				doneCallback();
				return ; 
			}
			
			// check if we have scode
			if( !_this.getConfig('s_codeUrl') ){
				_this.log( "Error: s_codeUrl must be set for Omniture onPage plugin");
				return ;
			}
			kWidget.appendScriptUrl( _this.getConfig('s_codeUrl'), doneCallback );
		},
		/** Getters **/
		getMediaPlayerName: function(){
			return 'Kaltura Omniture OnPage v' + mw.getConfig('version'); 
		},
		getMediaName: function(){
	 		var _this = this;
	 		// shortcut to custom data with trimming spaces if exists

			var trimSpaces = function(str) {
				str = str.replace(/^\s+/, '');
				for (var i = str.length - 1; i >= 0; i--) {
					if (/\S/.test(str.charAt(i))) {
						str = str.substring(0, i + 1);
						break;
					}
				}
				return str;
			}


	 		var g = function( key ){
	 			return trimSpaces(_this.getAttr( 'mediaProxy.entryMetadata.' + key ) || '_');
	 		}
 			switch( _this.getConfig( 'concatMediaName' ) ){
 				case 'doluk':
 					var refId = _this.entryData.referenceId;
 					if( !refId ) 
 						refId = _this.entryData.id;
 					return [  this.getCType(), g('SiteSection'), g('PropertyCode'), 
 						g('ContentType'),  g('ShortTitle').substr(0,30), 
 						_this.getDuration(),  refId 
 						].join(':').replace(/\s/g, "_");
 				break;
 			}
			return this.entryData.name;
		},
		getDuration: function(){
			if( !this.entryData.duration ) return '';
			return this.entryData.duration.toString();
		},
		getCurrentTime: function(){
			return Math.floor( parseInt(this.getAttr('video.player.currentTime')) );
		},
		/*
		Support passing global evars to all events
		
		sample attribute config: 
		additionalEvarsAndProps="eVar51,eVar52,eVar53,eVar54,prop44"
		additionalEvarsAndPropsValues="{mediaProxy.entry.creatorId},
			{mediaProxy.entry.createdAt},{configProxy.flashvars.referer},
			{mediaProxy.entry.duration},{configProxy.flashvars.streamerType}" 
		*/
		setupMonitor: function() {
			// Exit if sCode not loaded
			if( !this.sCodeLoaded ) {
				return ;
			}

			var _this = this;
			var extraEvars = [];
			var extraEvarsValues = [];
			
			this.log( 'setupMonitor' );
			
			// get local ref to the sCode s var:
			var s = window[ this.getSCodeName() ];
			
			// Check for additional eVars and eVars values
			var additionalEvarsAndProps = this.getConfig('additionalEvarsAndProps');
			var additionalEvarsAndPropsValues = this.getConfig('additionalEvarsAndPropsValues');
			if( additionalEvarsAndProps ) {
				extraEvars = additionalEvarsAndProps.split(",");
			}
			if( additionalEvarsAndPropsValues ){<commit_msg>re-evaluate omniture additionalEvarsAndProps so that complex strings that holds mix expressions and strings will be parsed.<commit_after>kWidget.addReadyCallback( function( playerId ){ 
	/**
	 * The main omnitureOnPage object:
	 */
	var omnitureOnPage = function( player ){
		return this.init( player );
	}
	omnitureOnPage.prototype = {
		instanceName: 'omnitureOnPage',
		sCodeLoaded: false,
		entryData: {},
		init: function( player ){
			var _this = this;
			this.kdp = player;
			this.log( 'init' );
			// unbind any existing bindings:
			this.kdp.kUnbind( '.' + this.instanceName );
			// We bind to event
			_this.bindPlayer();
			// Check for on-page s-code that already exists
			this.bind('layoutReady', function(){
				_this.sCodeCheck(function(){
					_this.setupMonitor();
					_this.bindCustomEvents();
				});
			});
		},
		cacheEntryMetadata: function(){
			this.entryData = {
				id: this.kdp.evaluate( '{mediaProxy.entry.id}' ),
				referenceId: this.kdp.evaluate( '{mediaProxy.entry.referenceId}' ),
				mediaType: this.kdp.evaluate( '{mediaProxy.entry.mediaType}' ),
				name: this.kdp.evaluate( '{mediaProxy.entry.name}' ),
				duration: this.kdp.evaluate( '{mediaProxy.entry.duration}' )
			};
		},
		getSCodeName: function(){
			return this.getConfig('s_codeVarName') || 's';
		},
		sCodeCheck: function( callback ){
			var _this = this;

			// Run sCode check once
			if( this.sCodeLoaded ) {
				return ;
			}

			var doneCallback = function() {
				_this.log( 'sCodeCheck found' );
				// check if media module is found
				if( !window[ _this.getSCodeName() ] || !window[ _this.getSCodeName() ]['Media'] ){
					_this.log( "Error: s.Media module missing !!");
					return ;
				}
				// Override s_code object with local configuration
				var configFuncName = _this.getConfig('s_codeConfigFunc');
				if( configFuncName && typeof window[ configFuncName ] == 'function' ) {
					var localConfig = window[ configFuncName ]();
					for( var k in localConfig ) {
						window[ _this.getSCodeName() ][ k ] = localConfig[ k ];
					}
				}

				_this.sCodeLoaded = true;

				if(callback) {
					callback();
				}
			};
			// check if already on the page: 
			if( window[ this.getSCodeName() ] && window[ this.getSCodeName() ]['Media'] ){
				doneCallback();
				return ; 
			}
			
			// check if we have scode
			if( !_this.getConfig('s_codeUrl') ){
				_this.log( "Error: s_codeUrl must be set for Omniture onPage plugin");
				return ;
			}
			kWidget.appendScriptUrl( _this.getConfig('s_codeUrl'), doneCallback );
		},
		/** Getters **/
		getMediaPlayerName: function(){
			return 'Kaltura Omniture OnPage v' + mw.getConfig('version'); 
		},
		getMediaName: function(){
	 		var _this = this;
	 		// shortcut to custom data with trimming spaces if exists

			var trimSpaces = function(str) {
				str = str.replace(/^\s+/, '');
				for (var i = str.length - 1; i >= 0; i--) {
					if (/\S/.test(str.charAt(i))) {
						str = str.substring(0, i + 1);
						break;
					}
				}
				return str;
			}


	 		var g = function( key ){
	 			return trimSpaces(_this.getAttr( 'mediaProxy.entryMetadata.' + key ) || '_');
	 		}
 			switch( _this.getConfig( 'concatMediaName' ) ){
 				case 'doluk':
 					var refId = _this.entryData.referenceId;
 					if( !refId ) 
 						refId = _this.entryData.id;
 					return [  this.getCType(), g('SiteSection'), g('PropertyCode'), 
 						g('ContentType'),  g('ShortTitle').substr(0,30), 
 						_this.getDuration(),  refId 
 						].join(':').replace(/\s/g, "_");
 				break;
 			}
			return this.entryData.name;
		},
		getDuration: function(){
			if( !this.entryData.duration ) return '';
			return this.entryData.duration.toString();
		},
		getCurrentTime: function(){
			return Math.floor( parseInt(this.getAttr('video.player.currentTime')) );
		},
		/*
		Support passing global evars to all events
		
		sample attribute config: 
		additionalEvarsAndProps="eVar51,eVar52,eVar53,eVar54,prop44"
		additionalEvarsAndPropsValues="{mediaProxy.entry.creatorId},
			{mediaProxy.entry.createdAt},{configProxy.flashvars.referer},
			{mediaProxy.entry.duration},{configProxy.flashvars.streamerType}" 
		*/
		setupMonitor: function() {
			// Exit if sCode not loaded
			if( !this.sCodeLoaded ) {
				return ;
			}

			var _this = this;
			var extraEvars = [];
			var extraEvarsValues = [];
			
			this.log( 'setupMonitor' );
			
			// get local ref to the sCode s var:
			var s = window[ this.getSCodeName() ];

			// Check for additional eVars and eVars values
			var additionalEvarsAndProps = this.getConfig('additionalEvarsAndProps');
			var additionalEvarsAndPropsValues = this.getConfig('additionalEvarsAndPropsValues');
			if( additionalEvarsAndProps ) {
				extraEvars = additionalEvarsAndProps.split(",");
			}
			if( additionalEvarsAndPropsValues ){
				additionalEvarsAndPropsValues = this.kdp.evaluate(additionalEvarsAndPropsValues);
{'fraction_non_alphanumeric': 0.1450788017952197, 'fraction_numerical': 0.003548690115854295, 'mean_word_length': 3.1301724137931033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1791845', 'n_tokens_mistral': 3877, 'n_tokens_neox': 3124, 'n_words': 685}