-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
218 lines (194 loc) · 8.52 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hackathon 2015 - SUBTTL</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<script src="http://use.typekit.net/gqr8pyu.js"></script>
<script>try{Typekit.load();}catch(e){}</script>
<link href="public/css/subttl.css" rel="stylesheet" type="text/css" media="all"/>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.js"></script>
<script>
angular.module('subttlApp', ['ngSanitize'])
.controller('subtitleSearchCtrl', function ($scope, $sce, $http) {
$scope.hits = {};
$scope.sendPost = function () {
console.log($scope);
var data = {
"query": {
"bool": {
"should": [
{
"match_phrase": {
"subtitles.en": {
"query": $scope.searchText,
"boost": 10.0,
"analyzer": "language_en"
}
}
},
{
"match_phrase": {
"subtitles.fr": {
"query": $scope.searchText,
"boost": 10.0,
"analyzer": "language_fr"
}
}
},
{
"match": {
"subtitles.en": {
"query": $scope.searchText,
"analyzer": "language_en",
"minimum_should_match": "75%"
}
}
},
{
"match": {
"subtitles.fr": {
"query": $scope.searchText,
"analyzer": "language_fr",
"minimum_should_match": "75%"
}
}
}
]
}
},
"highlight": {
"fragment_size": 1000,
"fields": {
"subtitles.en": {
"order": "score"
},
"subtitles.fr": {
"order": "score"
}
}
}
};
$http.post("http://norman-vm1.nfb.ca:9200/nfb_films/films/_search", data).success(function (data, status) {
$scope.hits = data.hits.hits;
for (var i = 0; i < $scope.hits.length; i++) {
var hit = $scope.hits[i];
var sub_en = typeof(hit.highlight['subtitles.en']) != "undefined" ? hit.highlight['subtitles.en'] : [];
var sub_fr = typeof(hit.highlight['subtitles.fr']) != "undefined" ? hit.highlight['subtitles.fr'] : [];
hit["highlight_subtitles"] = [].concat(sub_en, sub_fr);
}
})
}
})
</script>
<style>
</style>
<!-- TODO: Complete this project :) -->
</head>
<body>
<div class="container">
<div ng-app="subttlApp" ng-controller="subtitleSearchCtrl">
<div class="head">
<h1 class="brand">Subttl</h1>
<div class="search-boite big-boite">
<form ng-submit="sendPost()">
<div class="row sfield">
<div class="col-xs-1"><i class="fa fa-quote-left fa-2x"></i></div>
<div class="col-xs-10">
<div class="input-group">
<input ng-model="searchText" type="text" class="form-control input-lg" placeholder="Recherche dans les sous-titres" />
<span class="input-group-btn">
<button type=submit class="btn btn-default btn-lg"> <i class="fa fa-search fa-lg"></i> </button>
</span>
</div>
</div>
<div class="col-xs-1"><i class="fa fa-quote-right fa-2x"></i></div>
</div>
</form>
</div>
</div>
<div class="resultats">
<ul class="liste-resultats list-unstyled">
<li class="resultat" ng-repeat="hit in hits">
<div><img ng-src={{hit._source.thumbnail_url.replace('https:','http:')}} alt=""></div>
<h2 class="titre-film">{{ hit._source.title }}</h2>
<div>
<blockquote ng-repeat="tt in hit.highlight_subtitles">
<div>
<p ng-bind-html="tt.substring(14)"></p>
<footer>
<a data-timecode="{{ tt.substring(1, 13) }}"
data-mp4="http://nfbca-stream.nfbcdn.ca{{ hit._source.video_url }}"
data-vtt-fr="http://norman-vm1.nfb.ca/subttl/FLASH/flash4{{ hit._source.subtitles.ttxt_url_fr.replace('.ttxt', '.vtt') }}"
data-vtt-en="http://norman-vm1.nfb.ca/subttl/FLASH/flash4{{ hit._source.subtitles.ttxt_url_en.replace('.ttxt', '.vtt') }}"
class="play-clip" data-toggle="modal" data-target="#myModal">
<i class="fa fa-clock-o"></i> {{ tt.substring(1, 13) }} <i class="fa fa-play-circle"></i>
</a>
</footer>
</div>
</blockquote>
</div>
</li>
</ul>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<!--p id="timecode"> . </p-->
<video width="100%" style="display:block; margin: 0 auto;" id="videoTag" controls>
<source id="sourceTag" src="" type="video/mp4" />
<track id="trackTag" label="English" kind="subtitles" srclang="en" src="" default />
<p class="warning">Your browser does not support HTML5 video.</p>
</video>
</div>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
var myTimecode = "00:00:00.000";
var myVTT = ""
var myMP4 = ""
function getTimeSeek (timeStamp){
var sec = timeStamp.split('.');
var tt = sec[0].split(':');
return tt[0]*3600+tt[1]*60+tt[2]*1;
}
// hack sur body --- a investiquer pour le rendre plus specifique au modal #myModal
$('body').on('hidden.bs.modal', '.modal', function () {
//$("#timecode").val('');
$('#videoTag').trigger('pause');
});
$('#myModal').on('shown.bs.modal', function() {
//$("#timecode").val("00:15:35.279");
console.log(myMP4);
$('#videoTag source').attr('src', myMP4);
console.log(myVTT);
//$('#trackTag').attr('src', myVTT);
$('#videoTag track').attr('src', myVTT);
$('#videoTag')[0].load();
var timecode = myTimecode
console.log(timecode)
//var timestamp = "00:15:35.279"
var tSeek = 0
if (timecode) { tSeek = getTimeSeek(timecode); };
$("#videoTag").get(0).currentTime = tSeek;
$("#videoTag").get(0).play()
$("#timecode").val(timecode);
});
$(document).on("click", ".play-clip", function () {
myTimecode = $(this).data('timecode');
myMP4 = $(this).data('mp4');
myVTT = $(this).data('vtt-fr');
if(!myVTT.endsWith('.vtt')){myVTT = $(this).data('vtt-en');}
});
</script>
</body>
</html>