src/js/widgets/annotationsListWidget.js
branchpopcorn-port
changeset 603 58dfdafb5410
parent 602 b35862f9b0b0
child 605 e1a6f73038b4
equal deleted inserted replaced
602:b35862f9b0b0 603:58dfdafb5410
    30   if (typeof(view_type) === "undefined") {
    30   if (typeof(view_type) === "undefined") {
    31     console.log("no type suitable for display");
    31     console.log("no type suitable for display");
    32     return;
    32     return;
    33   }
    33   }
    34 
    34 
    35   console.log(currentTime);
       
    36   for (i = 0; i < annotations.length; i++) {
    35   for (i = 0; i < annotations.length; i++) {
    37     var annotation = annotations[i];
    36     var annotation = annotations[i];
    38 
    37 
    39     /* filter the annotations whose type is not the one we want */
    38     /* filter the annotations whose type is not the one we want */
    40     if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
    39     if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
    41           && annotation.meta["id-ref"] != view_type) {
    40           && annotation.meta["id-ref"] != view_type) {
    42         continue;
    41         continue;
    43     }
    42     }
    44 
    43 
    45     /* only get the annotations happening in the current chapter */
    44     /* only get the annotations happening in the current chapter */
    46     if (annotation.begin > currentTime || annotation.end <= currentTime) {
    45     if (!(annotation.begin <= currentTime * 1000 && annotation.end > currentTime * 1000)) {        
    47         continue;
    46         continue;
    48     }
    47     }
    49     
    48 
    50     var a = annotation;
    49     var a = annotation;
    51     var obj = {};
    50     var obj = {};
    52 
    51 
    53     obj["id"] = a.id;
    52     obj["id"] = a.id;
    54     obj["title"] = a.content.title;
    53     obj["title"] = a.content.title;
    55     obj["desc"] = a.content.description;
    54     obj["desc"] = a.content.description;
    56     obj["begin"] = IriSP.msToTime(a.begin);
    55     obj["begin"] = IriSP.msToTime(annotation.begin);
    57     obj["end"] = IriSP.msToTime(a.end);
    56     obj["end"] = IriSP.msToTime(annotation.end);
    58 
    57 
    59     list.push(obj);
    58     list.push(obj);
    60   }
    59   }
    61 
    60 
    62   var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
    61   var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});