src/widgets/AnnotationsList.js
changeset 965 eadb7290c325
parent 963 d58d0dcdb640
child 966 c1c762ad1697
equal deleted inserted replaced
964:d7d56ea2d0a6 965:eadb7290c325
   127         _currentTime = this.media.getCurrentTime();
   127         _currentTime = this.media.getCurrentTime();
   128     var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
   128     var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
   129     if (this.mashupMode) {
   129     if (this.mashupMode) {
   130         var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
   130         var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime);
   131         if (typeof _currentAnnotation !== "undefined") {
   131         if (typeof _currentAnnotation !== "undefined") {
   132             _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds();
   132             _currentTime = _currentTime - _currentAnnotation.begin + _currentAnnotation.annotation.begin;
   133             var _mediaId = _currentAnnotation.getMedia().id;
   133             var _mediaId = _currentAnnotation.getMedia().id;
   134             _list = _list.filter(function(_annotation) {
   134             _list = _list.filter(function(_annotation) {
   135                 return _annotation.getMedia().id === _mediaId;
   135                 return _annotation.getMedia().id === _mediaId;
   136             });
   136             });
   137         }
   137         }
   138     }
   138     }
   139     if (this.searchString) {
   139     if (this.searchString) {
   140         _list = _list.searchByTextFields(this.searchString);
   140         _list = _list.searchByTextFields(this.searchString);
   141     }
   141     }
   142     if (this.limit_count) {
   142     if (this.limit_count) {
       
   143         /* Get the n annotations closest to current timecode */
   143         _list = _list.sortBy(function(_annotation) {
   144         _list = _list.sortBy(function(_annotation) {
   144             return Math.abs(_annotation.begin.getSeconds() - _currentTime);
   145             return Math.abs((_annotation.begin + _annotation.end) / 2 - _currentTime);
   145         }).slice(0, this.limit_count)
   146         }).slice(0, this.limit_count)
   146     }
   147     }
   147     if (this.newest_first) {
   148     if (this.newest_first) {
   148         _list = _list.sortBy(function(_annotation) {
   149         _list = _list.sortBy(function(_annotation) {
   149             return -_annotation.created.valueOf();
   150             return -_annotation.created.valueOf();