web/res/metadataplayer/test/chartTimeline2.html
changeset 99 6cb4d10f0b8b
child 133 9578d3ddce17
equal deleted inserted replaced
97:861cae17abda 99:6cb4d10f0b8b
       
     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
     2 <html xmlns="http://www.w3.org/1999/xhtml">
       
     3 <head>
       
     4 <title>Example raphael</title>
       
     5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       
     6 
       
     7 </head>
       
     8 <body>
       
     9 
       
    10 <div id="Ldt-output" name="Ldt-output" style="position:absolute;left:600px;" ></div>
       
    11 <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
       
    12 <script type="text/javascript" src="raphael-min.js"></script>
       
    13 
       
    14 <div>
       
    15 <!--
       
    16 
       
    17 -->
       
    18 
       
    19 
       
    20 
       
    21 <script type='text/javascript' src='http://www.iri.centrepompidou.fr/dev/ldt/static/ldt/js/LdtPlayer.min.js'></script>
       
    22   <div id="player_project_13b0aa52-336b-11e0-b233-00145ea49a02_embed" class="iri_player_embed"/>
       
    23   <script type="text/javascript">
       
    24 	var config = {
       
    25 			metadata:{
       
    26 				format:'cinelab',
       
    27 				src:'metadata.json',
       
    28 				load:'json'},
       
    29 			gui:{
       
    30 				width:650,
       
    31 				height:480,
       
    32 				mode:'video',
       
    33 				container:'player_project_13b0aa52-336b-11e0-b233-00145ea49a02_embed',
       
    34 				debug:false,
       
    35 				css:'http://www.iri.centrepompidou.fr//dev/ldt/static/ldt/css/LdtPlayer.css'},
       
    36 			player:{
       
    37 				type:'jwplayer',
       
    38 				src:'http://www.iri.centrepompidou.fr//dev/ldt/static/ldt/swf/player.swf'}
       
    39 		};
       
    40 	__IriSP.init(config);     
       
    41 </script>
       
    42 <div id="charttimeline" style="position:relative;display:block;">ici</div>
       
    43 
       
    44 <script type="text/javascript"> 
       
    45 
       
    46 // v1 ::
       
    47 //		- config
       
    48 // 		- organisation classe
       
    49 // 		- rollover !! 
       
    50 // 		- legend  !!
       
    51 // 		- seek !!
       
    52 //		- time cursor
       
    53 /*
       
    54 	1 | 1D973D > vert 	> ++ > OK
       
    55 	2 | C5A62D > orange	> ?? > Q
       
    56 	3 | CE0A15 > rouge  > -- > KO
       
    57 	4 | 036AAE > bleu   > == > REF
       
    58 	5 | 585858 > gris   > NQ > ""
       
    59 */
       
    60 	
       
    61 
       
    62 	// configuration 
       
    63 	var config = {
       
    64 					target:"charttimeline",
       
    65 					x:8,
       
    66 					y:438,
       
    67 					width:650,
       
    68 					height:70,
       
    69 					heightmax:70
       
    70 					}
       
    71 	// Make and define the Raphael area
       
    72 	//var paper = Raphael(document.getElementById(config.target),config.width, config.height);
       
    73 	var paper = Raphael(config.x,config.y,config.width, config.height);
       
    74 	paper.rect(0,20,config.width,config.heightmax-20).attr({fill:"#fff","stroke-width":0.1,opacity: 0.2});	
       
    75 	paper.rect(0,20,config.width,1).attr({fill:"#fff",stroke: "none"});	
       
    76 	
       
    77 	// variable 
       
    78 	var yCoef	  = 2; 					// coef for height of 1 tweet 
       
    79 	var frameSize = 5; 					// frame size 
       
    80 	var margin 	  = 1;					// marge between frame
       
    81 	var lineSize  = 650;				// timeline pixel width 
       
    82 	var nbrframes = lineSize/frameSize; // frame numbers
       
    83 	var numberOfTweet=0;				// number of tweet overide later 
       
    84 	var duration  = 4299820 ;			// timescale width 
       
    85 	var frameLenght =lineSize/frameSize;// frame timescale	
       
    86 	var timeline;
       
    87 	var colors  = new Array("","#1D973D","#C5A62D","#CE0A15","#036AAE","#585858");
       
    88 	
       
    89 	// array 
       
    90 	var tweets  = new Array();
       
    91 	var element = new Array();
       
    92 	var cluster = new Array();
       
    93 	var frames  = new Array(frameLenght);
       
    94 	var slices  = new Array();
       
    95 	
       
    96 	
       
    97 	// Classes =======================================================================
       
    98 	var Frames = function(){
       
    99 		
       
   100 		var Myclusters;
       
   101 		var x;
       
   102 		var y;
       
   103 		var width;
       
   104 		var height;
       
   105 	};
       
   106 	Frames = function(json){
       
   107 		// make my clusters
       
   108 		// ou Frame vide 
       
   109 	};
       
   110 	Frames.prototype.draw = function(){
       
   111 	}
       
   112 	Frames.prototype.zoom = function(){
       
   113 	}
       
   114 	Frames.prototype.inside = function(){
       
   115 	}
       
   116 	var Clusters = function(){
       
   117 		var Object;
       
   118 		var yDist;
       
   119 		var x;
       
   120 		var y;
       
   121 		var width;
       
   122 		var height;
       
   123 	};
       
   124 	Clusters = function(json){
       
   125 		// make my object
       
   126 	};
       
   127 	var Tweet = function(){
       
   128 	}
       
   129 	// Classes =======================================================================
       
   130 	
       
   131 	
       
   132 
       
   133 
       
   134 	// trace function 
       
   135 	var traceNum = 0;
       
   136 	function trace(msg,value){
       
   137 		traceNum += 1;
       
   138 		$("<div>"+traceNum+" - "+msg+" : "+value+"</div>").appendTo("#Ldt-output");
       
   139 	}
       
   140 	
       
   141 	// Refactoring (parametere) ************************************************************
       
   142 	// color translastion
       
   143 	function colorTranslation(value){
       
   144 		if(value == "Q"){
       
   145 			return 2;
       
   146 		}else if(value =="REF"){
       
   147 			return 4;
       
   148 		}else if(value =="OK"){
       
   149 			return 1;
       
   150 		}else if(value =="KO"){
       
   151 			return 3;
       
   152 		}else if(value ==""){
       
   153 			return 5;
       
   154 		}
       
   155 	}
       
   156 	
       
   157 	
       
   158 	// Refactoring (parametere) ************************************************************
       
   159 	// load tweets send in parameters 
       
   160 	$.ajax({
       
   161 	  dataType: "json",
       
   162 	  url:"metadata.json",
       
   163 	  success : function(json){
       
   164 		trace("load","");
       
   165 			$.each(json.annotations, function(i,item) {
       
   166 				
       
   167 				var MyTime  = Math.floor(item.begin/duration*lineSize);
       
   168 				var Myframe = Math.floor(MyTime/lineSize*frameLenght);
       
   169 
       
   170 				if (item.content['polemics'] != undefined) {
       
   171 					if (item.content['polemics'][0] != null) {
       
   172 						
       
   173 							for(var j=0; j<item.content['polemics'].length; j++){
       
   174 
       
   175 									tweets[numberOfTweet] = {
       
   176 												id:i,
       
   177 												qualification:colorTranslation(item.content['polemics'][j]),
       
   178 												yIndicator:MyTime,
       
   179 												yframe:Myframe
       
   180 												}
       
   181 									numberOfTweet+=1;
       
   182 							}
       
   183 					}else{
       
   184 						//trace("k = ",i);
       
   185 						tweets[numberOfTweet] = {
       
   186 									id:i,
       
   187 									qualification:colorTranslation(""),
       
   188 									yIndicator:MyTime,
       
   189 									yframe:Myframe
       
   190 						}
       
   191 						numberOfTweet+=1;
       
   192 					}
       
   193 					
       
   194 				} else {
       
   195 					//trace("tweet qualification = ","null");
       
   196 				}
       
   197 			});	
       
   198 		trace("======= ",numberOfTweet);
       
   199 	   DrawTweets ();
       
   200 	   
       
   201 	  }
       
   202 	 });
       
   203  
       
   204  
       
   205  	// FishEye Effect 
       
   206 	var zoomCoef = 2;
       
   207 	
       
   208 	function fisheye(id,sens){
       
   209 
       
   210 		if(sens!=0){
       
   211 			// ZOOM IN -----------------
       
   212 			//replaceAll(id,sens);
       
   213 			ZoomIt(id,1,1);
       
   214 			//ZoomIt(id-1,2);
       
   215 			//ZoomIt(id+1,2);
       
   216 		} else {
       
   217 		trace("ici1","");
       
   218 			// ZOOM OUT -----------------
       
   219 			ZoomIt(id,1,0);
       
   220 		trace("ici3","");
       
   221 		}
       
   222 		
       
   223 	}
       
   224 	
       
   225 	function replaceAll(id){
       
   226 		// move every body
       
   227 		for (var i=0; i<slices.length; i++) {
       
   228 			if (slices[i] != undefined || i==id  || i==id+1  || i==id-1  ){	
       
   229 					for (var j=0; j<slices[i].length; j++) {
       
   230 						if (slices[i][j] != undefined){
       
   231 							//trace("anim== ",i+" "+slices[i].length);
       
   232 							slices[i][j].animate({//x:slices[i][j].attr("x")+(zoomCoef*3*frameSize),
       
   233 												  height:slices[i][j].heightStart,
       
   234 												  width:frameSize-margin,
       
   235 												  y:slices[i][j].yStart
       
   236 												  },180);
       
   237 						}
       
   238 					}
       
   239 				
       
   240 			}
       
   241 		}
       
   242 	}
       
   243 	
       
   244 	function ZoomIt(id,coef,sens){
       
   245 		if (slices[id][0].state==0 && sens!=0){
       
   246 				slices[id][0].state=1;
       
   247 				var addEheight = 0;
       
   248 				for (var j=0; j<slices[id].length; j++) {
       
   249 					//trace("",j);
       
   250 					object = slices[id][j];
       
   251 					if (j!=slices[id].length){
       
   252 							Eheight 	= object.attr("height")*zoomCoef/coef;
       
   253 							addEheight += Eheight;
       
   254 							MyWidth 	= object.attr("width")*zoomCoef*4;
       
   255 							object.animate({
       
   256 											height:Eheight,
       
   257 											width:MyWidth,
       
   258 											y:config.heightmax-addEheight
       
   259 											//x:object.attr("x")-(MyWidth/4)
       
   260 											},200);
       
   261 					}
       
   262 			}
       
   263 		} else if (slices[id][0].state==1 && sens!=1){
       
   264 			slices[id][0].state=0;
       
   265 				slices[id][0].state=1;
       
   266 				var addEheight = 0;
       
   267 				for (var j=0; j<slices[id].length; j++) {
       
   268 					//trace("",j);
       
   269 					object = slices[id][j];
       
   270 					if (j!=slices[id].length){
       
   271 						object.animate({ 	  height:object.heightStart,
       
   272 											  width:frameSize-margin,
       
   273 											  y:object.yStart
       
   274 											  },180);					
       
   275 					
       
   276 					}
       
   277 			}
       
   278 		}
       
   279 	}
       
   280 		
       
   281 	// tweet Drawing (in raphael) 
       
   282 	function DrawTweets (){
       
   283 	
       
   284 		//=====================================
       
   285 		// count nbr of cluster and tweet in a frame an save int in "frames"
       
   286 		numberOfTweet = tweets.length;
       
   287 		for(var i=0; i<nbrframes; i++) {	
       
   288 			for(var j=0; j<numberOfTweet; j++) {	
       
   289 				if (i==tweets[j].yframe){
       
   290 					
       
   291 					var k = tweets[j].qualification;
       
   292 					// make array for frame cluster
       
   293 					if(frames[i]==undefined){
       
   294 						frames[i] = new Array();
       
   295 					}
       
   296 					// count clusters
       
   297 					if(frames[i][k]==undefined){
       
   298 						frames[i][k]=1;
       
   299 					}else{
       
   300 						frames[i][k]+=1;
       
   301 					}
       
   302 				}
       
   303 			}
       
   304 		}
       
   305 			
       
   306 		//=====================================
       
   307 		var max 	= 0; // max of tweet by Frame 
       
   308 		for(var i=0; i<nbrframes; i++) {
       
   309 			var moy	= 0;
       
   310 			for (var j=1; j<6; j++){		
       
   311 				if (frames[i]!=undefined){
       
   312 					if (frames[i][j]!=undefined){
       
   313 						moy += frames[i][j]
       
   314 					}
       
   315 				}
       
   316 			}
       
   317 			//trace("frame "+i,moy);
       
   318 			if (moy>max){max=moy;}
       
   319 		}
       
   320 		//trace("frame max =",max);
       
   321 		
       
   322 		//=====================================
       
   323 		// draw cluster of tweet by frame ...
       
   324 		for(var i=0; i<nbrframes; i++) {
       
   325 			var addEheight = 0;
       
   326 			slices[i] =  new Array();
       
   327 			if (frames[i]!=undefined){
       
   328 				for (var j=6; j>0; j--){
       
   329 					if (frames[i][j]!=undefined){
       
   330 						//trace(" x ",i+" "+j);
       
   331 						var Eheight  = frames[i][j]*5;
       
   332 						//				x			y									w					h
       
   333 						e = paper.rect(i*frameSize, config.heightmax-Eheight-addEheight, frameSize-margin, Eheight).attr({stroke:"#00","stroke-width":0.1,  fill: colors[j]});	
       
   334 						e.id = i;
       
   335 						e.state = 0; // 0 petit // 1 grand
       
   336 						e.heightStart = Eheight;
       
   337 						e.yStart = config.heightmax-Eheight-addEheight;
       
   338 						addEheight +=Eheight;
       
   339 						e.mouseover(function () {
       
   340 							fisheye(this.id,1);
       
   341 						}).mouseout(function () {
       
   342 							fisheye(this.id,0);
       
   343 						});;
       
   344 						slices[i].push(e);
       
   345 					}
       
   346 					// ajouter cette objet 
       
   347 				
       
   348 				}
       
   349 			}
       
   350 		}
       
   351 	}
       
   352 	
       
   353 	
       
   354 	
       
   355 	
       
   356 
       
   357 </script>
       
   358 
       
   359 
       
   360 </div>
       
   361 </body>
       
   362 </html>