| author | hamidouk |
| Mon, 09 Jan 2012 17:23:08 +0100 | |
| branch | popcorn-port |
| changeset 602 | b35862f9b0b0 |
| parent 599 | a5a5e70d46a7 |
| child 603 | 58dfdafb5410 |
| 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 |
|
| 602 | 35 |
console.log(currentTime); |
| 585 | 36 |
for (i = 0; i < annotations.length; i++) { |
37 |
var annotation = annotations[i]; |
|
38 |
||
39 |
/* filter the annotations whose type is not the one we want */ |
|
40 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
|
41 |
&& annotation.meta["id-ref"] != view_type) { |
|
42 |
continue; |
|
43 |
} |
|
44 |
||
| 602 | 45 |
/* only get the annotations happening in the current chapter */ |
46 |
if (annotation.begin > currentTime || annotation.end <= currentTime) { |
|
47 |
continue; |
|
48 |
} |
|
49 |
|
|
| 585 | 50 |
var a = annotation; |
51 |
var obj = {}; |
|
| 588 | 52 |
|
| 585 | 53 |
obj["id"] = a.id; |
54 |
obj["title"] = a.content.title; |
|
55 |
obj["desc"] = a.content.description; |
|
56 |
obj["begin"] = IriSP.msToTime(a.begin); |
|
57 |
obj["end"] = IriSP.msToTime(a.end); |
|
| 588 | 58 |
|
| 585 | 59 |
list.push(obj); |
60 |
} |
|
61 |
||
62 |
var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list}); |
|
| 599 | 63 |
this.selector.html(widgetMarkup); |
64 |
}; |
|
65 |
||
66 |
IriSP.AnnotationsListWidget.prototype.draw = function() { |
|
67 |
||
68 |
this.drawList(); |
|
69 |
this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, this.redraw)); |
|
| 602 | 70 |
this._Popcorn.listen("seeked", IriSP.wrap(this, this.redraw)); |
| 599 | 71 |
}; |
72 |
||
73 |
IriSP.AnnotationsListWidget.prototype.redraw = function() { |
|
74 |
this.drawList(); |
|
| 585 | 75 |
}; |