src/js/LdtPlayer.js
changeset 22 e67d56c23ca7
parent 16 81a63a89ed35
child 31 cbb1425bc769
equal deleted inserted replaced
21:6065fde8401f 22:e67d56c23ca7
    17  *	The fact that you are presently reading this means that you have had
    17  *	The fact that you are presently reading this means that you have had
    18  *	knowledge of the CeCILL-C license and that you accept its terms.
    18  *	knowledge of the CeCILL-C license and that you accept its terms.
    19 */
    19 */
    20 
    20 
    21 if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
    21 if ( window.IriSP === undefined && window.__IriSP === undefined ) { 
    22 	var IriSP ={}; 
    22 	var IriSP = {}; 
    23 	var __IriSP = IriSP; /* for backward compatibility */
    23 	var __IriSP = IriSP; /* for backward compatibility */
    24 }
    24 }
    25 
    25 
    26 		
    26 		
    27 /* CLASS TRACE */
    27 /* CLASS TRACE */
    28 
    28 
    29 IriSP.traceNum=0;
    29 IriSP.traceNum = 0;
    30 IriSP.trace = function(msg,value){
    30 IriSP.trace = function( msg, value ) {
    31 
    31 
    32 	if(IriSP.config.gui.debug===true){
    32 	if( IriSP.config.gui.debug === true ) {
    33 		IriSP.traceNum += 1;
    33 		IriSP.traceNum += 1;
    34 		IriSP.jQuery("<div>"+IriSP.traceNum+" - "+msg+" : "+value+"</div>").appendTo("#Ldt-output");
    34 		IriSP.jQuery( "<div>"+IriSP.traceNum+" - "+msg+" : "+value+"</div>" ).appendTo( "#Ldt-output" );
    35 	}
    35 	}
    36 
    36 };
    37 }
       
    38 
    37 
    39 // Player Configuration 
    38 // Player Configuration 
    40 IriSP.config = undefined;
    39 IriSP.config = undefined;
    41 IriSP.configDefault = {
    40 IriSP.configDefault = {
    42 		metadata:{
    41 		metadata:{
    73 				name:"Ldtplayer1"
    72 				name:"Ldtplayer1"
    74 			}
    73 			}
    75 		},
    74 		},
    76 		module:null
    75 		module:null
    77 	};
    76 	};
       
    77 
    78 IriSP.lib = {
    78 IriSP.lib = {
    79 			jQuery:"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",
    79 			jQuery:"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js",
    80 			jQueryUI:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js",
    80 			jQueryUI:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.min.js",
    81 			jQueryToolTip:"http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js",
    81 			jQueryToolTip:"http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js",
    82 			swfObject:"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
    82 			swfObject:"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
   103 
   103 
   104 	
   104 	
   105  
   105  
   106 
   106 
   107 
   107 
   108 IriSP.init = function (config){
   108 IriSP.init = function ( config ) {
   109 
   109 
   110 		
   110 		
   111 		if(config === null){
   111 		if ( config === null ) {
   112 		
       
   113 			IriSP.config 			 = IriSP.configDefault;
   112 			IriSP.config 			 = IriSP.configDefault;
   114 			
       
   115 		} else {
   113 		} else {
   116 			
   114 			
   117 			IriSP.config 			 = config;
   115 			IriSP.config 			 = config;
   118 			
   116 						
   119 			
   117 			if ( IriSP.config.player.params == null ) {
   120 
   118 				IriSP.config.player.params = IriSP.configDefault.player.params;
   121 			if (IriSP.config.player.params == null){
   119 			}
   122 			IriSP.config.player.params = IriSP.configDefault.player.params;}
   120 			
   123 			
   121 			if ( IriSP.config.player.flashvars == null ) {
   124 			if (IriSP.config.player.flashvars == null){
   122 				IriSP.config.player.flashvars = IriSP.configDefault.player.flashvars;
   125 			IriSP.config.player.flashvars = IriSP.configDefault.player.flashvars;}
   123 			}
   126 			if (IriSP.config.player.attributes == null){
   124 			
   127 			IriSP.config.player.attributes = IriSP.configDefault.player.attributes;}
   125 			if ( IriSP.config.player.attributes == null ) {
       
   126 				IriSP.config.player.attributes = IriSP.configDefault.player.attributes;
       
   127 			}
   128 		}
   128 		}
   129 		
   129 		
   130 		var metadataSrc 		 = IriSP.config.metadata.src;
   130 		var metadataSrc 		 = IriSP.config.metadata.src;
   131 		var guiContainer		 = IriSP.config.gui.container;
   131 		var guiContainer		 = IriSP.config.gui.container;
   132 		var guiMode				 = IriSP.config.gui.mode;
   132 		var guiMode				 = IriSP.config.gui.mode;
   133 		var guiLdtShareTool		 = IriSP.LdtShareTool;
   133 		var guiLdtShareTool		 = IriSP.LdtShareTool;
       
   134 		
   134 		// Localize jQuery variable
   135 		// Localize jQuery variable
   135 		IriSP.jQuery = null;
   136 		IriSP.jQuery = null;
   136 
   137 
   137 		/******** Load jQuery if not present *********/
   138 		/******** Load jQuery if not present *********/
   138 		if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
   139 		if ( window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2' ) {
   139 			var script_tag = document.createElement('script');
   140 			
   140 			script_tag.setAttribute("type","text/javascript");
   141 			var script_tag = document.createElement( 'script' );
   141 			script_tag.setAttribute("src",IriSP.lib.jQuery);
   142 			script_tag.setAttribute( "type", "text/javascript" );
   142 				//"http://cdn.jquerytools.org/1.2.4/full/jquery.tools.min.js");
   143 			script_tag.setAttribute( "src", IriSP.lib.jQuery );
       
   144 			
   143 			script_tag.onload = scriptLibHandler;
   145 			script_tag.onload = scriptLibHandler;
   144 			script_tag.onreadystatechange = function () { // Same thing but for IE
   146 			script_tag.onreadystatechange = function () { // Same thing but for IE
   145 				if (this.readyState == 'complete' || this.readyState == 'loaded') {
   147 				if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
   146 					scriptLibHandler();
   148 					scriptLibHandler();					
   147 					
       
   148 				}
   149 				}
   149 			};
   150 			};
       
   151 			
   150 			// Try to find the head, otherwise default to the documentElement
   152 			// Try to find the head, otherwise default to the documentElement
   151 			(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
   153 			( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_tag );
   152 		} else {
   154 		} else {
   153 			// The jQuery version on the window is the one we want to use
   155 			// The jQuery version on the window is the one we want to use
   154 			 IriSP.jQuery = window.jQuery;
   156 			 IriSP.jQuery = window.jQuery;
   155 			scriptLibHandler();
   157 			 scriptLibHandler();
   156 		}
   158 		}
   157 
   159 
   158 		/******** Called once jQuery has loaded ******/
   160 		/******** Called once jQuery has loaded ******/
   159 		function scriptLibHandler() {
   161 		function scriptLibHandler() {
   160 			
   162 			
   161 			var script_jqUi_tooltip = document.createElement('script');
   163 			var script_jqUi_tooltip = document.createElement( 'script' );
   162 			script_jqUi_tooltip.setAttribute("type","text/javascript");
   164 			script_jqUi_tooltip.setAttribute( "type", "text/javascript" );
   163 			script_jqUi_tooltip.setAttribute("src",IriSP.lib.jQueryToolTip);
   165 			script_jqUi_tooltip.setAttribute( "src", IriSP.lib.jQueryToolTip );
   164 			script_jqUi_tooltip.onload = scriptLoadHandler;
   166 			script_jqUi_tooltip.onload = scriptLoadHandler;
   165 			script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE
   167 			script_jqUi_tooltip.onreadystatechange = function () { // Same thing but for IE
   166 				if (this.readyState == 'complete' || this.readyState == 'loaded') {
   168 				if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
   167 					scriptLoadHandler("jquery.tools.min.js loded");
   169 					scriptLoadHandler( "jquery.tools.min.js loded" );
   168 				}
   170 				}
   169 			};
   171 			};
   170 			
   172 			
   171 			var script_swfObj = document.createElement('script');
   173 			var script_swfObj = document.createElement('script');
   172 			script_swfObj.setAttribute("type","text/javascript");
   174 			script_swfObj.setAttribute( "type","text/javascript" );
   173 			script_swfObj.setAttribute("src",IriSP.lib.swfObject);
   175 			script_swfObj.setAttribute( "src",IriSP.lib.swfObject );
   174 			script_swfObj.onload = scriptLoadHandler;
   176 			script_swfObj.onload = scriptLoadHandler;
   175 			script_swfObj.onreadystatechange = function () { // Same thing but for IE
   177 			script_swfObj.onreadystatechange = function () { // Same thing but for IE
   176 				if (this.readyState == 'complete' || this.readyState == 'loaded') {
   178 				if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
   177 					scriptLoadHandler("swfobject.js loded");
   179 					scriptLoadHandler( "swfobject.js loded" );
   178 				}
   180 				}
   179 			};
   181 			};
   180 		
   182 		
   181 			var script_jqUi = document.createElement('script');
   183 			var script_jqUi = document.createElement( 'script' );
   182 			script_jqUi.setAttribute("type","text/javascript");
   184 			script_jqUi.setAttribute( "type","text/javascript" );
   183 			script_jqUi.setAttribute("src",IriSP.lib.jQueryUI);
   185 			script_jqUi.setAttribute( "src",IriSP.lib.jQueryUI );
   184 			script_jqUi.onload = scriptLoadHandler;
   186 			script_jqUi.onload = scriptLoadHandler;
   185 			script_jqUi.onreadystatechange = function () { // Same thing but for IE
   187 			script_jqUi.onreadystatechange = function () { // Same thing but for IE
   186 				if (this.readyState == 'complete' || this.readyState == 'loaded') {
   188 				if ( this.readyState == 'complete' || this.readyState == 'loaded' ) {
   187 					scriptLoadHandler("jquery-ui.min.js loded");
   189 					scriptLoadHandler( "jquery-ui.min.js loded" );
   188 				}
   190 				}
   189 			};
   191 			};
   190 		
   192 		
   191 
   193 
   192 			
   194 			( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi_tooltip);
   193 
   195 			( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_jqUi );
   194 			(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi_tooltip);
   196 			( document.getElementsByTagName("head")[0] || document.documentElement ).appendChild( script_swfObj );
   195 			(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_jqUi);
       
   196 			(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_swfObj);
       
   197 			
   197 			
   198 
   198 
   199 		};
   199 		};
   200 
   200 
   201 		/******** Called once all lib are loaded ******/
   201 		/******** Called once all lib are loaded ******/
   202 		var loadLib = 0;
   202 		var loadLib = 0;
   203 		function scriptLoadHandler(Mylib) {
   203 		/* FIXME : ugly */
       
   204 		function scriptLoadHandler( Mylib ) {
   204 			//alert(Mylib);
   205 			//alert(Mylib);
   205 			loadLib +=1;
   206 			loadLib +=1;
   206 			if(loadLib===3){ 
   207 			if( loadLib===3 ) { 
   207 				main(); 			  
   208 				main(); 			  
   208 			}else {
       
   209 				// __IriSP.jQuery('#'+__IriSP.config.gui.container).html("Loading library ...");
       
   210 			}
   209 			}
   211 		};
   210 		};
   212 
   211 
   213 		/******** Our main function ********/
   212 		/******** Our main function ********/
   214 		function main() { 
   213 		function main() { 
   215 			
   214 			
   216 
   215 
   217 			//  Make __IriSP.jQuery and restore window.jQuery 
   216 			//  Make our own IriSP.jQuery and restore window.jQuery if there was one. 
   218 			IriSP.jQuery = window.jQuery.noConflict(true);
   217 			IriSP.jQuery = window.jQuery.noConflict( true );
   219 			// Call MY Jquery
   218 			// Call ours Jquery
   220 			IriSP.jQuery(document).ready(function($) { 
   219 			IriSP.jQuery( document ).ready( function($) { 
   221 				
   220 				
   222 				/******* Load CSS *******/
   221 				/******* Load CSS *******/
   223 				var css_link_jquery = IriSP.jQuery("<link>", { 
   222 				var css_link_jquery = IriSP.jQuery( "<link>", { 
   224 					rel: "stylesheet", 
   223 					rel: "stylesheet", 
   225 					type: "text/css", 
   224 					type: "text/css", 
   226 					href: IriSP.lib.cssjQueryUI,
   225 					href: IriSP.lib.cssjQueryUI,
   227 					'class': "dynamic_css"
   226 					'class': "dynamic_css"
   228 				});
   227 				} );
   229 				var css_link_custom = IriSP.jQuery("<link>", { 
   228 				var css_link_custom = IriSP.jQuery( "<link>", { 
   230 					rel: "stylesheet", 
   229 					rel: "stylesheet", 
   231 					type: "text/css", 
   230 					type: "text/css", 
   232 					href: IriSP.config.gui.css,
   231 					href: IriSP.config.gui.css,
   233 					'class': "dynamic_css"
   232 					'class': "dynamic_css"
   234 				});
   233 				} );
   235 				
   234 				
   236 				css_link_jquery.appendTo('head');
   235 				css_link_jquery.appendTo( 'head' );
   237 				css_link_custom.appendTo('head');   
   236 				css_link_custom.appendTo( 'head' );   
   238 
   237 
   239 				// to see dynamicly loaded css on IE
   238 				// to see dynamicly loaded css on IE
   240 				if ($.browser.msie) {
   239 				if ( $.browser.msie ) {
   241 					$('.dynamic_css').clone().appendTo('head');
   240 					$( '.dynamic_css' ).clone().appendTo( 'head' );
   242 				}
   241 				}
   243 				
   242 				
   244 				//__IriSP.trace("main","ready createMyHtml");
   243 				//__IriSP.trace("main","ready createMyHtml");
   245 				
   244 				
   246 				IriSP.createMyHtml();
   245 				IriSP.createMyHtml();
   247 				//__IriSP.trace("main","end createMyHtml");
   246 				//__IriSP.trace("main","end createMyHtml");
   248 				
   247 				
   249 				/******* Load Metadata *******/
   248 				/******* Load Metadata *******/
   250 				
   249 				/* FIXME : factor it in another file */
   251 				IriSP.jQuery.ajax({
   250 				IriSP.jQuery.ajax({
   252 					  dataType: IriSP.config.metadata.load,
   251 					  dataType: IriSP.config.metadata.load,
   253 					  url:metadataSrc,
   252 					  url:metadataSrc,
   254 					  success : function(json){
   253 					  success : function( json ){
   255 					  
   254 					  
   256 							IriSP.trace("ajax","success");
   255 							IriSP.trace( "ajax", "success" );
   257 							
   256 							
   258 							// START PARSING ----------------------- 
   257 							// START PARSING ----------------------- 
   259 							if(json === ""){
   258 							if( json === "" ){
   260 								alert("ERREUR DE CHARGEMENT JSON");
   259 								alert( "Json load error" );
   261 							} else {
   260 							} else {							  							  
   262 							  
       
   263 							  
       
   264 								// # CREATE MEDIA  							//
   261 								// # CREATE MEDIA  							//
   265 								// # JUSTE ONE PLAYER FOR THE MOMENT		//
   262 								// # JUSTE ONE PLAYER FOR THE MOMENT		//
   266 								//__IriSP.jQuery("<div></div>").appendTo("#output");
   263 								//__IriSP.jQuery("<div></div>").appendTo("#output");
   267 								var MyMedia = new  __IriSP.Media(
   264 								var MyMedia = new  __IriSP.Media(
   268 																	json.medias[0].id,
   265 																	json.medias[0].id,
   269 																	json.medias[0].href,
   266 																	json.medias[0].href,
   270 																	json.medias[0]['meta']['dc:duration'],
   267 																	json.medias[0]['meta']['dc:duration'],
   271 																	json.medias[0]['dc:title'],
   268 																	json.medias[0]['dc:title'],
   272 																	json.medias[0]['dc:description']);
   269 																	json.medias[0]['dc:description']);
   273 								
   270 								
   274 								IriSP.trace("__IriSP.MyApiPlayer",
   271 								IriSP.trace( "__IriSP.MyApiPlayer",
   275 																	IriSP.config.gui.width+"   "
   272 																	IriSP.config.gui.width+"   "
   276 																	+ IriSP.config.gui.height + " "
   273 																	+ IriSP.config.gui.height + " "
   277 																	+ json.medias[0].href + " "
   274 																	+ json.medias[0].href + " "
   278 																	+ json.medias[0]['meta']['dc:duration'] + " "
   275 																	+ json.medias[0]['meta']['dc:duration'] + " "
   279 																	+ json.medias[0]['meta']['item']['value']);
   276 																	+ json.medias[0]['meta']['item']['value']);
   280 								
   277 								
   281 								// Create APIplayer
   278 								// Create APIplayer
   282 								IriSP.MyApiPlayer = new __IriSP.APIplayer(
   279 								IriSP.MyApiPlayer = new __IriSP.APIplayer (
   283 																	IriSP.config.gui.width,
   280 																	IriSP.config.gui.width,
   284 																	IriSP.config.gui.height,
   281 																	IriSP.config.gui.height,
   285 																	json.medias[0].href,
   282 																	json.medias[0].href,
   286 																	json.medias[0]['meta']['dc:duration'],
   283 																	json.medias[0]['meta']['dc:duration'],
   287 																	json.medias[0]['meta']['item']['value']);
   284 																	json.medias[0]['meta']['item']['value']);
   288 							
   285 							
   289 								// # CREATE THE FIRST LINE  				//
   286 								// # CREATE THE FIRST LINE  				//
   290 								IriSP.trace("__IriSP.init.main","__IriSP.Ligne");
   287 								IriSP.trace( "__IriSP.init.main","__IriSP.Ligne" );
   291 								IriSP.MyLdt = new __IriSP.Ligne (
   288 								IriSP.MyLdt = new __IriSP.Ligne(
   292 																	json['annotation-types'][0].id,
   289 																	json['annotation-types'][0].id,
   293 																	json['annotation-types'][0]['dc:title'],
   290 																	json['annotation-types'][0]['dc:title'],
   294 																	json['annotation-types'][0]['dc:description'],
   291 																	json['annotation-types'][0]['dc:description'],
   295 																	json.medias[0]['meta']['dc:duration']);			
   292 																	json.medias[0]['meta']['dc:duration']);			
   296 								
   293 								
   297 								// CREATE THE TAG CLOUD 					//
   294 								// CREATE THE TAG CLOUD 					//
   298 								IriSP.trace("__IriSP.init.main","__IriSP.Tags");
   295 								IriSP.trace( "__IriSP.init.main","__IriSP.Tags" );
   299 								IriSP.MyTags =  new __IriSP.Tags (json.tags);
   296 								IriSP.MyTags =  new __IriSP.Tags( json.tags );
   300 							
   297 							
   301 								// CREATE THE ANNOTATIONS  				    //
   298 								// CREATE THE ANNOTATIONS  				    //
   302 								// JUSTE FOR THE FIRST TYPE   			 	//
   299 								// JUSTE FOR THE FIRST TYPE   			 	//
   303 								IriSP.jQuery.each(json.annotations, function(i,item) {
   300 								IriSP.jQuery.each( json.annotations, function(i,item) {
   304 									if (item.meta['id-ref'] == IriSP.MyLdt.id) {
   301 									if (item.meta['id-ref'] == IriSP.MyLdt.id) {
   305 										//__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation");
   302 										//__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation");
   306 										IriSP.MyLdt.addAnnotation(
   303 										IriSP.MyLdt.addAnnotation(
   307 													item.id,
   304 													item.id,
   308 													item.begin,
   305 													item.begin,
   312 													item.content.description,
   309 													item.content.description,
   313 													item.content.color,
   310 													item.content.color,
   314 													item.tags);
   311 													item.tags);
   315 									}
   312 									}
   316 										//MyTags.addAnnotation(item);
   313 										//MyTags.addAnnotation(item);
   317 								});	
   314 								} );	
   318 								IriSP.jQuery.each(json.lists, function(i,item) {
   315 								IriSP.jQuery.each( json.lists, function(i,item) {
   319 									IriSP.trace("lists","");
   316 									IriSP.trace("lists","");
   320 								});	
   317 								} );	
   321 								IriSP.jQuery.each(json.views, function(i,item) {
   318 								IriSP.jQuery.each( json.views, function(i,item) {
   322 									IriSP.trace("views","");
   319 									IriSP.trace("views","");
   323 								});	
   320 								} );	
   324 							}
   321 							}
   325 							// END PARSING ----------------------- //  
   322 							// END PARSING ----------------------- //  
   326 						
   323 						
   327 										
   324 										
   328 					},error : function(data){
   325 					}, error : function(data){
   329 						  alert("ERROR : "+data);
   326 						  alert("ERROR : "+data);
   330 					}
   327 					}
   331 				  });	
   328 				  });	
   332 			
   329 			
   333 			
   330 			
   342 		var height = IriSP.config.gui.height;
   339 		var height = IriSP.config.gui.height;
   343 		var heightS = IriSP.config.gui.height-20;
   340 		var heightS = IriSP.config.gui.height-20;
   344 		
   341 		
   345 		// AUDIO  */
   342 		// AUDIO  */
   346 		// PB dans le html : ; 
   343 		// PB dans le html : ; 
   347 		IriSP.trace("__IriSP.createMyHtml",IriSP.config.gui.container);
   344 		IriSP.trace( "__IriSP.createMyHtml",IriSP.config.gui.container );
   348 
   345 
   349 		
   346 		
   350 		
   347 		/* FIXME : factor this in another file */
   351 		if(IriSP.config.gui.mode=="radio"){
   348 		if( IriSP.config.gui.mode=="radio" ){
   352 		
   349 		
   353 		IriSP.jQuery("#"+IriSP.config.gui.container).before(
   350 		IriSP.jQuery( "#"+IriSP.config.gui.container ).before(
   354 		"<div id='LdtSearchContainer'  style='margin-left:445px;position:absolute;'>\n"+
   351 		"<div id='LdtSearchContainer'  style='margin-left:445px;position:absolute;'>\n"+
   355 		"<div id='LdtSearch' style='display:none;background-color:#EEE;width:165px;boder:1px;border-color:#CFCFCF;position:absolute;text-align:center;'><input id='LdtSearchInput' style='margin-top:2px;margin-bottom:2px;' /></div>	\n"+
   352 		"<div id='LdtSearch' style='display:none;background-color:#EEE;width:165px;boder:1px;border-color:#CFCFCF;position:absolute;text-align:center;'><input id='LdtSearchInput' style='margin-top:2px;margin-bottom:2px;' /></div>	\n"+
   356 		"</div>\n"+
   353 		"</div>\n"+
   357 		" <div class='cleaner'></div>");
   354 		" <div class='cleaner'></div>");
   358 		IriSP.trace("__IriSP.createHtml",IriSP.config.gui.container);
   355 		IriSP.trace("__IriSP.createHtml",IriSP.config.gui.container);
   479 			IriSP.jQuery("#Ldt-output").hide();
   476 			IriSP.jQuery("#Ldt-output").hide();
   480 		}
   477 		}
   481 		
   478 		
   482 };
   479 };
   483 
   480 
   484 __IriSP.Media = function (id,url,duration,title,description){
   481 __IriSP.Media = function ( id, url, duration, title, description ) {
   485 		this.id 		 	= id;
   482 		this.id 		 	= id;
   486 		this.url 		= url;
   483 		this.url 		= url;
   487 		this.title 		= title;
   484 		this.title 		= title;
   488 		this.description = description;
   485 		this.description = description;
   489 		this.duration 	= duration;
   486 		this.duration 	= duration;
   490 		this.lignes 	  	= new Array();
   487 		this.lignes 	  	= new Array();
   491 
   488 
   492 		IriSP.trace("__IriSP.Media","Media ID : "+id);
   489 		IriSP.trace( "__IriSP.Media" , "Media ID : "+id);
   493 		IriSP.trace("__IriSP.Media","Media URL : "+url);
   490 		IriSP.trace( "__IriSP.Media" , "Media URL : "+url);
   494 		IriSP.trace("__IriSP.Media","Media title : "+title);
   491 		IriSP.trace( "__IriSP.Media" , "Media title : "+title);
   495 }
   492 };
   496 __IriSP.Media.prototype.createPlayerMedia = function (width,height,MyStreamer,MySwfPath){
   493 
   497 		IriSP.MyApiPlayer = new __IriSP.APIplayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
   494 __IriSP.Media.prototype.createPlayerMedia = function ( width, height, MyStreamer, MySwfPath) {
       
   495 		IriSP.MyApiPlayer = new __IriSP.APIplayer( width, height, this.url, this.duration, MyStreamer, MySwfPath);
   498 		//createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
   496 		//createPlayer(width,height,this.url,this.duration,MyStreamer,MySwfPath);
   499 }
   497 };
   500 __IriSP.Media.prototype.getMediaDuration = function (){
   498 
       
   499 __IriSP.Media.prototype.getMediaDuration = function () {
   501 		return (this.duration);
   500 		return (this.duration);
   502 }
   501 };
       
   502 
   503 __IriSP.Media.prototype.getMediaTitle = function (){
   503 __IriSP.Media.prototype.getMediaTitle = function (){
   504 		return (this.title);
   504 		return (this.title);
   505 }
   505 };
   506 
   506 
   507 
   507 
   508 
   508 
   509 /* 	INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON ()   */
   509 /* 	INTERFACE : SLIDER ( CONTROL BAR ) | BUTTON ()   */
   510 IriSP.createInterface = function(width,height,duration){
   510 IriSP.createInterface = function( width, height, duration ) {
   511 				
   511 		
   512 		IriSP.jQuery("#Ldt-controler").show();
   512 		IriSP.jQuery( "#Ldt-controler" ).show();
   513 		//__IriSP.jQuery("#Ldt-Root").css('display','visible');
   513 		//__IriSP.jQuery("#Ldt-Root").css('display','visible');
   514 		IriSP.trace("__IriSP.createInterface",width+","+height+","+duration+",");
   514 		IriSP.trace( "__IriSP.createInterface" , width+","+height+","+duration+"," );
   515 		
   515 		
   516 		IriSP.jQuery("#Ldt-ShowAnnotation").click(function () { 
   516 		IriSP.jQuery( "#Ldt-ShowAnnotation").click( function () { 
   517 			 //__IriSP.jQuery(this).slideUp(); 
   517 			 //__IriSP.jQuery(this).slideUp(); 
   518 		});
   518 		} );
   519 
   519 
   520 		var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
   520 		var LdtpPlayerY = IriSP.jQuery("#Ldt-PlaceHolder").attr("top");
   521 		var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
   521 		var LdtpPlayerX = IriSP.jQuery("#Ldt-PlaceHolder").attr("left");
   522 		IriSP.jQuery("#slider-range-min").slider({ //range: "min",
   522 		
       
   523 		IriSP.jQuery( "#slider-range-min" ).slider( { //range: "min",
   523 			value: 0,
   524 			value: 0,
   524 			min: 1,
   525 			min: 1,
   525 			max: duration/1000,//1:54:52.66 = 3600+3240+
   526 			max: duration/1000,//1:54:52.66 = 3600+3240+
   526 			step: 0.1,
   527 			step: 0.1,
   527 			slide: function(event, ui) {
   528 			slide: function(event, ui) {
   530 				//player.sendEvent('SEEK', ui.value)
   531 				//player.sendEvent('SEEK', ui.value)
   531 				IriSP.MyApiPlayer.seek(ui.value);
   532 				IriSP.MyApiPlayer.seek(ui.value);
   532 				//changePageUrlOffset(ui.value);
   533 				//changePageUrlOffset(ui.value);
   533 				//player.sendEvent('PAUSE')
   534 				//player.sendEvent('PAUSE')
   534 			}
   535 			}
   535 		});
   536 		} );
       
   537 		
   536 		IriSP.trace("__IriSP.createInterface","ICI");
   538 		IriSP.trace("__IriSP.createInterface","ICI");
   537 		IriSP.jQuery("#amount").val(IriSP.jQuery("#slider-range-min").slider("value")+" s");
   539 		IriSP.jQuery("#amount").val(IriSP.jQuery("#slider-range-min").slider("value")+" s");
   538 		IriSP.jQuery(".Ldt-Control1 button:first").button({
   540 		IriSP.jQuery(".Ldt-Control1 button:first").button({
   539 			icons: {
   541 			icons: {
   540 				primary: 'ui-icon-play'
   542 				primary: 'ui-icon-play'
   560 		});
   562 		});
   561 
   563 
   562 		// /!\ PB A MODIFIER 
   564 		// /!\ PB A MODIFIER 
   563 		//__IriSP.MyTags.draw();
   565 		//__IriSP.MyTags.draw();
   564 		IriSP.trace("__IriSP.createInterface","ICI2");
   566 		IriSP.trace("__IriSP.createInterface","ICI2");
   565 		IriSP.jQuery("#ldt-CtrlPlay").attr("style","background-color:#CD21C24;");
   567 		IriSP.jQuery( "#ldt-CtrlPlay" ).attr( "style", "background-color:#CD21C24;" );
   566 		
   568 		
   567 		IriSP.jQuery("#Ldt-load-container").hide();
   569 		IriSP.jQuery( "#Ldt-load-container" ).hide();
   568 		
   570 		
   569 		if(IriSP.config.gui.mode=="radio" & IriSP.jQuery.browser.msie!=true){
   571 		if( IriSP.config.gui.mode=="radio" & IriSP.jQuery.browser.msie != true ) {
   570 			IriSP.jQuery("#Ldtplayer1").attr("height","0");
   572 			IriSP.jQuery( "#Ldtplayer1" ).attr( "height", "0" );
   571 		}
   573 		}
   572 		IriSP.trace("__IriSP.createInterface","3");
   574 		IriSP.trace( "__IriSP.createInterface" , "3" );
   573 
   575 
   574 		IriSP.trace("__IriSP.createInterface","END");
   576 		IriSP.trace( "__IriSP.createInterface", "END" );
   575 		
   577 		
   576 	}
   578 	};
   577 
   579 
   578 
   580 
   579 
   581 
   580 /*  API player - work in progress ... need refactoring of code */ 
   582 /*  FIXME : API player - work in progress ... need refactoring of code */ 
   581 __IriSP.APIplayer = function (width,height,url,duration,streamerPath,MySwfPath){
   583 __IriSP.APIplayer = function ( width, height, url, duration, streamerPath, MySwfPath){
   582 		
   584 		
   583 		
   585 		
   584 		this.player 			= null;
   586 		this.player 			= null;
   585 		this.hashchangeUpdate 	= null;
   587 		this.hashchangeUpdate 	= null;
   586 		
   588 		
   591 		this.streamerPath		= streamerPath;
   593 		this.streamerPath		= streamerPath;
   592 		this.MySwfPath			= MySwfPath;
   594 		this.MySwfPath			= MySwfPath;
   593 		
   595 		
   594 		IriSP.MyApiPlayer		= this;
   596 		IriSP.MyApiPlayer		= this;
   595 		
   597 		
   596 		IriSP.createPlayer(this.url,this.streamerPath);
   598 		IriSP.createPlayer( this.url, this.streamerPath );
   597 		IriSP.trace("__IriSP.APIplayer","__IriSP.createPlayer");
   599 		IriSP.trace( "__IriSP.APIplayer", "__IriSP.createPlayer" );
   598 	
   600 	
   599 	//__IriSP.config.player
   601 	//__IriSP.config.player
   600 	/*
   602 	/*
   601 	- dailymotion  // &enableApi=1&chromeless=1
   603 	- dailymotion  // &enableApi=1&chromeless=1
   602 	- youtube 
   604 	- youtube 
   603 	- html5
   605 	- html5
   604 	- flowplayer 
   606 	- flowplayer 
   605 	- jwplayer
   607 	- jwplayer
   606 	*/
   608 	*/
   607 		
   609 		
   608 }
   610 };
   609 __IriSP.APIplayer.prototype.ready = function(player){
   611 
       
   612 __IriSP.APIplayer.prototype.ready = function( player ) {
   610 
   613 
   611 	//__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface");
   614 	//__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady"," __IriSP.createInterface");
   612 	IriSP.createInterface(this.width,this.height,this.duration);
   615 	IriSP.createInterface( this.width, this.height, this.duration );
   613 	//__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady","END  __IriSP.createInterface");
   616 	//__IriSP.trace("__IriSP.APIplayer.prototype.APIpReady","END  __IriSP.createInterface");
   614 
   617 
   615 	// hashchange EVENT
   618 	// hashchange EVENT
   616 	if (window.addEventListener){
   619 	if ( window.addEventListener ){
   617 	
   620 	
   618 	// pour FIREFOX  hashchange EVENT
   621 	// for firefox  hashchange EVENT
   619 		window.addEventListener("hashchange", function() {
   622 		window.addEventListener( "hashchange", function() {
   620 		  var url = window.location.href;
   623 		  var url = window.location.href;
   621 		  var time = IriSP.retrieveTimeFragment(url);
   624 		  var time = IriSP.retrieveTimeFragment( url );
   622 		  IriSP.trace("__IriSP.APIplayer.prototype.ready",time);
   625 		  IriSP.trace( "__IriSP.APIplayer.prototype.ready", time );
   623 		  if(IriSP.MyApiPlayer.hashchangeUpdate==null){
   626 		  if( IriSP.MyApiPlayer.hashchangeUpdate==null ){
       
   627 			IriSP.MyApiPlayer.seek( time );
       
   628 			
       
   629 		  } else {			  
       
   630 			IriSP.MyApiPlayer.hashchangeUpdate = null;
       
   631 		  }
       
   632 		}, false );
       
   633 	 
       
   634 	} else if (window.attachEvent){
       
   635 	// for ie hashchange EVENT
       
   636 		window.attachEvent( "onhashchange", function() {
       
   637 		  IriSP.trace( "hashchange",time );
       
   638 		  var url = window.location.href;
       
   639 		  var time = IriSP.retrieveTimeFragment( url );
       
   640 		  if( IriSP.MyApiPlayer.hashchangeUpdate == null ){
   624 			IriSP.MyApiPlayer.seek(time);
   641 			IriSP.MyApiPlayer.seek(time);
   625 			
   642 		  } else {
   626 		  }else{
   643 			IriSP.MyApiPlayer.hashchangeUpdate = null;
   627 			IriSP.MyApiPlayer.hashchangeUpdate=null;
       
   628 		  }
       
   629 		}, false);
       
   630 	 
       
   631 	} 
       
   632 	else if (window.attachEvent){
       
   633 	// FOR IE hashchange EVENT
       
   634 	
       
   635 		window.attachEvent("onhashchange", function() {
       
   636 		  IriSP.trace("hashchange",time);
       
   637 		  var url = window.location.href;
       
   638 		  var time = IriSP.retrieveTimeFragment(url);
       
   639 		  if(IriSP.MyApiPlayer.hashchangeUpdate==null){
       
   640 			IriSP.MyApiPlayer.seek(time);
       
   641 		  }else{
       
   642 			IriSP.MyApiPlayer.hashchangeUpdate=null;
       
   643 		  }
   644 		  }
   644 		}, false);
   645 		}, false);
   645 	}
   646 	}
   646 	
   647 	
   647 	// Search
   648 	// Search
   648 	//__IriSP.jQuery("#LdtSearchInput").change(function() {__IriSP.Search(this.value);});
   649 	//__IriSP.jQuery("#LdtSearchInput").change(function() {__IriSP.Search(this.value);});
   649 	//__IriSP.jQuery("#LdtSearchInput").live('change', function(event) {__IriSP.Search(this.value);}); 
   650 	//__IriSP.jQuery("#LdtSearchInput").live('change', function(event) {__IriSP.Search(this.value);}); 
   650 	IriSP.jQuery("#LdtSearchInput").keydown(function() {IriSP.Search(this.value);});
   651 	IriSP.jQuery( "#LdtSearchInput" ).keydown( function() { IriSP.Search( this.value );} );
   651 	IriSP.jQuery("#LdtSearchInput").keyup(function() {IriSP.Search(this.value);});
   652 	IriSP.jQuery("#LdtSearchInput").keyup( function() { IriSP.Search( this.value );} );
   652 	
   653 	
   653 }
   654 };
       
   655 
   654 __IriSP.APIplayer.prototype.pause = function(){
   656 __IriSP.APIplayer.prototype.pause = function(){
   655 	this.hashchangeUpdate = true;
   657 	this.hashchangeUpdate = true;
   656 	IriSP.player.sendEvent('PAUSE');
   658 	IriSP.player.sendEvent( 'PAUSE' );
   657 }
   659 };
   658 __IriSP.APIplayer.prototype.play  = function(){
   660 
       
   661 __IriSP.APIplayer.prototype.play  = function() {
   659 	this.hashchangeUpdate = true;
   662 	this.hashchangeUpdate = true;
   660 	//__IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type);
   663 	//__IriSP.trace("__IriSP.config.player.type",__IriSP.config.player.type);
   661 	if(IriSP.config.player.type=='jwplayer'){
   664 	if( IriSP.config.player.type=='jwplayer' ){
   662 	
   665 	
   663 		IriSP.player.sendEvent('PLAY');
   666 		IriSP.player.sendEvent( 'PLAY' );
   664 		
   667 		
   665 	} else if(IriSP.config.player.type=='dailymotion' 
   668 	} else if(IriSP.config.player.type == 'dailymotion' 
   666 			  || IriSP.config.player.type=='youtube') {
   669 			  || IriSP.config.player.type == 'youtube' ) {
   667 			  
   670 			  
   668 		var status = IriSP.player.getPlayerState();
   671 		var status = IriSP.player.getPlayerState();
   669 		IriSP.trace("__IriSP.APIplayer.prototype.play.status",status);
   672 		IriSP.trace( "__IriSP.APIplayer.prototype.play.status", status);
   670 		if (status!=1){
   673 		if ( status != 1 ){
   671 			IriSP.player.playVideo();
   674 			IriSP.player.playVideo();
   672 		}else{
   675 		} else {
   673 			IriSP.player.pauseVideo();
   676 			IriSP.player.pauseVideo();
   674 		}
   677 		}
   675 	}
   678 	}
   676 }
   679 };
   677 __IriSP.APIplayer.prototype.mute  = function(){
   680 
   678 	IriSP.player.sendEvent('MUTE');
   681 __IriSP.APIplayer.prototype.mute  = function() {
       
   682 	IriSP.player.sendEvent( 'MUTE' );
   679 	
   683 	
   680 	//alert(__IriSP.jQuery(".ui-icon-volume-on").css("background-position-x"));
   684 	//alert(__IriSP.jQuery(".ui-icon-volume-on").css("background-position-x"));
   681 	if (IriSP.jQuery(".ui-icon-volume-on").css("background-position")=="-144px -160px"){
   685 	/* FIXME : remove hardcoded values */
   682 		IriSP.jQuery(".ui-icon-volume-on").css("background-position","-130px -160px");
   686 	if ( IriSP.jQuery( ".ui-icon-volume-on" ).css( "background-position" ) == "-144px -160px" ){
       
   687 		IriSP.jQuery(" .ui-icon-volume-on ").css(" background-position ", "-130px -160px");
   683 	} else {
   688 	} else {
   684 		IriSP.jQuery(".ui-icon-volume-on").css("background-position","-144px -160px");
   689 		IriSP.jQuery( ".ui-icon-volume-on" ).css( "background-position", "-144px -160px" );
   685 	}
   690 	}
   686 }
   691 };
   687 __IriSP.APIplayer.prototype.share = function(network){
   692 
   688 
   693 /* FIXME : rename */
   689 	var MyMessage = encodeURIComponent("J'écoute Les Retours du Dimanche : ");
   694 __IriSP.APIplayer.prototype.share = function( network ) {
       
   695 
       
   696 	/* FIXME : remove hardcoded */
       
   697 	var MyMessage = encodeURIComponent( "J'écoute Les Retours du Dimanche : " );
   690 	var MyURLNow = window.location.href;
   698 	var MyURLNow = window.location.href;
   691 	var shareURL;
   699 	var shareURL = null;
   692 	//alert(network+" : "+MyURLNow);
   700 	//alert(network+" : "+MyURLNow);
   693 	
   701 	
       
   702 	/* FIXME : use a sharing library */
   694 	if(network == "facebook"){
   703 	if(network == "facebook"){
   695 			shareURL = "http://www.facebook.com/share.php?u=";			
   704 			shareURL = "http://www.facebook.com/share.php?u=";			
   696 		}else if(network == "twitter"){
   705 		}else if(network == "twitter"){
   697 			shareURL  = "http://twitter.com/home?status="+MyMessage;	
   706 			shareURL  = "http://twitter.com/home?status="+MyMessage;	
   698 		}else if(network == "myspace"){
   707 		}else if(network == "myspace"){
   702 		}else if(network == "JameSpot"){
   711 		}else if(network == "JameSpot"){
   703 			shareURL = "http://www.jamespot.com/?action=spotit&u=";
   712 			shareURL = "http://www.jamespot.com/?action=spotit&u=";
   704 			//alert(network+" non actif pour l'instant : "+MyURLNow);
   713 			//alert(network+" non actif pour l'instant : "+MyURLNow);
   705 	}
   714 	}
   706 	
   715 	
   707 	window.open(shareURL+encodeURIComponent(MyURLNow));
   716 	if (shareURL != null)
       
   717 		window.open( shareURL+encodeURIComponent(MyURLNow) );
   708 	//window.location.href = shareURL+encodeURIComponent(MyURLNow);
   718 	//window.location.href = shareURL+encodeURIComponent(MyURLNow);
   709 }
   719 };
   710 __IriSP.APIplayer.prototype.seek  = function (time){
   720 
   711 	if(time==0){time=1}
   721 __IriSP.APIplayer.prototype.seek = function (time) {
   712 	IriSP.trace("__IriSP.APIplayer.prototype.seek",time);
   722 	
   713 	if(IriSP.config.player.type=='jwplayer'){
   723 	if( time==0 ) { time=1; }
       
   724 	
       
   725 	IriSP.trace( "__IriSP.APIplayer.prototype.seek", time );
       
   726 	
       
   727 	if( IriSP.config.player.type=='jwplayer') {
   714 		//__IriSP.MyApiPlayer.play()
   728 		//__IriSP.MyApiPlayer.play()
   715 		IriSP.player.sendEvent('SEEK', time);
   729 		IriSP.player.sendEvent( 'SEEK', time );
   716 	} else if(IriSP.config.player.type=='dailymotion'
   730 	} else if( IriSP.config.player.type=='dailymotion'
   717 			|| IriSP.config.player.type=='youtube') {
   731 			|| IriSP.config.player.type=='youtube' ) {
   718 		IriSP.player.seekTo(time);
   732 		IriSP.player.seekTo( time );
   719 	}
   733 	}
   720 	this.changePageUrlOffset(time);
   734 	
   721 }	
   735 	this.changePageUrlOffset( time );
   722 __IriSP.APIplayer.prototype.update = function (time){
   736 };
   723 	if(time!=0){
   737 
   724 	this.hashchangeUpdate = true;
   738 __IriSP.APIplayer.prototype.update = function (time) {
   725 	IriSP.trace("__IriSP.APIplayer.prototype.update",time);
   739 	
   726 	IriSP.player.sendEvent('SEEK', time);
   740 	if( time != 0 ) {
   727 	}
   741 		this.hashchangeUpdate = true;
   728 }
   742 		
   729 __IriSP.APIplayer.prototype.changePageUrlOffset = function (time) {
   743 		IriSP.trace( "__IriSP.APIplayer.prototype.update" ,time);
       
   744 		IriSP.player.sendEvent( 'SEEK', time );
       
   745 	}
       
   746 };
       
   747 
       
   748 __IriSP.APIplayer.prototype.changePageUrlOffset = function ( time ) {
   730 	//alert(time);
   749 	//alert(time);
   731   IriSP.trace("__IriSP.APIplayer.prototype.changePageUrlOffset","CHANGE URL "+time);
   750   IriSP.trace( "__IriSP.APIplayer.prototype.changePageUrlOffset" , "CHANGE URL "+ time);
   732   
   751   
   733   window.location.hash = "#t=" + time;
   752   window.location.hash = "#t=" + time;
   734   window.location.href =  window.location.href;
   753   window.location.href =  window.location.href;
   735   
   754   
   736 }
   755 };
   737 
   756 
   738 /* MEDIA FRAGMENT FUNCTION by Silvia Pfeiffer */ 
   757 /* Media Fragment functionality by Silvia Pfeiffer */ 
   739 
   758 
   740 IriSP.jumpToTimeoffset = function (form) {
   759 IriSP.jumpToTimeoffset = function ( form ) {
   741 	var time = form.time.value;
   760 	var time = form.time.value;
   742 	IriSP.MyApiPlayer.changePageUrlOffset(time);
   761 	IriSP.MyApiPlayer.changePageUrlOffset( time );
   743 }
   762 };
   744 IriSP.retrieveTimeFragment = function (url) {
   763 
       
   764 IriSP.retrieveTimeFragment = function ( url ) {
   745   var pageoffset = 0;
   765   var pageoffset = 0;
   746   var offsettime = 0;
   766   var offsettime = 0;
   747   
   767   
   748   if (url.split("#")[1] != null) {
   768   if ( url.split("#")[1] != null ) {
   749 	pageoffset = url.split("#")[1];
   769 	pageoffset = url.split( "#" )[1];
   750 		if (pageoffset.substring(2) != null) {
   770 		if ( pageoffset.substring( 2 ) != null ) {
   751 			offsettime = pageoffset.substring(2);
   771 			offsettime = pageoffset.substring( 2 );
   752 		}
   772 		}
   753 	}
   773 	}
   754 	return offsettime;
   774 	return offsettime;
   755 }  
   775 };
   756 IriSP.ignoreTimeFragment = function(url){
   776 
   757  if (url.split("#")[1] != null) {
   777 IriSP.ignoreTimeFragment = function( url ){
   758 	var pageurl= url.split("#")[0];
   778 
   759  }
   779 	var pageurl = url;
   760  return pageurl;
   780 	
   761 }
   781 	if ( url.split( "#" )[1] != null ) {
   762 
   782 		pageurl = url.split( "#" )[0];
   763 
   783 	}
   764 /* CODE SPECIAL JW PLAYER  creation + listener */
   784  
       
   785 	return pageurl;
       
   786 };
       
   787 
       
   788 
       
   789 /* code specific to jwplayer / creation and listener */
   765 
   790 
   766 IriSP.currentPosition 	= 0; 
   791 IriSP.currentPosition 	= 0; 
   767 IriSP.currentVolume   	= 50; 
   792 IriSP.currentVolume   	= 50; 
   768 IriSP.player 				= null;
   793 IriSP.player 			= null;
   769 IriSP.startPosition 		= null;
   794 IriSP.startPosition 	= null;
   770 IriSP.firstplay	 		= false;
   795 IriSP.firstplay	 		= false;
   771 
   796 
   772 
   797 
   773 
   798 
   774 IriSP.createPlayer = function (url,streamerPath) {
   799 IriSP.createPlayer = function ( url, streamerPath ) {
   775 
   800 	if( IriSP.config.player.type=='dailymotion' ) {
   776 
       
   777 	if(IriSP.config.player.type=='dailymotion'){
       
   778 		IriSP.config.player.src = IriSP.config.player.src+"&chromeless=1&enableApi=1";
   801 		IriSP.config.player.src = IriSP.config.player.src+"&chromeless=1&enableApi=1";
   779 	} else if (IriSP.config.player.type=='youtube'){
   802 	} else if ( IriSP.config.player.type=='youtube' ){
   780 		IriSP.config.player.src = IriSP.config.player.src+"&enablejsapi=1&version=3";
   803 		IriSP.config.player.src = IriSP.config.player.src+"&enablejsapi=1&version=3";
   781 	}
   804 	}
   782 	
   805 	
   783 	IriSP.trace("__IriSP.createPlayer","start");			
   806 	IriSP.trace( "__IriSP.createPlayer", "start" );			
   784 	
   807 	
   785 	IriSP.myUrlFragment = url.split(streamerPath);	
   808 	IriSP.myUrlFragment = url.split( streamerPath );	
   786 	
   809 	
   787 	var configTemp = IriSP.jQuery.extend(true, {}, IriSP.config);
   810 	var configTemp = IriSP.jQuery.extend( true, {}, IriSP.config );
   788 	configTemp.player.flashvars.autostart =	"true";
   811 	configTemp.player.flashvars.autostart =	"true";
   789 	configTemp.player.flashvars.streamer =	streamerPath;
   812 	configTemp.player.flashvars.streamer =	streamerPath;
   790 	configTemp.player.flashvars.file =	IriSP.myUrlFragment[1];
   813 	configTemp.player.flashvars.file =	IriSP.myUrlFragment[1];
   791 	
   814 	
   792 	var flashvars 		  = configTemp.player.flashvars;
   815 	var flashvars 		  = configTemp.player.flashvars;
   804 	swfobject.embedSWF(
   827 	swfobject.embedSWF(
   805 						IriSP.config.player.src,
   828 						IriSP.config.player.src,
   806 						"Ldt-PlaceHolder",
   829 						"Ldt-PlaceHolder",
   807 						IriSP.config.gui.width,
   830 						IriSP.config.gui.width,
   808 						IriSP.config.gui.height,
   831 						IriSP.config.gui.height,
   809 						"9.0.115",
   832 						"9.0.115", // FIXME : de-hardcode version ?
   810 						false,
   833 						false,
   811 						flashvars,
   834 						flashvars,
   812 						params,
   835 						params,
   813 						attributes
   836 						attributes
   814 					);
   837 					);
   815 	
   838 	
   816 	// need a methode to 
   839 	// need a methode to 
   817 	// re execute if this swf call does'nt work 
   840 	// re execute if this swf call does'nt work 
   818 }
   841 };
   819 
   842 
   820 
   843 
   821 /* API JW PLAYER 	*/
   844 /* jw player api */
   822 IriSP.playerReady  = function (thePlayer) {
   845 IriSP.playerReady  = function (thePlayer) {
   823 
   846 
   824 	//__IriSP.trace("__IriSP.playerReady","PLAYER READY !!!!!!!!!!!!");
   847 	//__IriSP.trace("__IriSP.playerReady","PLAYER READY !!!!!!!!!!!!");
   825 	IriSP.player = window.document[thePlayer.id];
   848 	IriSP.player = window.document[thePlayer.id];
   826 	//__IriSP.trace("__IriSP.playerReady","API CALL "+__IriSP.player);
   849 	//__IriSP.trace("__IriSP.playerReady","API CALL "+__IriSP.player);
   827 	IriSP.MyApiPlayer.ready(IriSP.player);
   850 	IriSP.MyApiPlayer.ready( IriSP.player );
   828 	//__IriSP.trace("__IriSP.playerReady","API CALL END ");
   851 	//__IriSP.trace("__IriSP.playerReady","API CALL END ");
   829 	
   852 	
   830 	var url = document.location.href;
   853 	var url = document.location.href;
   831 	var time = IriSP.retrieveTimeFragment(url);
   854 	var time = IriSP.retrieveTimeFragment( url );
   832 	//__IriSP.trace("__IriSP.playerReady"," "+url+" "+time );
   855 	//__IriSP.trace("__IriSP.playerReady"," "+url+" "+time );
   833 	IriSP.startPosition = time;
   856 	IriSP.startPosition = time;
   834 	//__IriSP.trace("__IriSP.playerReady"," LISTENER LAUCHER");
   857 	//__IriSP.trace("__IriSP.playerReady"," LISTENER LAUCHER");
   835 	IriSP.addListeners();	
   858 	IriSP.addListeners();	
   836 	//__IriSP.trace("__IriSP.playerReady"," LISTENER END");
   859 	//__IriSP.trace("__IriSP.playerReady"," LISTENER END");
   837 	
   860 	
   838 }
   861 };
       
   862 
   839 IriSP.addListeners = function () {
   863 IriSP.addListeners = function () {
   840 	if (IriSP.player) { 
   864 	if ( IriSP.player ) { 
   841 		IriSP.trace("__IriSP.addListeners","ADD  Listener ");
   865 		IriSP.trace("__IriSP.addListeners","ADD  Listener ");
   842 		IriSP.player.addModelListener("TIME", "__IriSP.positionListener");
   866 		IriSP.player.addModelListener( "TIME", "__IriSP.positionListener");
   843 		IriSP.player.addControllerListener("VOLUME", "__IriSP.volumeListener");
   867 		IriSP.player.addControllerListener( "VOLUME", "__IriSP.volumeListener" );
   844 		IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor');
   868 		IriSP.player.addModelListener( 'STATE', '__IriSP.stateMonitor' );
   845 	} else {
   869 	} else {
   846 		IriSP.setTimeout("__IriSP.addListeners()",100);
   870 		IriSP.setTimeout( "__IriSP.addListeners()", 100 );
   847 	}
   871 	}
   848 
   872 
   849 	// et changer les boutons
   873 	// et changer les boutons
   850 }
   874 };
   851 IriSP.stateMonitor = function (obj) { 
   875 
   852 
   876 IriSP.stateMonitor = function ( obj ) { 
   853 	 if(obj.newstate == 'PAUSED')
   877 
   854     {
   878 	 if(obj.newstate == 'PAUSED') {
   855 		IriSP.trace("__IriSP.stateMonitor","PAUSE");
   879 		IriSP.trace( "__IriSP.stateMonitor", "PAUSE" );
   856 		IriSP.MyApiPlayer.changePageUrlOffset(IriSP.currentPosition);			
   880 		IriSP.MyApiPlayer.changePageUrlOffset( IriSP.currentPosition );			
   857 		IriSP.jQuery(".ui-icon-play").css("background-position","0px -160px");
   881 		IriSP.jQuery( ".ui-icon-play" ).css( "background-position","0px -160px" );
   858 		
   882 		
   859 	} else if (obj.newstate == 'PLAYING'){
   883 	} else if (obj.newstate == 'PLAYING' ){
   860 		
   884 		
   861 		IriSP.trace("__IriSP.stateMonitor","PLAYING "+IriSP.startPosition );
   885 		IriSP.trace( "__IriSP.stateMonitor", "PLAYING "+IriSP.startPosition );
   862 		
   886 		
   863 		// forcer le buffering mais stop du player si dans config 
   887 		// force buffering even if autostart is disabled. 
   864 		if (IriSP.config.player.flashvars.autostart=="false" && IriSP.firstplay==false && IriSP.startPosition == 0){
   888 		if ( IriSP.config.player.flashvars.autostart == "false" && IriSP.firstplay == false && IriSP.startPosition == 0 ) {
   865 			IriSP.trace("__IriSP.stateMonitor","first stop ???");
   889 			IriSP.trace("__IriSP.stateMonitor","first stop ???");
   866 			IriSP.MyApiPlayer.play();
   890 			IriSP.MyApiPlayer.play();
   867 			IriSP.firstplay = true;
   891 			IriSP.firstplay = true;
   868 			IriSP.MyLdt.checkTime(1);
   892 			IriSP.MyLdt.checkTime( 1 );
   869 		}
   893 		}
   870 		
   894 		
   871 		// une fois la video prete a lire  la déplacer au bon timecode 
   895 		// once that the video is loaded, move it to the correct timecode
   872 		if(IriSP.startPosition!=null){
   896 		if( IriSP.startPosition!=null ){
   873 			IriSP.MyApiPlayer.update(IriSP.startPosition);
   897 			IriSP.MyApiPlayer.update( IriSP.startPosition );
   874 			IriSP.startPosition = null;
   898 			IriSP.startPosition = null;
   875 		}
   899 		}
   876 		
   900 		
   877 		
   901 		
   878 		IriSP.jQuery(".ui-icon-play").css("background-position","-16px -160px");
   902 		IriSP.jQuery( ".ui-icon-play" ).css( "background-position", "-16px -160px" );
   879 	} else if (obj.newstate == 'BUFFERING'){
   903 	} else if (obj.newstate == 'BUFFERING'){
   880 		IriSP.trace("__IriSP.stateMonitor","BUFFERING : "+IriSP.config.player.flashvars.autostart);
   904 		IriSP.trace( "__IriSP.stateMonitor", "BUFFERING : "+IriSP.config.player.flashvars.autostart );
   881 		//changePageUrlOffset(currentPosition);
   905 		//changePageUrlOffset(currentPosition);
   882 	}
   906 	}
   883 	
   907 	
   884 }
   908 };
       
   909 
   885 IriSP.positionListener = function(obj) { 
   910 IriSP.positionListener = function(obj) { 
   886 	//__IriSP.trace("__IriSP.positionListener",obj.position);
   911 	//__IriSP.trace("__IriSP.positionListener",obj.position);
   887 	IriSP.currentPosition = obj.position; 
   912 	IriSP.currentPosition = obj.position; 
   888 	var tmp = document.getElementById("posit");
   913 	var tmp = document.getElementById( "posit" );
   889 	if (tmp) { tmp.innerHTML = "position: " + IriSP.currentPosition; }
   914 	if (tmp) { tmp.innerHTML = "position: " + IriSP.currentPosition; }
   890 	IriSP.jQuery("#slider-range-min").slider("value", obj.position);
   915 	IriSP.jQuery( "#slider-range-min" ).slider( "value", obj.position);
   891 	IriSP.jQuery("#amount").val(obj.position+" s");
   916 	IriSP.jQuery( "#amount" ).val(obj.position+" s");
   892 	// afficher annotation 
   917 	// display annotation 
   893 	IriSP.MyLdt.checkTime(IriSP.currentPosition);
   918 	IriSP.MyLdt.checkTime( IriSP.currentPosition );
   894 	
   919 	
   895 }
   920 };
       
   921 
   896 IriSP.volumeListener   = function (obj) { 
   922 IriSP.volumeListener   = function (obj) { 
   897 	IriSP.currentVolume = obj.percentage; 
   923 	IriSP.currentVolume = obj.percentage; 
   898 	var tmp = document.getElementById("vol");
   924 	var tmp = document.getElementById("vol");
   899 	if (tmp) { tmp.innerHTML = "volume: " + IriSP.currentVolume; }
   925 	if (tmp) { tmp.innerHTML = "volume: " + IriSP.currentVolume; }
   900 }	
   926 };
   901 
   927 
   902 
   928 
   903 /* API DAILYMOTION 	*/
   929 /* dailymotion api 	*/
   904 onDailymotionPlayerReady = function (playerid){
   930 onDailymotionPlayerReady = function (playerid) {
   905 
   931 
   906 	//alert(playerid);
   932 	//alert(playerid);
   907 	IriSP.player = document.getElementById(IriSP.config.player.attributes.id);
   933 	IriSP.player = document.getElementById( IriSP.config.player.attributes.id );
   908 	IriSP.MyApiPlayer.ready(IriSP.player);
   934 	IriSP.MyApiPlayer.ready( IriSP.player );
   909 	
   935 	
   910 	var url = document.location.href;
   936 	var url = document.location.href;
   911 	var time = IriSP.retrieveTimeFragment(url);
   937 	var time = IriSP.retrieveTimeFragment( url );
   912 	IriSP.startPosition = time;
   938 	IriSP.startPosition = time;
   913 	IriSP.DailymotionAddListeners();	
   939 	IriSP.DailymotionAddListeners();	
   914 	
   940 	
   915 	IriSP.MyApiPlayer.ready(playerid);
   941 	IriSP.MyApiPlayer.ready(playerid);
   916 }
   942 };
       
   943 
   917 IriSP.DailymotionAddListeners = function () {
   944 IriSP.DailymotionAddListeners = function () {
   918 	if (IriSP.player) { 
   945 	if ( IriSP.player ) { 
   919 		IriSP.trace("__IriSP.addListeners","ADD  Listener ");
   946 		IriSP.trace( "__IriSP.addListeners","ADD  Listener " );
   920 		//__IriSP.player.addEventListener("onStateChange", "__IriSP.DailymotionPositionListener");
   947 		//__IriSP.player.addEventListener("onStateChange", "__IriSP.DailymotionPositionListener");
   921 		setTimeout("__IriSP.DailymotionPositionListener()",100);
   948 		setTimeout( "__IriSP.DailymotionPositionListener()", 100);
   922 		IriSP.DailymotionPositionListener();
   949 		IriSP.DailymotionPositionListener();
   923 		IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener");
   950 		IriSP.player.addModelListener( "VOLUME", "__IriSP.volumeListener" );
   924 		//__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor');
   951 		//__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor');
   925 	} else {
   952 	} else {
   926 		IriSP.setTimeout("__IriSP.DailymotionAddListeners()",100);
   953 		IriSP.setTimeout( "__IriSP.DailymotionAddListeners()", 100);
   927 	}
   954 	}
   928 }
   955 };
       
   956 
   929 IriSP.DailymotionPositionListener = function() { 
   957 IriSP.DailymotionPositionListener = function() { 
   930 	
   958 	
   931 	IriSP.currentPosition = IriSP.player.getCurrentTime();
   959 	IriSP.currentPosition = IriSP.player.getCurrentTime();
   932 	//__IriSP.trace("__IriSP.DailymotionPositionListener",__IriSP.currentPosition);
   960 	//__IriSP.trace("__IriSP.DailymotionPositionListener",__IriSP.currentPosition);
   933 	//__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition);
   961 	//__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition);
   934 	
   962 	
   935 	IriSP.jQuery("#slider-range-min").slider("value",IriSP.currentPosition);
   963 	IriSP.jQuery( "#slider-range-min" ).slider( "value" , IriSP.currentPosition);
   936 	IriSP.jQuery("#amount").val(IriSP.currentPosition+" s");
   964 	IriSP.jQuery( "#amount" ).val( IriSP.currentPosition+" s" );
   937 	// afficher annotation 
   965 	// afficher annotation 
   938 	/*__IriSP.MyLdt.checkTime(__IriSP.currentPosition);
   966 	/*__IriSP.MyLdt.checkTime(__IriSP.currentPosition);
   939 	*/
   967 	*/
   940 	
   968 	
   941 	setTimeout("__IriSP.DailymotionPositionListener()",10);
   969 	setTimeout( "__IriSP.DailymotionPositionListener()", 10 );
   942 }
   970 };
   943 
   971 
   944 /* API YOUTUBE 	*/
   972 /* youtube api 	*/
   945 onYouTubePlayerReady= function (playerid){
   973 onYouTubePlayerReady= function (playerid){
   946 
   974 
   947 	var url = document.location.href;
   975 	var url = document.location.href;
   948 	var time = IriSP.retrieveTimeFragment(url);
   976 	var time = IriSP.retrieveTimeFragment( url );
   949 	IriSP.player = document.getElementById(IriSP.config.player.attributes.id);
   977 	IriSP.player = document.getElementById( IriSP.config.player.attributes.id );
   950 	IriSP.startPosition = time;
   978 	IriSP.startPosition = time;
   951 	
   979 	
   952 	IriSP.MyApiPlayer.ready(IriSP.player);
   980 	IriSP.MyApiPlayer.ready( IriSP.player );
   953 	
   981 	
   954 	IriSP.MyApiPlayer.seek(time);
   982 	IriSP.MyApiPlayer.seek( time );
   955 	IriSP.MyApiPlayer.play();
   983 	IriSP.MyApiPlayer.play();
   956 	
   984 	
   957 	
   985 	
   958 	IriSP.YouTubeAddListeners();	
   986 	IriSP.YouTubeAddListeners();	
   959 	IriSP.trace("onYouTubePlayerReady=",time);
   987 	IriSP.trace( "onYouTubePlayerReady=", time);
   960 	//__IriSP.MyApiPlayer.ready(playerid);
   988 	//__IriSP.MyApiPlayer.ready(playerid);
   961 }
   989 };
       
   990 
   962 IriSP.YouTubeAddListeners = function () {
   991 IriSP.YouTubeAddListeners = function () {
   963 	if (IriSP.player) { 
   992 	if ( IriSP.player ) { 
   964 		IriSP.trace("__IriSP.addListeners","ADD  Listener ");
   993 		IriSP.trace( "__IriSP.addListeners", "ADD  Listener " );
   965 		IriSP.player.addEventListener("onStateChange", "__IriSP.YouTubeStateMonitor");
   994 		IriSP.player.addEventListener( "onStateChange", "__IriSP.YouTubeStateMonitor" );
   966 		setTimeout("__IriSP.YouTubePositionListener()",100);
   995 		setTimeout( "__IriSP.YouTubePositionListener()", 100 );
   967 		IriSP.player.addModelListener("VOLUME", "__IriSP.volumeListener");
   996 		IriSP.player.addModelListener( "VOLUME", "__IriSP.volumeListener" );
   968 		//__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor');
   997 		//__IriSP.player.addModelListener('STATE', '__IriSP.stateMonitor');
   969 	} else {
   998 	} else {
   970 		IriSP.setTimeout("__IriSP.YouTubePositionListener()",100);
   999 	}
   971 	}
  1000 };
   972 }
  1001 
   973 IriSP.YouTubePositionListener = function() { 
  1002 IriSP.YouTubePositionListener = function() { 
   974 	
  1003 	
   975 	IriSP.currentPosition = IriSP.player.getCurrentTime();
  1004 	IriSP.currentPosition = IriSP.player.getCurrentTime();
   976 	//__IriSP.trace("__IriSP.YouTubePositionListener",__IriSP.currentPosition);
  1005 	//__IriSP.trace("__IriSP.YouTubePositionListener",__IriSP.currentPosition);
   977 	//__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition);
  1006 	//__IriSP.trace("__IriSP.currentPosition",__IriSP.currentPosition);
   978 	
  1007 	
   979 	IriSP.MyLdt.checkTime(IriSP.currentPosition);
  1008 	IriSP.MyLdt.checkTime(IriSP.currentPosition);
   980 	IriSP.jQuery("#slider-range-min").slider("value",IriSP.currentPosition);
  1009 	IriSP.jQuery( "#slider-range-min" ).slider( "value", IriSP.currentPosition );
   981 	IriSP.jQuery("#amount").val(IriSP.currentPosition+" s");
  1010 	IriSP.jQuery( "#amount" ).val( IriSP.currentPosition+" s" );
   982 	// afficher annotation 
  1011 	// afficher annotation 
   983 	IriSP.MyLdt.checkTime(IriSP.currentPosition);
  1012 	IriSP.MyLdt.checkTime( IriSP.currentPosition );
   984 	
  1013 	
   985 	
  1014 	
   986 	setTimeout("__IriSP.YouTubePositionListener()",10);
  1015 	setTimeout( "__IriSP.YouTubePositionListener()", 10 );
   987 }
  1016 };
       
  1017 
   988 IriSP.YouTubeStateMonitor = function (obj) { 
  1018 IriSP.YouTubeStateMonitor = function (obj) { 
   989 	IriSP.player.addModelListener('__IriSP.YouTubeStateMonitor ', newstate);
  1019 	IriSP.player.addModelListener( '__IriSP.YouTubeStateMonitor ', newstate );
   990 	//alert(newstate+" "+obj.newstate);
  1020 	//alert(newstate+" "+obj.newstate);
   991 	 if(newstate == '2')
  1021 	 if(newstate == '2') {
   992     {
       
   993 		IriSP.trace("__IriSP.stateMonitor","PAUSE");
  1022 		IriSP.trace("__IriSP.stateMonitor","PAUSE");
   994 		IriSP.MyApiPlayer.changePageUrlOffset(IriSP.currentPosition);			
  1023 		IriSP.MyApiPlayer.changePageUrlOffset( IriSP.currentPosition );
   995 		
  1024 		
   996 	}else if (newstate == '1'){
  1025 	} else if (newstate == '1' || newstate == '1') {
   997 		// une fois la video prete a lire  la déplacer au bon timecode 
  1026 		// une fois la video prete a lire  la déplacer au bon timecode 
   998 		if(IriSP.startPosition!=null){
  1027 		if( IriSP.startPosition!=null ) {
   999 			IriSP.MyApiPlayer.update(IriSP.startPosition);
  1028 			IriSP.MyApiPlayer.update( IriSP.startPosition );
  1000 			IriSP.startPosition = null;
       
  1001 		}
       
  1002 	} 
       
  1003 	else if (newstate == '-1'){
       
  1004 		// une fois la video prete a lire  la déplacer au bon timecode 
       
  1005 		if(IriSP.startPosition!=null){
       
  1006 			IriSP.MyApiPlayer.update(IriSP.startPosition);
       
  1007 			IriSP.startPosition = null;
  1029 			IriSP.startPosition = null;
  1008 		}
  1030 		}
  1009 	} else if (newstate == '3'){
  1031 	} else if (newstate == '3'){
  1010 		IriSP.trace("__IriSP.stateMonitor","BUFFERING : ");
  1032 		IriSP.trace("__IriSP.stateMonitor","BUFFERING : ");
  1011 		//changePageUrlOffset(currentPosition);
  1033 		//changePageUrlOffset(currentPosition);
  1012 	}
  1034 	}
  1013 	
  1035 	
  1014 }
  1036 };
  1015 
  1037 
  1016 
  1038 
  1017 
  1039 /* 	utils */
  1018 /* 	UTIL */
       
  1019 // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript
  1040 // code from http://stackoverflow.com/questions/822452/strip-html-from-text-javascript
       
  1041 /* FIXME: maybe make it a little more robust */
  1020 IriSP.stripHtml = function(s){
  1042 IriSP.stripHtml = function(s){
  1021 	return s.replace(/\\&/g, '&amp;').replace(/\\</g, '&lt;').replace(/\\>/g, '&gt;').replace(/\\t/g, '&nbsp;&nbsp;&nbsp;').replace(/\\n/g, '<br />').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
  1043 	return s.replace(/\\&/g, '&amp;').replace(/\\</g, '&lt;').replace(/\\>/g, '&gt;').replace(/\\t/g, '&nbsp;&nbsp;&nbsp;').replace(/\\n/g, '<br />').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
  1022 }
  1044 };
  1023 // conversion de couleur Decimal vers HexaDecimal || 000 si fff 
  1045 
  1024 IriSP.DEC_HEXA_COLOR = function (dec){
  1046 // conversion de couleur Decimal vers HexaDecimal || 000 si fff
       
  1047 /* FIXME : move it somewhere else */
       
  1048 IriSP.DEC_HEXA_COLOR = function (dec) {
  1025 	 var hexa='0123456789ABCDEF',hex='';
  1049 	 var hexa='0123456789ABCDEF',hex='';
  1026 	 var tmp;
  1050 	 var tmp;
  1027 	 while (dec>15){
  1051 	 while (dec>15){
  1028 		  tmp = dec-(Math.floor(dec/16))*16;
  1052 		  tmp = dec-(Math.floor(dec/16))*16;
  1029 		  hex = hexa.charAt(tmp)+hex;
  1053 		  hex = hexa.charAt(tmp)+hex;
  1030 		  dec = Math.floor(dec/16);
  1054 		  dec = Math.floor(dec/16);
  1031 	 }
  1055 	 }
  1032 	 hex = hexa.charAt(dec)+hex;
  1056 	 hex = hexa.charAt(dec)+hex;
  1033 	 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ }
  1057 	 if (hex == "FFCC00"){ hex="";/* by default color of Ldt annotation */ }
  1034 	 return(hex);
  1058 	 return(hex);
  1035 }
  1059 };
  1036 
  1060 
  1037 
  1061 
  1038 /* Search  methodes	*/
  1062 /* Search  methods	*/
  1039 IriSP.SearchOldValue="";
  1063 IriSP.SearchOldValue="";
  1040 IriSP.searchblockOpen=false;
  1064 IriSP.searchblockOpen=false;
  1041 IriSP.searchblock 		= function (){
  1065 IriSP.searchblock = function () {
  1042 	IriSP.trace("__IriSP.searchblock",IriSP.searchblockOpen);
  1066 	IriSP.trace( "__IriSP.searchblock", IriSP.searchblockOpen );
  1043 	if (IriSP.searchblockOpen==false){
  1067 	
  1044 		IriSP.jQuery(".ui-icon-search").css("background-position","-144px -112px");
  1068 	if ( IriSP.searchblockOpen == false ) {
       
  1069 		IriSP.jQuery( ".ui-icon-search" ).css( "background-position", "-144px -112px" );
  1045 		//__IriSP.jQuery("#LdtSearch").animate({height:26},250);
  1070 		//__IriSP.jQuery("#LdtSearch").animate({height:26},250);
  1046 		IriSP.jQuery("#LdtSearch").show(250);
  1071 		IriSP.jQuery("#LdtSearch").show(250);
       
  1072 		/* FIXME : refactor this */
  1047 		IriSP.jQuery("#LdtSearchInput").css('background-color','#fff');
  1073 		IriSP.jQuery("#LdtSearchInput").css('background-color','#fff');
  1048 		IriSP.jQuery("#LdtSearchInput").focus();
  1074 		IriSP.jQuery("#LdtSearchInput").focus();
  1049 		IriSP.jQuery("#LdtSearchInput").attr('value',IriSP.SearchOldValue);
  1075 		IriSP.jQuery("#LdtSearchInput").attr('value',IriSP.SearchOldValue);
  1050 		IriSP.Search(IriSP.SearchOldValue);
  1076 		IriSP.Search(IriSP.SearchOldValue);
  1051 		IriSP.searchblockOpen=true;
  1077 		IriSP.searchblockOpen = true;
  1052 	} else {
  1078 	} else {
  1053 		IriSP.SearchOldValue = IriSP.jQuery("#LdtSearchInput").attr('value');
  1079 		IriSP.SearchOldValue = IriSP.jQuery("#LdtSearchInput").attr('value');
  1054 		IriSP.jQuery("#LdtSearchInput").attr('value','');
  1080 		IriSP.jQuery("#LdtSearchInput").attr('value','');
  1055 		IriSP.SearchClean();
  1081 		IriSP.SearchClean();
  1056 		IriSP.jQuery(".ui-icon-search").css("background-position","-160px -112px");
  1082 		IriSP.jQuery(".ui-icon-search").css("background-position","-160px -112px");
  1057 		//__IriSP.jQuery("#LdtSearch").animate({height:0},250);
  1083 		//__IriSP.jQuery("#LdtSearch").animate({height:0},250);
  1058 		IriSP.jQuery("#LdtSearch").hide(250);
  1084 		IriSP.jQuery("#LdtSearch").hide(250);
  1059 		IriSP.searchblockOpen=false;
  1085 		IriSP.searchblockOpen = false;
  1060 	}
  1086 	}
  1061 }
  1087 };
  1062 IriSP.Search 				= function (value){
  1088 
       
  1089 IriSP.Search = function ( value ){
  1063 
  1090 
  1064 	annotations = IriSP.LDTligne.annotations;
  1091 	annotations = IriSP.LDTligne.annotations;
  1065 	
  1092 	
  1066 	IriSP.trace("__IriSP.Search",annotations.length+" "+value);
  1093 	IriSP.trace("__IriSP.Search", annotations.length+" "+value);
       
  1094 	/* FIXME : rename finded => found */
  1067 	var finded  = 0;
  1095 	var finded  = 0;
  1068 	var findmem = 0;
  1096 	var findmem = 0;
  1069 	var factor  = 0;
  1097 	var factor  = 0;
  1070 	IriSP.trace(value,value.length);
  1098 	IriSP.trace(value,value.length);
  1071 	var valueS = value.toLowerCase();
  1099 	var valueS = value.toLowerCase();
  1072 	IriSP.trace("__IriSP.Search",annotations.length+" "+valueS);
  1100 	IriSP.trace("__IriSP.Search", annotations.length+" "+valueS);
  1073 	if(valueS.length>=3){
  1101 	if(valueS.length>=3){
  1074 		
  1102 		
  1075 		for (var i=0; i < annotations.length; ++i){
  1103 		for (var i=0; i < annotations.length; ++i){
  1076 			annotation = annotations[i];
  1104 			annotation = annotations[i];
  1077 			
  1105 			
  1119 		IriSP.jQuery("#LdtSearchInput").css('background-color','#fff');		
  1147 		IriSP.jQuery("#LdtSearchInput").css('background-color','#fff');		
  1120 	} else {
  1148 	} else {
  1121 		IriSP.SearchClean();
  1149 		IriSP.SearchClean();
  1122 		IriSP.jQuery("#LdtSearchInput").css('background-color','#f6f6f6');
  1150 		IriSP.jQuery("#LdtSearchInput").css('background-color','#f6f6f6');
  1123 	}
  1151 	}
  1124 }
  1152 };
  1125 IriSP.SearchClean 		= function (){
  1153 
       
  1154 IriSP.SearchClean = function (){
  1126 	annotations = IriSP.LDTligne.annotations;
  1155 	annotations = IriSP.LDTligne.annotations;
  1127 	
  1156 	
  1128 	for (var i=0; i < annotations.length; ++i){
  1157 	for (var i=0; i < annotations.length; ++i){
  1129 			annotation = annotations[i];
  1158 			annotation = annotations[i];
  1130 			IriSP.jQuery("#"+annotation.id).dequeue();
  1159 			IriSP.jQuery("#"+annotation.id).dequeue();
  1131 			IriSP.jQuery("#"+annotation.id).animate({height:0},100);	
  1160 			IriSP.jQuery("#"+annotation.id).animate({height:0},100);	
  1132 			IriSP.jQuery("#"+annotation.id).css('border','0px');
  1161 			IriSP.jQuery("#"+annotation.id).css('border','0px');
  1133 			IriSP.jQuery("#"+annotation.id).css('border-color','red');
  1162 			IriSP.jQuery("#"+annotation.id).css('border-color','red');
  1134 			IriSP.jQuery("#"+annotation.id).animate({opacity:0.3},100);
  1163 			IriSP.jQuery("#"+annotation.id).animate({opacity:0.3},100);
  1135 		}
  1164 		}
  1136 }
  1165 };
  1137 IriSP.SearchCleanString 	= function (value){
  1166 
       
  1167 IriSP.SearchCleanString	= function (value){
  1138 	var reg = new RegExp("(chien)", "g");
  1168 	var reg = new RegExp("(chien)", "g");
  1139 	value.replace(reg,"")
  1169 	value.replace(reg,"");
  1140 	return value;
  1170 	return value;
  1141 }	
  1171 };
  1142 IriSP.SearchThisSegment  	= function (annotation){
  1172 
       
  1173 IriSP.SearchThisSegment = function (annotation){
       
  1174 	/* FIXME: to implement */
  1143 					IriSP.jQuery("#LdtSearchInput").text(annotation.title);
  1175 					IriSP.jQuery("#LdtSearchInput").text(annotation.title);
  1144 					IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotation.title);
  1176 					IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotation.title);
  1145 					/*__IriSP.jQuery("#Ldt-SaDescription").text(annotationTempo.description);
  1177 					/*__IriSP.jQuery("#Ldt-SaDescription").text(annotationTempo.description);
  1146 					__IriSP.jQuery("#Ldt-SaKeywordText").html("Mots clefs : "+annotationTempo.htmlTags);*/
  1178 					__IriSP.jQuery("#Ldt-SaKeywordText").html("Mots clefs : "+annotationTempo.htmlTags);*/
  1147 }
  1179 };
  1148 
  1180 
  1149 
  1181 
  1150 /* CLASS Ligne (annotationType) 	*/
  1182 /* CLASS Ligne (annotationType) 	*/
  1151 
  1183 
  1152 IriSP.LDTligne 	= null;		
  1184 IriSP.LDTligne 	= null;		
  1153 __IriSP.Ligne = function (id,title,description,duration){
  1185 __IriSP.Ligne = function( id, title, description, duration ) {
  1154 	this.id 		 = id;
  1186 	this.id 		 = id;
  1155 	this.title 		 = title;
  1187 	this.title 		 = title;
  1156 	this.description = description;
  1188 	this.description = description;
  1157 	//
  1189 	//
  1158 	this.annotations = new Array();
  1190 	this.annotations = new Array();
  1159 	this.duration = duration;
  1191 	this.duration = duration;
  1160 	this.annotationOldRead="";
  1192 	this.annotationOldRead = "";
  1161 	IriSP.LDTligne = this;
  1193 	IriSP.LDTligne = this;
  1162 	IriSP.trace("__IriSP.Ligne","CREATE "+IriSP.LDTligne);
  1194 	IriSP.trace("__IriSP.Ligne","CREATE "+IriSP.LDTligne);
  1163 }	
  1195 };
  1164 __IriSP.Ligne.prototype.addAnnotation = function (id,begin,end,media,title,description,color,tags){
  1196 
       
  1197 __IriSP.Ligne.prototype.addAnnotation = function ( id, begin, end, media, title, description, color, tags ) {
  1165 	var myAnnotation = new __IriSP.Annotation(id,begin,end,media,title,description,color,tags,this.duration);
  1198 	var myAnnotation = new __IriSP.Annotation(id,begin,end,media,title,description,color,tags,this.duration);
  1166 	this.annotations.push(myAnnotation);
  1199 	this.annotations.push(myAnnotation);
  1167 	//__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation  ","add annotation "+title);
  1200 	//__IriSP.trace("__IriSP.Ligne.prototype.addAnnotation  ","add annotation "+title);
  1168 }
  1201 };
  1169 __IriSP.Ligne.prototype.onClickLigneAnnotation = function(id){
  1202 
       
  1203 __IriSP.Ligne.prototype.onClickLigneAnnotation = function( id ) {
       
  1204 	/* TODO implement */
  1170 	//changePageUrlOffset(currentPosition);
  1205 	//changePageUrlOffset(currentPosition);
  1171 	//player.sendEvent('SEEK', this.start);
  1206 	//player.sendEvent('SEEK', this.start);
  1172 	//__IriSP.trace("SEEK",this.start);
  1207 	//__IriSP.trace("SEEK",this.start);
  1173 }
  1208 };
  1174 __IriSP.Ligne.prototype.searchLigneAnnotation = function(id){
  1209 
       
  1210 __IriSP.Ligne.prototype.searchLigneAnnotation = function( id ) {
       
  1211 	/* TODO implement */
  1175 	/*for (){
  1212 	/*for (){
  1176 	}*/
  1213 	}*/
  1177 }
  1214 };
  1178 __IriSP.Ligne.prototype.listAnnotations = function(){
  1215 
  1179 
  1216 __IriSP.Ligne.prototype.listAnnotations = function() {
  1180 }
  1217 	/* TODO implement */
  1181 __IriSP.Ligne.prototype.nextAnnotation = function (){
  1218 };
       
  1219 
       
  1220 __IriSP.Ligne.prototype.nextAnnotation = function () {
       
  1221 	
  1182 	var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1;
  1222 	var annotationCibleNumber = this.numAnnotation(this.annotationOldRead)+1;
  1183 	var annotationCible = this.annotations[annotationCibleNumber];
  1223 	var annotationCible = this.annotations[annotationCibleNumber];
  1184 
  1224 
  1185 	if(annotationCibleNumber<this.annotations.length-1){
  1225 	if( annotationCibleNumber<this.annotations.length-1 ){
  1186 		annotationCible.begin
  1226 		IriSP.player.sendEvent( 'SEEK', annotationCible.begin/1000 );
  1187 		IriSP.player .sendEvent('SEEK', annotationCible.begin/1000);
  1227 		IriSP.trace( "LIGNE  ", "| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000);
  1188 		IriSP.trace("LIGNE  ","| next = "+annotationCibleNumber+" - "+this.annotations.length+" | seek :"+annotationCible.begin/1000);
  1228 	} else {
  1189 	}else{
  1229 		IriSP.player.sendEvent( 'SEEK', this.annotations[0].begin/1000);
  1190 		IriSP.player .sendEvent('SEEK', this.annotations[0].begin/1000);
  1230 	}
  1191 	}
  1231 		
  1192 	
  1232 };
  1193 	
  1233 
  1194 }
       
  1195 __IriSP.Ligne.prototype.numAnnotation = function (annotationCible){
  1234 __IriSP.Ligne.prototype.numAnnotation = function (annotationCible){
  1196 	for (var i=0; i < this.annotations.length; ++i){
  1235 	for (var i=0; i < this.annotations.length; ++i){
  1197 		if(annotationCible == this.annotations[i]){
  1236 		if(annotationCible == this.annotations[i]){
  1198 			return i;
  1237 			return i;
  1199 		}
  1238 		}
  1200 	}
  1239 	}
  1201 }
  1240 };
       
  1241 
  1202 __IriSP.Ligne.prototype.checkTime = function(time){
  1242 __IriSP.Ligne.prototype.checkTime = function(time){
  1203 	
  1243 	
  1204 	var annotationTempo = -1;
  1244 	var annotationTempo = -1;
  1205 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",time);
  1245 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",time);
  1206 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",this.annotations.length);
  1246 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",this.annotations.length);
  1225 					IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
  1265 					IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
  1226 					//alert(startPourcent);
  1266 					//alert(startPourcent);
  1227 					var tempolinkurl  =  IriSP.ignoreTimeFragment(window.location.href)+"#t="+(this.annotations[i].begin/1000);
  1267 					var tempolinkurl  =  IriSP.ignoreTimeFragment(window.location.href)+"#t="+(this.annotations[i].begin/1000);
  1228 				}
  1268 				}
  1229 			break;
  1269 			break;
  1230 		}else{
  1270 		} else {
  1231 		annotationTempo=-1;
  1271 		annotationTempo = -1;
  1232 		}		
  1272 		}		
  1233 		
  1273 		
  1234 	}
  1274 	}
  1235 	// si il y en a pas : retractation du volet 
  1275 	// si il y en a pas : retractation du volet 
  1236 	if( annotationTempo == -1){
  1276 	if( annotationTempo == -1){
  1237 		if(annotationTempo!=this.annotationOldRead){
  1277 		if(annotationTempo != this.annotationOldRead){
  1238 			IriSP.trace("Check : ","pas d'annotation ici ");
  1278 			IriSP.trace("Check : ","pas d'annotation ici ");
  1239 			IriSP.jQuery("#Ldt-SaTitle").text("");
  1279 			IriSP.jQuery("#Ldt-SaTitle").text("");
  1240 			IriSP.jQuery("#Ldt-SaDescription").text("");
  1280 			IriSP.jQuery("#Ldt-SaDescription").text("");
  1241 			IriSP.jQuery("#Ldt-SaKeywordText").html("");
  1281 			IriSP.jQuery("#Ldt-SaKeywordText").html("");
  1242 			IriSP.jQuery('#Ldt-ShowAnnotation').slideUp();
  1282 			IriSP.jQuery('#Ldt-ShowAnnotation').slideUp();
  1246 			//__IriSP.jQuery("#Ldt-Show-Arrow").animate({left:'0%'},1000);
  1286 			//__IriSP.jQuery("#Ldt-Show-Arrow").animate({left:'0%'},1000);
  1247 			this.annotationOldRead = annotationTempo;
  1287 			this.annotationOldRead = annotationTempo;
  1248 		}
  1288 		}
  1249 	}
  1289 	}
  1250 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotationTempo);
  1290 	//__IriSP.trace("__IriSP.Ligne.prototype.checkTimeLigne",annotationTempo);
  1251 }
  1291 };
  1252 
  1292 
  1253 
  1293 
  1254 /* CLASS Annotation */
  1294 /* CLASS Annotation */
  1255 
  1295 
  1256 __IriSP.Annotation = function (){
  1296 __IriSP.Annotation = function (){
  1257 	var id 			= null;
  1297 	var id 	= null;
  1258 	var begin 			= null;
  1298 	var begin 			= null;
  1259 	var end 			= null;
  1299 	var end 			= null;
  1260 	var media 			= null;
  1300 	var media 			= null;
  1261 	var description	= null;
  1301 	var description	= null;
  1262 	var title 			= null;
  1302 	var title 			= null;
  1263 	var color 			= null;
  1303 	var color 			= null;
  1264 	var tags			= null;
  1304 	var tags			= null;
  1265 	IriSP.trace("annotation ","réussi")
  1305 	IriSP.trace("annotation ","réussi");
  1266 }	
  1306 };
  1267 __IriSP.Annotation = function(id,begin,end,media,title,description,color,tags,duration){
  1307 
       
  1308 __IriSP.Annotation = function( id, begin, end, media, title, description, color, tags, duration ){
  1268 	this.id 			= id;
  1309 	this.id 			= id;
  1269 	this.begin 			= begin;
  1310 	this.begin 			= begin;
  1270 	this.end 			= end;
  1311 	this.end 			= end;
  1271 	this.media 			= media;
  1312 	this.media 			= media;
  1272 	this.description 	= description;
  1313 	this.description 	= description;
  1278 	// draw it 
  1319 	// draw it 
  1279 	this.draw();
  1320 	this.draw();
  1280 	this.drawTags();
  1321 	this.drawTags();
  1281 	//
  1322 	//
  1282 	IriSP.trace("Annotation created : ",id);
  1323 	IriSP.trace("Annotation created : ",id);
  1283 }	
  1324 };
       
  1325 
  1284 __IriSP.Annotation.prototype.draw = function(){
  1326 __IriSP.Annotation.prototype.draw = function(){
  1285 	//alert (this.duration);
  1327 	//alert (this.duration);
  1286 	var startPourcent 	= this.timeToPourcent(this.begin,this.duration); // temps du media 
  1328 	var startPourcent 	= this.timeToPourcent(this.begin,this.duration); // temps du media 
  1287 	var endPourcent 	= this.timeToPourcent(this.end,this.duration)-startPourcent;
  1329 	var endPourcent 	= this.timeToPourcent(this.end,this.duration)-startPourcent;
  1288 	var titleForDiv		= this.title.substr(0,55);
  1330 	var titleForDiv		= this.title.substr(0,55);
  1289 	
  1331 	
  1290 	IriSP.jQueryAnnotationTemplate = "<div title='"+IriSP.stripHtml(titleForDiv)+"' id='"+this.id+"'  class='ui-slider-range ui-slider-range-min ui-widget-header iri-chapter' width='100%' style=\"left:"+startPourcent+"%; width:"+endPourcent+"%; padding-top:15px; border-left:solid 1px #aaaaaa; border-right:solid 1px #aaaaaa; background:#"+IriSP.DEC_HEXA_COLOR(this.color)+";\" onClick=\"__IriSP.MyApiPlayer.seek('"+Math.round(this.begin/1000)+"');__IriSP.jQuery('#Ldt-ShowAnnotation').slideDown();\"    ></div> ";
  1332 	IriSP.jQueryAnnotationTemplate = "<div title='"+IriSP.stripHtml(titleForDiv)+"' id='"+this.id+"'  class='ui-slider-range ui-slider-range-min ui-widget-header iri-chapter' width='100%' style=\"left:"+startPourcent+"%; width:"+endPourcent+"%; padding-top:15px; border-left:solid 1px #aaaaaa; border-right:solid 1px #aaaaaa; background:#"+IriSP.DEC_HEXA_COLOR(this.color)+";\" onClick=\"__IriSP.MyApiPlayer.seek('"+Math.round(this.begin/1000)+"');__IriSP.jQuery('#Ldt-ShowAnnotation').slideDown();\"    ></div> ";
  1291 	//alert(this.color+" : "+DEC_HEXA_COLOR(this.color));
  1333 	//alert(this.color+" : "+DEC_HEXA_COLOR(this.color));
  1292 	
  1334 	
       
  1335 	/* FIXME: templatize this portion */
  1293 	IriSP.jQuerytoolTipTemplate = "<div class='Ldt-tooltip'>"
  1336 	IriSP.jQuerytoolTipTemplate = "<div class='Ldt-tooltip'>"
  1294 						+"<div class='title'>"+IriSP.stripHtml(this.title)+"</div>"
  1337 						+"<div class='title'>"+IriSP.stripHtml(this.title)+"</div>"
  1295 						+"<div class='time'>"+this.begin+" : "+this.end+"</div>"
  1338 						+"<div class='time'>"+this.begin+" : "+this.end+"</div>"
  1296 						+"<div class='description'>"+IriSP.stripHtml(this.description)+"</div>"
  1339 						+"<div class='description'>"+IriSP.stripHtml(this.description)+"</div>"
  1297 						+"</div>";
  1340 						+"</div>";
  1303 	IriSP.jQuery("#"+this.id).tooltip({ effect: 'slide'});
  1346 	IriSP.jQuery("#"+this.id).tooltip({ effect: 'slide'});
  1304 	
  1347 	
  1305 	
  1348 	
  1306 	IriSP.jQuery("#"+this.id).fadeTo(0,0.3);
  1349 	IriSP.jQuery("#"+this.id).fadeTo(0,0.3);
  1307 	IriSP.jQuery("#"+this.id).mouseover(function() {
  1350 	IriSP.jQuery("#"+this.id).mouseover(function() {
  1308 		IriSP.jQuery("#"+this.id).animate({opacity: 0.6}, 5)
  1351 		IriSP.jQuery("#"+this.id).animate({opacity: 0.6}, 5);
  1309 	}).mouseout(function(){		
  1352 	}).mouseout(function(){		
  1310 		IriSP.jQuery("#"+this.id).animate({opacity: 0.3}, 5)
  1353 		IriSP.jQuery("#"+this.id).animate({opacity: 0.3}, 5);
  1311 	});
  1354 	});
  1312 	IriSP.trace("__IriSP.Annotation.prototype.draw","ADD ANOTATION : "+this.begin+" "+this.end+" "+IriSP.stripHtml(this.title)+" | "+startPourcent+" | "+endPourcent+" | duration = "+this.duration);
  1355 	IriSP.trace("__IriSP.Annotation.prototype.draw","ADD ANOTATION : "+this.begin+" "+this.end+" "+IriSP.stripHtml(this.title)+" | "+startPourcent+" | "+endPourcent+" | duration = "+this.duration);
  1313 	
  1356 	
  1314 }	
  1357 };
       
  1358 
  1315 __IriSP.Annotation.prototype.drawTags = function(){
  1359 __IriSP.Annotation.prototype.drawTags = function(){
       
  1360 	/* FIXME : to implement */
  1316 	var KeywordPattern = '<a href=\"\"> '+' </a>';
  1361 	var KeywordPattern = '<a href=\"\"> '+' </a>';
  1317 	
  1362 	
  1318 	//__IriSP.trace(" !? Tags : ",this.tags);
  1363 	//__IriSP.trace(" !? Tags : ",this.tags);
  1319 	
  1364 	
  1320 	if (this.tags!=undefined){
  1365 	if (this.tags!=undefined){
  1323 			//this.htmlTags += '<span onclick=\"ShowTag('+this.tags[i]['id-ref']+');\"  > '+MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , ";
  1368 			//this.htmlTags += '<span onclick=\"ShowTag('+this.tags[i]['id-ref']+');\"  > '+MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , ";
  1324 			this.htmlTags += '<span> '+IriSP.MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , ";
  1369 			this.htmlTags += '<span> '+IriSP.MyTags.getTitle(this.tags[i]['id-ref'])+' </span>'+" , ";
  1325 			
  1370 			
  1326 		}		
  1371 		}		
  1327 	}
  1372 	}
  1328 }
  1373 };
       
  1374 
  1329 __IriSP.Annotation.prototype.tootTipAnnotation = function() {
  1375 __IriSP.Annotation.prototype.tootTipAnnotation = function() {
  1330 	// 1 chercher le div correspondant
  1376 	// 1 chercher le div correspondant
  1331 	// 2 y mettre les information
  1377 	// 2 y mettre les information
  1332 	return this.color + ' ' + this.type + ' apple';
  1378 	return this.color + ' ' + this.type + ' apple';
  1333 }
  1379 };
       
  1380 
  1334 __IriSP.Annotation.prototype.onRollOverAnnotation = function (){
  1381 __IriSP.Annotation.prototype.onRollOverAnnotation = function (){
  1335 	this.tootTip();
  1382 	this.tootTip();
  1336 }		
  1383 };
       
  1384 
  1337 __IriSP.Annotation.prototype.timeToPourcent = function(time,timetotal){
  1385 __IriSP.Annotation.prototype.timeToPourcent = function(time,timetotal){
  1338 	return (parseInt(Math.round(time/timetotal*100)));
  1386 	return (parseInt(Math.round(time/timetotal*100)));
  1339 }
  1387 };
  1340  
  1388  
  1341 
  1389 
  1342 /* CLASS Tags */
  1390 /* CLASS Tags */
  1343 
  1391 
  1344 __IriSP.Tags = function(object){
  1392 __IriSP.Tags = function(object){
  1345 	this.myTags 	=	object;
  1393 	this.myTags 	=	object;
  1346 	this.htmlTags 	= 	null;
  1394 	this.htmlTags 	= 	null;
  1347 	this.weigthMax 	= 	0;
  1395 	this.weigthMax 	= 	0;
  1348 	//this.mySegments  = 	new array();
  1396 	//this.mySegments  = 	new array();
  1349 }
  1397 };
       
  1398 
  1350 __IriSP.Tags.prototype.addAnnotation = function (annotation){
  1399 __IriSP.Tags.prototype.addAnnotation = function (annotation){
  1351 	for (var i = 0; i < this.myTags.length; ++i){
  1400 	for (var i = 0; i < this.myTags.length; ++i){
  1352 		this.myTags[i].mySegments = new Array(); 
  1401 		this.myTags[i].mySegments = new Array(); 
  1353 		if (annotation.tags!=null){
  1402 		if (annotation.tags!=null){
  1354 			for (var j = 0; j < annotation.tags.length; ++j){
  1403 			for (var j = 0; j < annotation.tags.length; ++j){
  1355 				if (this.myTags[i]['id'] == annotation.tags[j]['id-ref']){
  1404 				if (this.myTags[i]['id'] == annotation.tags[j]['id-ref']){
  1356 					this.myTags[i].mySegments.push([annotation.begin,annotation.end,annotation.id]);
  1405 					this.myTags[i].mySegments.push([annotation.begin,annotation.end,annotation.id]);
  1357 					var weigthTempo = this.myTags[i].mySegments.length
  1406 					var weigthTempo = this.myTags[i].mySegments.length;
  1358 					var tempo = this.myTags[i].mySegments[weigthTempo-1];
  1407 					var tempo = this.myTags[i].mySegments[weigthTempo-1];
  1359 					//__IriSP.trace ("__IriSP.Tags.prototype.addAnnotation ","  "+this.myTags[i]['meta']['dc:title']+" "+this.myTags[i]['id']+" : "+tempo[0]+" - "+tempo[1]);
  1408 					//__IriSP.trace ("__IriSP.Tags.prototype.addAnnotation ","  "+this.myTags[i]['meta']['dc:title']+" "+this.myTags[i]['id']+" : "+tempo[0]+" - "+tempo[1]);
  1360 					
  1409 					
  1361 					if (this.weigthMax < weigthTempo ){
  1410 					if (this.weigthMax < weigthTempo ){
  1362 						this.weigthMax = weigthTempo;
  1411 						this.weigthMax = weigthTempo;
  1363 					}
  1412 					}
  1364 				}
  1413 				}
  1365 			}
  1414 			}
  1366 		}
  1415 		}
  1367 	}
  1416 	}
  1368 }
  1417 };
       
  1418 
  1369 __IriSP.Tags.prototype.getTitle = function (id){
  1419 __IriSP.Tags.prototype.getTitle = function (id){
  1370 	for (var i = 0; i < this.myTags.length; ++i){
  1420 	for (var i = 0; i < this.myTags.length; ++i){
  1371 		if(this.myTags[i]['id']==id){
  1421 		if(this.myTags[i]['id']==id){
  1372 			return(this.myTags[i]['meta']['dc:title']);
  1422 			return(this.myTags[i]['meta']['dc:title']);
  1373 		}
  1423 		}
  1374 	}
  1424 	}
  1375 
  1425 
  1376 }
  1426 };
       
  1427 
  1377 __IriSP.Tags.prototype.draw = function (){
  1428 __IriSP.Tags.prototype.draw = function (){
  1378 
  1429 
  1379 	IriSP.trace("__IriSP.Tags.prototype.draw"," !!! WELL START " );
  1430 	IriSP.trace("__IriSP.Tags.prototype.draw"," !!! WELL START " );
  1380 	for (var i = 0; i < this.myTags.length; ++i){
  1431 	for (var i = 0; i < this.myTags.length; ++i){
  1381 		IriSP.trace("__IriSP.Tags.prototype.draw"," ADD Tags : "+this.myTags[i]['id']);
  1432 		IriSP.trace("__IriSP.Tags.prototype.draw"," ADD Tags : "+this.myTags[i]['id']);
  1388 	}
  1439 	}
  1389 	
  1440 	
  1390 	IriSP.jQuery('#Ldt-Tags').html(this.htmlTags);
  1441 	IriSP.jQuery('#Ldt-Tags').html(this.htmlTags);
  1391 	IriSP.trace("__IriSP.Tags.prototype.draw"," !!!!  END WMAX= "+this.weigthMax );
  1442 	IriSP.trace("__IriSP.Tags.prototype.draw"," !!!!  END WMAX= "+this.weigthMax );
  1392 	
  1443 	
  1393 }
  1444 };
       
  1445 
  1394 __IriSP.Tags.prototype.show = function (id){
  1446 __IriSP.Tags.prototype.show = function (id){
  1395 	
  1447 	
  1396 	var timeStartOffsetA	=	100000000000000000000;
  1448 	var timeStartOffsetA	=	100000000000000000000;
  1397 	var timeStartOffsetB	=	100000000000000000000;
  1449 	var timeStartOffsetB	=	100000000000000000000;
  1398 	var timeEndOffsetA		=	0;
  1450 	var timeEndOffsetA		=	0;
  1434 	leftPourCent 	= IriSP.timeToPourcent((timeStartOffsetA*1+(timeStartOffsetB-timeStartOffsetA)/2),IriSP.MyLdt.duration); 
  1486 	leftPourCent 	= IriSP.timeToPourcent((timeStartOffsetA*1+(timeStartOffsetB-timeStartOffsetA)/2),IriSP.MyLdt.duration); 
  1435 	WidthPourCent	= IriSP.timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),IriSP.MyLdt.duration)-leftPourCent; 			
  1487 	WidthPourCent	= IriSP.timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),IriSP.MyLdt.duration)-leftPourCent; 			
  1436 	//WidthPourCent	= timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),MyLdt.duration)-startPourcent; 			
  1488 	//WidthPourCent	= timeToPourcent((timeEndOffsetA*1+(timeEndOffsetB-timeEndOffsetA)/2),MyLdt.duration)-startPourcent; 			
  1437 	IriSP.jQuery("#Ldt-Show-Tags").css('left',leftPourCent+'%');
  1489 	IriSP.jQuery("#Ldt-Show-Tags").css('left',leftPourCent+'%');
  1438 	IriSP.jQuery("#Ldt-Show-Tags").css('width',WidthPourCent+'%');
  1490 	IriSP.jQuery("#Ldt-Show-Tags").css('width',WidthPourCent+'%');
       
  1491 	IriSP.jQuery("#Ldt-Show-Tags").text('joijoij');
  1439 	// like arrow script
  1492 	// like arrow script
  1440 	
  1493 	
  1441 	
  1494 	
  1442 	
  1495 	
  1443 }
  1496 };
  1444 
  1497