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