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