| author | hamidouk |
| Tue, 10 Jan 2012 11:40:31 +0100 | |
| branch | popcorn-port |
| changeset 603 | 58dfdafb5410 |
| parent 602 | b35862f9b0b0 |
| child 605 | e1a6f73038b4 |
| permissions | -rw-r--r-- |
| 585 | 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 |
||
| 588 | 11 |
IriSP.AnnotationsListWidget.prototype.clearWidget = function() { |
| 585 | 12 |
}; |
13 |
||
| 599 | 14 |
/** draw the annotation list */ |
15 |
IriSP.AnnotationsListWidget.prototype.drawList = function() { |
|
| 585 | 16 |
var _this = this; |
17 |
||
|
595
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
588
diff
changeset
|
18 |
var view_type = this._serializer.getContributions(); |
| 585 | 19 |
var annotations = this._serializer._data.annotations; |
| 602 | 20 |
var currentTime = this._Popcorn.currentTime(); |
21 |
|
|
22 |
/* happens when the player hasn't yet loaded */ |
|
23 |
if (typeof(currentTime) === "undefined") { |
|
24 |
window.setTimeout(IriSP.wrap(this, this.drawList), 4000); |
|
25 |
return; |
|
26 |
} |
|
27 |
|
|
| 585 | 28 |
var list = []; |
| 588 | 29 |
|
| 585 | 30 |
if (typeof(view_type) === "undefined") { |
| 602 | 31 |
console.log("no type suitable for display"); |
| 585 | 32 |
return; |
33 |
} |
|
| 588 | 34 |
|
| 585 | 35 |
for (i = 0; i < annotations.length; i++) { |
36 |
var annotation = annotations[i]; |
|
37 |
||
38 |
/* filter the annotations whose type is not the one we want */ |
|
39 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
|
40 |
&& annotation.meta["id-ref"] != view_type) { |
|
41 |
continue; |
|
42 |
} |
|
43 |
||
| 602 | 44 |
/* only get the annotations happening in the current chapter */ |
| 603 | 45 |
if (!(annotation.begin <= currentTime * 1000 && annotation.end > currentTime * 1000)) { |
| 602 | 46 |
continue; |
47 |
} |
|
| 603 | 48 |
|
| 585 | 49 |
var a = annotation; |
50 |
var obj = {}; |
|
| 588 | 51 |
|
| 585 | 52 |
obj["id"] = a.id; |
53 |
obj["title"] = a.content.title; |
|
54 |
obj["desc"] = a.content.description; |
|
| 603 | 55 |
obj["begin"] = IriSP.msToTime(annotation.begin); |
56 |
obj["end"] = IriSP.msToTime(annotation.end); |
|
| 588 | 57 |
|
| 585 | 58 |
list.push(obj); |
59 |
} |
|
60 |
||
61 |
var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list}); |
|
| 599 | 62 |
this.selector.html(widgetMarkup); |
63 |
}; |
|
64 |
||
65 |
IriSP.AnnotationsListWidget.prototype.draw = function() { |
|
66 |
||
67 |
this.drawList(); |
|
68 |
this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, this.redraw)); |
|
| 602 | 69 |
this._Popcorn.listen("seeked", IriSP.wrap(this, this.redraw)); |
| 599 | 70 |
}; |
71 |
||
72 |
IriSP.AnnotationsListWidget.prototype.redraw = function() { |
|
73 |
this.drawList(); |
|
| 585 | 74 |
}; |