|
34
|
1 |
Rkns.Ldt = {} |
|
26
|
2 |
|
|
34
|
3 |
Rkns.Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin); |
|
|
4 |
|
|
|
5 |
Rkns.Ldt.ProjectBin.prototype.tagTemplate = Rkns._.template( |
|
37
|
6 |
'<li class="Rk-Bin-Item" data-image="img/ldt-tag.png" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">' |
|
|
7 |
+ '<img class="Rk-Ldt-Tag-Icon" src="img/ldt-tag.png" /><h4><%-title%></h4><div class="Rk-Clear"></div></li>' |
|
26
|
8 |
); |
|
|
9 |
|
|
34
|
10 |
Rkns.Ldt.ProjectBin.prototype.annotationTemplate = Rkns._.template( |
|
37
|
11 |
'<li class="Rk-Bin-Item" data-image="<%=image%>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' |
|
|
12 |
+ '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%-title%></h4><p><%-description%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>' |
|
26
|
13 |
); |
|
|
14 |
|
|
34
|
15 |
Rkns.Ldt.ProjectBin.prototype._init = function(_renkan, _opts) { |
|
26
|
16 |
this.proj_id = _opts.project_id; |
|
28
|
17 |
this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/"; |
|
26
|
18 |
this.title_$.html(_opts.title); |
|
|
19 |
var _this = this; |
|
|
20 |
function convertTC(_ms) { |
|
|
21 |
function pad(_n) { |
|
|
22 |
var _res = _n.toString(); |
|
|
23 |
while (_res.length < 2) { |
|
|
24 |
_res = '0' + _res; |
|
|
25 |
} |
|
|
26 |
return _res; |
|
|
27 |
} |
|
|
28 |
var _totalSeconds = Math.abs(Math.floor(_ms/1000)), |
|
|
29 |
_hours = Math.floor(_totalSeconds / 3600), |
|
|
30 |
_minutes = (Math.floor(_totalSeconds / 60) % 60), |
|
|
31 |
_seconds = _totalSeconds % 60, |
|
|
32 |
_res = ''; |
|
|
33 |
if (_hours) { |
|
|
34 |
_res += pad(_hours) + ':' |
|
|
35 |
} |
|
|
36 |
_res += pad(_minutes) + ':' + pad(_seconds); |
|
|
37 |
return _res; |
|
|
38 |
} |
|
|
39 |
Rkns.$.getJSON( |
|
28
|
40 |
this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id + '?callback=?', |
|
26
|
41 |
function(_data) { |
|
|
42 |
var _html = '<li><h3>Tags</h3></li>', |
|
|
43 |
_projtitle = _data.meta["dc:title"]; |
|
|
44 |
_this.title_$.html('LDT Project: "' + _projtitle + '"'); |
|
|
45 |
_html += Rkns._(_data.tags).map(function(_tag) { |
|
|
46 |
var _title = _tag.meta["dc:title"] |
|
|
47 |
return _this.tagTemplate({ |
|
28
|
48 |
ldt_platform: _this.ldt_platform, |
|
26
|
49 |
title: _title, |
|
|
50 |
encodedtitle : encodeURIComponent(_title) |
|
|
51 |
}) |
|
|
52 |
}).join(""); |
|
|
53 |
_html += '<li><h3>Annotations</h3></li>'; |
|
|
54 |
_html += Rkns._(_data.annotations).map(function(_annotation) { |
|
|
55 |
var _description = _annotation.content.description, |
|
|
56 |
_title = _annotation.content.title.replace(_description,""), |
|
37
|
57 |
_duration = _annotation.end - _annotation.begin, |
|
|
58 |
_img = ( |
|
|
59 |
(_annotation.content && _annotation.content.img && _annotation.content.img.src) |
|
|
60 |
? _annotation.content.img.src |
|
|
61 |
: ( _duration ? "img/ldt-segment.png" : "img/ldt-point.png" ) |
|
|
62 |
); |
|
26
|
63 |
return _this.annotationTemplate({ |
|
28
|
64 |
ldt_platform: _this.ldt_platform, |
|
26
|
65 |
title: _title, |
|
|
66 |
description: _description, |
|
|
67 |
start: convertTC(_annotation.begin), |
|
|
68 |
end: convertTC(_annotation.end), |
|
|
69 |
duration: convertTC(_duration), |
|
|
70 |
mediaid: _annotation.media, |
|
|
71 |
annotationid: _annotation.id, |
|
37
|
72 |
image: _img |
|
26
|
73 |
}); |
|
|
74 |
}).join(""); |
|
|
75 |
|
|
|
76 |
_this.main_$.html(_html); |
|
|
77 |
_renkan.resizeBins(); |
|
|
78 |
} |
|
|
79 |
); |
|
|
80 |
} |