src/js/widgets/annotationsListWidget.js
branchpopcorn-port
changeset 585 44a4a4a179c1
child 588 78cf49152d4a
equal deleted inserted replaced
584:f90c88ab9a26 585:44a4a4a179c1
       
     1 IriSP.AnnotationsListWidget = function(Popcorn, config, Serializer) {
       
     2   IriSP.Widget.call(this, Popcorn, config, Serializer);
       
     3 };
       
     4 
       
     5 
       
     6 IriSP.AnnotationsListWidget.prototype = new IriSP.Widget();
       
     7 
       
     8 IriSP.AnnotationsListWidget.prototype.clear = function() {
       
     9 };
       
    10 
       
    11 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {   
       
    12 };
       
    13 
       
    14 IriSP.AnnotationsListWidget.prototype.draw = function() {
       
    15   var _this = this;
       
    16 
       
    17   var view_type = this._serializer.getNonTweetIds()[0];
       
    18   var annotations = this._serializer._data.annotations;
       
    19   var list = [];
       
    20   
       
    21   if (typeof(view_type) === "undefined") {
       
    22     console.log("not type suitable for display");
       
    23     return;
       
    24   }
       
    25   
       
    26   for (i = 0; i < annotations.length; i++) {
       
    27     var annotation = annotations[i];
       
    28 
       
    29     /* filter the annotations whose type is not the one we want */
       
    30     if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
       
    31           && annotation.meta["id-ref"] != view_type) {
       
    32         continue;
       
    33     }
       
    34 
       
    35     var a = annotation;
       
    36     var obj = {};
       
    37     console.log(a);
       
    38     obj["id"] = a.id;
       
    39     obj["title"] = a.content.title;
       
    40     obj["desc"] = a.content.description;
       
    41     obj["begin"] = IriSP.msToTime(a.begin);
       
    42     obj["end"] = IriSP.msToTime(a.end);
       
    43     
       
    44     list.push(obj);
       
    45   }
       
    46 
       
    47   var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
       
    48   this.selector.append(widgetMarkup);
       
    49 };