finished going through the widgets to add stricter line checking. popcorn-port
authorhamidouk
Mon, 09 Jan 2012 11:15:13 +0100
branchpopcorn-port
changeset 595 29d86e6c61a6
parent 594 96af41097260
child 596 a0d2c5b96bee
finished going through the widgets to add stricter line checking.
src/js/serializers/JSONSerializer.js
src/js/widgets/annotationsListWidget.js
src/js/widgets/annotationsWidget.js
src/js/widgets/polemicWidget.js
test/integration/polemic-platform.htm
--- a/src/js/serializers/JSONSerializer.js	Fri Jan 06 17:20:39 2012 +0100
+++ b/src/js/serializers/JSONSerializer.js	Mon Jan 09 11:15:13 2012 +0100
@@ -228,18 +228,21 @@
    currentTime is in seconds.
    
    @param currentTime the time at which we search.
+   @param (optional) the if of the type of the annotations we want to get.
  */
 
-IriSP.JSONSerializer.prototype.currentAnnotations = function(currentTime) {
+IriSP.JSONSerializer.prototype.currentAnnotations = function(currentTime, id) {
   var view;
   var currentTimeMs = 1000 * currentTime;
 
-  var id = this.getChapitrage();
-  /* FIXME: ugly */
-  if (typeof(id) === "undefined")    
-    var legal_ids = this.getNonTweetIds();
-  else 
-    legal_ids = [id];
+  if (typeof(id) === "undefined") {
+    id = this.getChapitrage();
+  
+    if (typeof(id) === "undefined")    
+      var legal_ids = this.getNonTweetIds();
+    else 
+      legal_ids = [id];
+  }
   
   var ret_array = [];
   
--- a/src/js/widgets/annotationsListWidget.js	Fri Jan 06 17:20:39 2012 +0100
+++ b/src/js/widgets/annotationsListWidget.js	Mon Jan 09 11:15:13 2012 +0100
@@ -14,7 +14,7 @@
 IriSP.AnnotationsListWidget.prototype.draw = function() {
   var _this = this;
 
-  var view_type = this._serializer.getNonTweetIds()[0];
+  var view_type = this._serializer.getContributions();
   var annotations = this._serializer._data.annotations;
   var list = [];
 
--- a/src/js/widgets/annotationsWidget.js	Fri Jan 06 17:20:39 2012 +0100
+++ b/src/js/widgets/annotationsWidget.js	Mon Jan 09 11:15:13 2012 +0100
@@ -55,7 +55,11 @@
 
   this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
                         IriSP.wrap(this, this.handleAnnotateSignal));  
-  var legal_ids = this._serializer.getNonTweetIds();
+  var legal_ids = [];
+  if (typeof(this._serializer.getChapitrage()) !== "undefined")
+    legal_ids.push(this._serializer.getChapitrage());
+  else 
+    legal_ids = this._serializer.getNonTweetIds();
   
   var annotations = this._serializer._data.annotations;
   var i;
--- a/src/js/widgets/polemicWidget.js	Fri Jan 06 17:20:39 2012 +0100
+++ b/src/js/widgets/polemicWidget.js	Mon Jan 09 11:15:13 2012 +0100
@@ -136,23 +136,24 @@
       this._serializer.sync(function(data) { loaded_callback.call(self, data) });
       
       function loaded_callback (json) {
-        
-      var view_type = this._serializer.getTweetIds()[0];        
+      var view_type = this._serializer.getTweets();
+
       if (typeof(view_type) === "undefined") {
-        // default to guessing if nothing else works.
-        view = json.views[0];
-        
-        // 
-        tweet_annot_type = null;
-        if(typeof(view.annotation_types) !== "undefined") {
-          if (view.annotation_types.length >= 1) {
-            view_type = view.annotation_types[0];
-          } else {
-            console.log("PolemicWidget: invalid file");
-          }
-        }      
+        var view_type = this._serializer.getTweetIds()[0];      
+        if (typeof(view_type) === "undefined") {
+          // default to guessing if nothing else works.
+          view = json.views[0];
+          
+          if(typeof(view.annotation_types) !== "undefined") {
+            if (view.annotation_types.length >= 1) {
+              view_type = view.annotation_types[0];
+            } else {
+              console.log("PolemicWidget: invalid file");
+            }
+          }      
+        }
       }
-        
+      
       for(var i = 0; i < json.annotations.length; i++) {
         var item = json.annotations[i];        
         var MyTime  = Math.floor(item.begin/duration*lineSize);
--- a/test/integration/polemic-platform.htm	Fri Jan 06 17:20:39 2012 +0100
+++ b/test/integration/polemic-platform.htm	Mon Jan 09 11:15:13 2012 +0100
@@ -21,6 +21,7 @@
   <div id="LdtPlayer"></div>
   
   <script  type="text/javascript">
+    var project_id = "af3b99e4-b695-11df-bfde-00145ea4a2be";
     var config = {            
         gui:{
             width:650,
@@ -31,7 +32,7 @@
             {type: "SliderWidget",
 						 metadata:{
 						  format:'cinelab',
-						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						  type:'json'}
 						},            
             
@@ -39,20 +40,20 @@
              container: "AnnotationsListContainer",             
 						 metadata:{
 						  format:'cinelab',
-						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						  type:'json'}
 						},
             {type: "PlayerWidget", // please note that type refers directly to the constructor of the widget.
              mode: "radio",
              metadata:{
               format:'cinelab',
-              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
               type:'json'}
             },
             {type: "SegmentsWidget",
              metadata:{
               format:'cinelab',
-              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
               type:'json'},
              requires: [{
               type: "TooltipWidget",
@@ -66,13 +67,13 @@
             {type: "SliceWidget",
              metadata:{
               format:'cinelab',
-              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
               type:'json'}
             },            
             {type: "ArrowWidget",
              metadata:{
               format:'cinelab',
-              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+              src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
               type:'json'}
             },
 
@@ -80,19 +81,19 @@
             {type: "AnnotationsWidget",
 						 metadata:{
 						  format:'cinelab',
-						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						  type:'json'}
 						},
             {type: "TweetsWidget",
 						 metadata:{
 						  format:'cinelab',
-						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						  type:'json'}
 						},
             {type: "createAnnotationWidget",
 						 metadata:{
 						  format:'cinelab',
-						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+						  src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						  type:'json'}
 						}      
             ]
@@ -108,7 +109,7 @@
                { type: "MediaFragment",
   			     		 metadata:{
 	  	  			   format:'cinelab',
-		  				   src:'http://localhost//pf/ldtplatform/ldt/cljson/id/af3b99e4-b695-11df-bfde-00145ea4a2be',
+		  				   src:'http://localhost//pf/ldtplatform/ldt/cljson/id/' + project_id,
 						     type:'json'}
 						}]