src/widgets/AnnotationsList.js
branchnew-model
changeset 916 ec6849bbbdcc
parent 909 aa0e42229784
child 919 972099304059
equal deleted inserted replaced
915:ba7aab923d08 916:ec6849bbbdcc
    82         _currentTime = 0;
    82         _currentTime = 0;
    83     }
    83     }
    84     this.lastAjaxQuery = _currentTime;
    84     this.lastAjaxQuery = _currentTime;
    85     _currentTime = Math.floor(1000 * _currentTime);
    85     _currentTime = Math.floor(1000 * _currentTime);
    86     var _url = Mustache.to_html(this.ajax_url, {
    86     var _url = Mustache.to_html(this.ajax_url, {
    87         media : this.source.currentMedia.namespacedId.name,
    87         media : this.source.currentMedia.id,
    88         begin : Math.max(0, _currentTime - this.ajax_granularity),
    88         begin : Math.max(0, _currentTime - this.ajax_granularity),
    89         end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity)
    89         end : Math.min(_duration.milliseconds, _currentTime + this.ajax_granularity)
    90     });
    90     });
    91     this.currentSource = this.player.loadMetadata(IriSP._.defaults({
    91     this.currentSource = this.player.loadMetadata(IriSP._.defaults({
    92         "url" : _url
    92         "url" : _url
    97     var _currentTime = this.player.popcorn.currentTime();
    97     var _currentTime = this.player.popcorn.currentTime();
    98     if (typeof _currentTime == "undefined") {
    98     if (typeof _currentTime == "undefined") {
    99         _currentTime = 0;
    99         _currentTime = 0;
   100     }
   100     }
   101     var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000);
   101     var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000);
   102     if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.namespacedId.name !== this.lastMashupAnnotation) {
   102     if (typeof _currentAnnotation !== "undefined" && _currentAnnotation.id !== this.lastMashupAnnotation) {
   103         this.lastMashupAnnotation = _currentAnnotation.namespacedId.name;
   103         this.lastMashupAnnotation = _currentAnnotation.id;
   104         var _currentMedia = _currentAnnotation.getMedia(),
   104         var _currentMedia = _currentAnnotation.getMedia(),
   105             _url = Mustache.to_html(this.ajax_url, {
   105             _url = Mustache.to_html(this.ajax_url, {
   106                 media : _currentMedia.namespacedId.name,
   106                 media : _currentMedia.id,
   107                 begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
   107                 begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
   108                 end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity)
   108                 end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity)
   109             });
   109             });
   110         console.log("Getting", _url);
   110         console.log("Getting", _url);
   111         this.currentSource = this.player.loadMetadata(IriSP._.defaults({
   111         this.currentSource = this.player.loadMetadata(IriSP._.defaults({
   127     var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
   127     var _list = this.annotation_type ? this.currentSource.getAnnotationsByTypeTitle(this.annotation_type) : this.currentSource.getAnnotations();
   128     if (this.mashupMode) {
   128     if (this.mashupMode) {
   129         var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000);
   129         var _currentAnnotation = this.source.currentMedia.getAnnotationAtTime(_currentTime * 1000);
   130         if (typeof _currentAnnotation !== "undefined") {
   130         if (typeof _currentAnnotation !== "undefined") {
   131             _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds();
   131             _currentTime = _currentTime - _currentAnnotation.begin.getSeconds() + _currentAnnotation.annotation.begin.getSeconds();
   132             var _mediaId = _currentAnnotation.getMedia().namespacedId.name;
   132             var _mediaId = _currentAnnotation.getMedia().id;
   133             _list = _list.filter(function(_annotation) {
   133             _list = _list.filter(function(_annotation) {
   134                 return _annotation.getMedia().namespacedId.name === _mediaId;
   134                 return _annotation.getMedia().id === _mediaId;
   135             });
   135             });
   136         }
   136         }
   137     }
   137     }
   138     if (this.searchString) {
   138     if (this.searchString) {
   139         _list = _list.searchByTextFields(this.searchString);
   139         _list = _list.searchByTextFields(this.searchString);
   167                             ? Mustache.to_html(
   167                             ? Mustache.to_html(
   168                                 _this.foreign_url,
   168                                 _this.foreign_url,
   169                                 {
   169                                 {
   170                                     project : _annotation.project,
   170                                     project : _annotation.project,
   171                                     media : _annotation.media.id.replace(/^.*:/,''),
   171                                     media : _annotation.media.id.replace(/^.*:/,''),
   172                                     annotation : _annotation.namespacedId.name,
   172                                     annotation : _annotation.id,
   173                                     annotationType : _annotation.annotationType.id.replace(/^.*:/,'')
   173                                     annotationType : _annotation.annotationType.id.replace(/^.*:/,'')
   174                                 }
   174                                 }
   175                             )
   175                             )
   176                             : '#id=' + _annotation.namespacedId.name
   176                             : '#id=' + _annotation.id
   177                             )
   177                             )
   178                     );
   178                     );
   179                     var _res = {
   179                     var _res = {
   180                         id : _annotation.namespacedId.name,
   180                         id : _annotation.id,
   181                         title : _annotation.title.replace(_annotation.description,''),
   181                         title : _annotation.title.replace(_annotation.description,''),
   182                         description : _annotation.description,
   182                         description : _annotation.description,
   183                         begin : _annotation.begin.toString(),
   183                         begin : _annotation.begin.toString(),
   184                         end : _annotation.end.toString(),
   184                         end : _annotation.end.toString(),
   185                         thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
   185                         thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,