src/js/serializers/JSONSerializer.js
branchpopcorn-port
changeset 317 a3492448fa9a
parent 150 40cf046b7049
child 320 b693ba1a83be
equal deleted inserted replaced
316:3b11a798f5e4 317:a3492448fa9a
   103 
   103 
   104   };
   104   };
   105   
   105   
   106   return ret;
   106   return ret;
   107 };
   107 };
       
   108 
       
   109 /* takes the currentTime and returns all the annotations that are displayable at the moment 
       
   110    NB: only takes account the first type of annotations - ignores tweets 
       
   111    currentTime is in seconds.
       
   112  */
       
   113 
       
   114 IriSP.JSONSerializer.prototype.currentAnnotations = function(currentTime) {
       
   115   var view;
       
   116   var currentTimeMs = 1000 * currentTime;
       
   117 
       
   118   if (typeof(this._data.views) !== "undefined" && this._data.views !== null)
       
   119      view = this._data.views[0];
       
   120 
       
   121   var view_type = "";
       
   122 
       
   123   if(typeof(view) !== "undefined" && typeof(view.annotation_types) !== "undefined" && view.annotation_types.length >= 1) {
       
   124           view_type = view.annotation_types[0];
       
   125   }
       
   126 
       
   127   var ret_array = [];
       
   128   
       
   129   var i;
       
   130  
       
   131   for (i in this._data.annotations) {
       
   132     var annotation = this._data.annotations[i];
       
   133     if (annotation.meta["id-ref"] == view_type && annotation.begin < currentTimeMs && annotation.end > currentTimeMs)
       
   134       ret_array.push(annotation);
       
   135   }
       
   136   
       
   137   return ret_array;
       
   138 };