src/js/data.js
author hamidouk
Mon, 10 Oct 2011 16:40:37 +0200
branchpopcorn-port
changeset 58 f92e6c4baae9
parent 44 1e295123f2a1
child 61 dc7b5ed7b02b
permissions -rw-r--r--
Renamed LAYOUT.txt and added sinon.js for mockups.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     1
/* data.js - this file deals with how the players gets and sends data */
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     2
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     3
IriSP.getMetadata = function() {
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     4
	
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     5
	IriSP.jQuery.ajax({
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     6
		  dataType: IriSP.config.metadata.load,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     7
		  url:IriSP.config.metadata.src,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     8
		  success : function( json ){
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
     9
		  
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    10
				IriSP.trace( "ajax", "success" );
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    11
				
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    12
				// START PARSING ----------------------- 
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    13
				if( json === "" ){
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    14
					alert( "Json load error" );
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    15
				} else {							  							  
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    16
					// # CREATE MEDIA  							//
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    17
					// # JUSTE ONE PLAYER FOR THE MOMENT		//
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    18
					//__IriSP.jQuery("<div></div>").appendTo("#output");
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    19
					var MyMedia = new  __IriSP.Media(
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    20
														json.medias[0].id,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    21
														json.medias[0].href,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    22
														json.medias[0]['meta']['dc:duration'],
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    23
														json.medias[0]['dc:title'],
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    24
														json.medias[0]['dc:description']);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    25
					
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    26
					IriSP.trace( "__IriSP.MyApiPlayer",
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    27
														IriSP.config.gui.width+"   "
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    28
														+ IriSP.config.gui.height + " "
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    29
														+ json.medias[0].href + " "
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    30
														+ json.medias[0]['meta']['dc:duration'] + " "
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    31
														+ json.medias[0]['meta']['item']['value']);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    32
					
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    33
					// Create APIplayer
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    34
					IriSP.MyApiPlayer = new __IriSP.APIplayer (
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    35
														IriSP.config.gui.width,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    36
														IriSP.config.gui.height,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    37
														json.medias[0].href,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    38
														json.medias[0]['meta']['dc:duration'],
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    39
														json.medias[0]['meta']['item']['value']);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    40
				
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    41
					// # CREATE THE FIRST LINE  				//
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    42
					IriSP.trace( "__IriSP.init.main","__IriSP.Ligne" );
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    43
					IriSP.MyLdt = new __IriSP.Ligne(
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    44
														json['annotation-types'][0].id,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    45
														json['annotation-types'][0]['dc:title'],
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    46
														json['annotation-types'][0]['dc:description'],
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    47
														json.medias[0]['meta']['dc:duration']);			
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    48
					
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    49
					// CREATE THE TAG CLOUD 					//
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    50
					IriSP.trace( "__IriSP.init.main","__IriSP.Tags" );
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    51
					IriSP.MyTags =  new __IriSP.Tags( json.tags );
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    52
				
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    53
					// CREATE THE ANNOTATIONS  				    //
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    54
					// JUSTE FOR THE FIRST TYPE   			 	//
44
1e295123f2a1 added a FIXME
hamidouk
parents: 31
diff changeset
    55
					/* FIXME: make it support more than one ligne de temps */
31
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    56
					IriSP.jQuery.each( json.annotations, function(i,item) {
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    57
						if (item.meta['id-ref'] == IriSP.MyLdt.id) {
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    58
							//__IriSP.trace("__IriSP.init.main","__IriSP.MyLdt.addAnnotation");
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    59
							IriSP.MyLdt.addAnnotation(
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    60
										item.id,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    61
										item.begin,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    62
										item.end,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    63
										item.media,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    64
										item.content.title,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    65
										item.content.description,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    66
										item.content.color,
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    67
										item.tags);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    68
						}
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    69
							//MyTags.addAnnotation(item);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    70
					} );	
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    71
					IriSP.jQuery.each( json.lists, function(i,item) {
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    72
						IriSP.trace("lists","");
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    73
					} );	
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    74
					IriSP.jQuery.each( json.views, function(i,item) {
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    75
						IriSP.trace("views","");
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    76
					} );	
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    77
				}
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    78
				// END PARSING ----------------------- //  
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    79
			
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    80
							
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    81
		}, error : function(data){
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    82
			  alert("ERROR : "+data);
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    83
		}
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    84
	  });	
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    85
cbb1425bc769 begun breaking the code across multiple files.
hamidouk
parents:
diff changeset
    86
}