1
1
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
+
2
91
$ ( 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
+
3
100
$ ( ".gallery img.preview" ) . hover (
4
101
function ( ) {
5
102
var url = $ ( this ) . attr ( "src" ) . replace ( "_static" , "_animated" ) ;
@@ -9,5 +106,41 @@ $(function() {
9
106
var url = $ ( this ) . attr ( "src" ) . replace ( "_animated" , "_static" ) ;
10
107
$ ( this ) . attr ( "src" , url ) ;
11
108
}
12
- ) ;
109
+ ) ;
13
110
} ) ;
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