|
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( |
|
58
|
6 |
'<li class="Rk-Bin-Item" data-image="<%-static_url%>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="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></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%>">' |
|
44
|
12 |
+ '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></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); |
|
42
|
19 |
this.refresh(); |
|
|
20 |
} |
|
|
21 |
|
|
44
|
22 |
Rkns.Ldt.ProjectBin.prototype.render = function(searchstr) { |
|
|
23 |
if (searchstr) { |
|
|
24 |
var rxbase = searchstr.replace(/(\W)/g,'\\$1'), |
|
|
25 |
_rgxp = new RegExp('('+rxbase+')','gi'), |
|
|
26 |
rxtest = new RegExp(rxbase,'i') |
|
|
27 |
} |
|
|
28 |
function highlight(_text) { |
|
|
29 |
return searchstr ? _text.replace(_rgxp, "<span class='searchmatch'>$1</span>") : _text; |
|
|
30 |
} |
|
26
|
31 |
function convertTC(_ms) { |
|
|
32 |
function pad(_n) { |
|
|
33 |
var _res = _n.toString(); |
|
|
34 |
while (_res.length < 2) { |
|
|
35 |
_res = '0' + _res; |
|
|
36 |
} |
|
|
37 |
return _res; |
|
|
38 |
} |
|
|
39 |
var _totalSeconds = Math.abs(Math.floor(_ms/1000)), |
|
|
40 |
_hours = Math.floor(_totalSeconds / 3600), |
|
|
41 |
_minutes = (Math.floor(_totalSeconds / 60) % 60), |
|
|
42 |
_seconds = _totalSeconds % 60, |
|
|
43 |
_res = ''; |
|
|
44 |
if (_hours) { |
|
|
45 |
_res += pad(_hours) + ':' |
|
|
46 |
} |
|
|
47 |
_res += pad(_minutes) + ':' + pad(_seconds); |
|
|
48 |
return _res; |
|
|
49 |
} |
|
44
|
50 |
|
|
|
51 |
var _html = '<li><h3>Tags</h3></li>', |
|
|
52 |
_projtitle = this.data.meta["dc:title"], |
|
|
53 |
_this = this, |
|
|
54 |
count = 0; |
|
|
55 |
_this.title_$.text('LDT Project: "' + _projtitle + '"'); |
|
|
56 |
Rkns._(_this.data.tags).map(function(_tag) { |
|
|
57 |
var _title = _tag.meta["dc:title"]; |
|
|
58 |
if (searchstr && !rxtest.test(_title)) { |
|
|
59 |
return; |
|
|
60 |
} |
|
|
61 |
count++; |
|
|
62 |
_html += _this.tagTemplate({ |
|
|
63 |
ldt_platform: _this.ldt_platform, |
|
|
64 |
title: _title, |
|
|
65 |
htitle: highlight(_title), |
|
58
|
66 |
encodedtitle : encodeURIComponent(_title), |
|
|
67 |
static_url: _this.renkan.static_url |
|
44
|
68 |
}) |
|
|
69 |
}); |
|
|
70 |
_html += '<li><h3>Annotations</h3></li>'; |
|
|
71 |
Rkns._(_this.data.annotations).map(function(_annotation) { |
|
|
72 |
var _description = _annotation.content.description, |
|
|
73 |
_title = _annotation.content.title.replace(_description,""); |
|
|
74 |
if (searchstr && !rxtest.test(_title) && !rxtest.test(_description)) { |
|
|
75 |
return; |
|
|
76 |
} |
|
|
77 |
count++; |
|
|
78 |
var _duration = _annotation.end - _annotation.begin, |
|
|
79 |
_img = ( |
|
|
80 |
(_annotation.content && _annotation.content.img && _annotation.content.img.src) |
|
|
81 |
? _annotation.content.img.src |
|
58
|
82 |
: ( _duration ? _this.renkan.static_url+"img/ldt-segment.png" : _this.renkan.static_url+"img/ldt-point.png" ) |
|
44
|
83 |
); |
|
|
84 |
_html += _this.annotationTemplate({ |
|
|
85 |
ldt_platform: _this.ldt_platform, |
|
|
86 |
title: _title, |
|
|
87 |
htitle: highlight(_title), |
|
|
88 |
description: _description, |
|
|
89 |
hdescription: highlight(_description), |
|
|
90 |
start: convertTC(_annotation.begin), |
|
|
91 |
end: convertTC(_annotation.end), |
|
|
92 |
duration: convertTC(_duration), |
|
|
93 |
mediaid: _annotation.media, |
|
|
94 |
annotationid: _annotation.id, |
|
58
|
95 |
image: _img, |
|
|
96 |
static_url: _this.renkan.static_url |
|
44
|
97 |
}); |
|
|
98 |
}); |
|
|
99 |
|
|
|
100 |
this.main_$.html(_html); |
|
|
101 |
if (searchstr && count) { |
|
|
102 |
this.count_$.text(count).show(); |
|
|
103 |
} else { |
|
|
104 |
this.count_$.hide(); |
|
|
105 |
} |
|
|
106 |
if (searchstr && !count) { |
|
|
107 |
this.$.hide(); |
|
|
108 |
} else { |
|
|
109 |
this.$.show(); |
|
|
110 |
} |
|
|
111 |
_renkan.resizeBins(); |
|
|
112 |
} |
|
|
113 |
|
|
|
114 |
Rkns.Ldt.ProjectBin.prototype.refresh = function() { |
|
|
115 |
var _this = this; |
|
42
|
116 |
Rkns.$.ajax({ |
|
|
117 |
url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id, |
|
|
118 |
dataType: "jsonp", |
|
|
119 |
success: function(_data) { |
|
44
|
120 |
_this.data = _data; |
|
|
121 |
_this.render(); |
|
26
|
122 |
} |
|
42
|
123 |
}); |
|
26
|
124 |
} |