src/js/serializers/JSONSerializer.js
branchcalage-segmentsWidget
changeset 513 4589b90fe1ad
parent 395 5766e8238aaf
child 528 a5894f09825a
equal deleted inserted replaced
512:9206956532c3 513:4589b90fe1ad
   240       ret_array.push(annotation);
   240       ret_array.push(annotation);
   241   }
   241   }
   242 
   242 
   243   return ret_array;
   243   return ret_array;
   244 };
   244 };
       
   245 
       
   246 
       
   247 /* this function returns a list of ids of tweet lines */
       
   248 IriSP.JSONSerializer.prototype.getTweetIds = function() {
       
   249   if (typeof(this._data.lists) === "undefined" || this._data.lists === null)
       
   250     return [];
       
   251 
       
   252   var tweetsId = [];
       
   253   
       
   254   /* first get the list containing the tweets */
       
   255   var tweets = IriSP.underscore.filter(this._data.lists, function(entry) { return entry.id.indexOf("tweet") !== -1 });
       
   256   
       
   257   // FIXME: collect tweets from multiple sources ?
       
   258   tweetsId = IriSP.underscore.pluck(tweets[0].items, "id-ref");
       
   259 
       
   260   return tweetsId;
       
   261 };
       
   262 
       
   263 /* this function returns a list of lines which are not tweet lines */
       
   264 IriSP.JSONSerializer.prototype.getNonTweetIds = function() {
       
   265   if (typeof(this._data.lists) === "undefined" || this._data.lists === null)
       
   266     return [];
       
   267   
       
   268   /* get all the ids */
       
   269   var ids = IriSP.underscore.map(this._data.lists, function(entry) {                                                         
       
   270                                                          return IriSP.underscore.pluck(entry.items, "id-ref"); });
       
   271                                                          
       
   272   var illegal_values = this.getTweetIds();
       
   273   return IriSP.underscore.difference(ids, illegal_values);
       
   274   
       
   275 };