Skip to content

Commit d9204ac

Browse files
committed
Better dataset preview.
1 parent 2581a4f commit d9204ac

File tree

4 files changed

+248
-1
lines changed

4 files changed

+248
-1
lines changed

config.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
"smartypants": true
1313
}
1414
}
15+

contents/css/vot.css

+24
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,28 @@ ul.publications.embedded li .published {
234234
color: #444444;
235235
}
236236

237+
.modal {
238+
text-align: center;
239+
padding: 0!important;
240+
}
241+
242+
.modal:before {
243+
content: '';
244+
display: inline-block;
245+
height: 100%;
246+
vertical-align: middle;
247+
margin-right: -4px;
248+
}
249+
250+
.modal-dialog {
251+
display: inline-block;
252+
text-align: left;
253+
vertical-align: middle;
254+
}
255+
256+
.modal-image {
257+
float: right;
258+
padding-left: 10px;
259+
260+
}
237261

contents/js/preview.js

+134-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,102 @@
11

2+
function show_dataset(url, parent) {
3+
4+
var container = $(parent);
5+
console.log(container);
6+
var placeholder = $("<div>").addClass("alert alert-info").text("Loading preveiw, please wait ...");
7+
8+
container.append(placeholder);
9+
10+
$.ajax(url).done(function(data) {
11+
12+
var parent_url = new URI(url);
13+
14+
var gallery = $("<div>");
15+
16+
var modal = $('<div class="modal fade" tabindex="-1" role="dialog"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-header"><h4 class="modal-title" id="myModalLabel"></h4></div><div class="modal-body"></div></div></div></div>').hide();
17+
18+
modal.modal({show: false});
19+
20+
function configure_preview(sequence) {
21+
22+
var relative_url_preview = URI(sequence.preview);
23+
var relative_url_thumbnail = URI(sequence.thumbnail);
24+
25+
var src_preview = relative_url_preview.absoluteTo(parent_url);
26+
var src_thumbnail = relative_url_thumbnail.absoluteTo(parent_url);
27+
28+
var preview = $("<img>").addClass("image sequence preview").attr({"title" : sequence["name"], "alt" : sequence["name"], "src" : src_thumbnail.toString()});
29+
30+
preview.hover(
31+
function() {
32+
var url = $(this).attr("src").replace("_static", "_animated");
33+
$(this).attr("src", src_preview.toString());
34+
},
35+
function() {
36+
var url = $(this).attr("src").replace("_animated", "_static");
37+
$(this).attr("src", src_thumbnail.toString());
38+
}
39+
);
40+
41+
preview.click(function() {
42+
modal.find('.modal-title').text("Sequence " + sequence["name"]);
43+
44+
var body = $("<div>").appendTo(modal.find('.modal-body').empty());
45+
46+
body.append($("<img>").attr("src", src_thumbnail.toString()).addClass("modal-image"));
47+
48+
body.append($("<p>").text("Size: " + sequence["width"] + "x" + sequence["height"] + " pixels"));
49+
body.append($("<p>").text("Length: " + sequence["length"] + " frames (at " + sequence["fps"] + " fps)"));
50+
51+
var resources = $("<ul>").appendTo(body);
52+
53+
var relative_url = URI(sequence.annotations.url);
54+
resources.append($("<li>").append($("<a>").attr("href", relative_url.absoluteTo(parent_url).toString()).text("Download annotations")));
55+
56+
for (var k in sequence["channels"]) {
57+
var relative_url = URI(sequence.channels[k].url);
58+
resources.append($("<li>").append($("<a>").attr("href", relative_url.absoluteTo(parent_url).toString()).text("Download data for channel " + k)));
59+
}
60+
61+
modal.modal('show');
62+
63+
});
64+
65+
return preview;
66+
}
67+
68+
for (var k in data["sequences"]) {
69+
70+
gallery.append(configure_preview(data["sequences"][k]));
71+
}
72+
73+
container.empty().append(gallery).append(modal);
74+
75+
}).error(function(e) {
76+
77+
console.log(container);
78+
79+
placeholder.remove();
80+
81+
var message = $("<div>").addClass("alert alert-warning").text("Unable to load dataset preview.");
82+
83+
container.append(message);
84+
85+
});
86+
87+
}
88+
89+
90+
291
$(function() {
92+
$(".gallery").each(function(i, element) {
93+
var container = $(element);
94+
if ($(element).data("votdataset") !== undefined) {
95+
show_dataset(container.data("votdataset"), container);
96+
}
97+
});
98+
99+
3100
$(".gallery img.preview").hover(
4101
function() {
5102
var url = $(this).attr("src").replace("_static", "_animated");
@@ -9,5 +106,41 @@ $(function() {
9106
var url = $(this).attr("src").replace("_animated", "_static");
10107
$(this).attr("src", url);
11108
}
12-
);
109+
);
13110
});
111+
112+
113+
function bintray_list(element, subject, repository, pkg, version) {
114+
115+
version = typeof version !== 'undefined' ? version : '_latest';
116+
117+
var path = subject + "/" + repository + "/" + pkg;
118+
119+
$(function() {
120+
121+
$.get("https://api.bintray.com/packages/" + path + "/versions/" + version,
122+
function(data) {
123+
124+
var realversion = data.name;
125+
126+
$.get("https://api.bintray.com/packages/" + path + "/versions/" + realversion + "/files",
127+
function(data) {
128+
129+
var list = $("</ul>");
130+
131+
for (var i in data) {
132+
list.append($("</li>").append("</a>").text(data[i].name).attr({"href" : data[i].path}));
133+
}
134+
135+
$(element).empty().append(list);
136+
}
137+
);
138+
139+
}
140+
);
141+
142+
});
143+
144+
}
145+
146+

0 commit comments

Comments
 (0)