-rw-r--r-- | content/fireflix.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 98b6d41..337354e 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -81,32 +81,33 @@ var fireflix = { | |||
81 | this.flickr.reset_token(); | 81 | this.flickr.reset_token(); |
82 | this.set_auth_state(false,false); | 82 | this.set_auth_state(false,false); |
83 | }, | 83 | }, |
84 | 84 | ||
85 | refresh_sets: function() { this.photosets.refresh_sets(); }, | 85 | refresh_sets: function() { this.photosets.refresh_sets(); }, |
86 | refresh_stuff: function() { | 86 | refresh_stuff: function() { |
87 | this.refresh_sets(); | 87 | this.refresh_sets(); |
88 | this.refresh_user_tags(); | 88 | this.refresh_user_tags(); |
89 | }, | 89 | }, |
90 | 90 | ||
91 | /* photoset treeview */ | 91 | /* photoset treeview */ |
92 | photoset: { | 92 | photoset: { |
93 | photos: new Array(), | 93 | photos: new Array(), |
94 | fireflix: null, | 94 | fireflix: null, |
95 | init: function(f) { | 95 | init: function(f) { |
96 | this.fireflix = f; | 96 | this.fireflix = f; |
97 | pull_elements(this,document,[ 'set_photo' ]); | ||
97 | }, | 98 | }, |
98 | rowCount: 0, | 99 | rowCount: 0, |
99 | getCellText: function(r,c) { | 100 | getCellText: function(r,c) { |
100 | var p = this.photos[r]; | 101 | var p = this.photos[r]; |
101 | if(c.id=='sp_title') return p.title; | 102 | if(c.id=='sp_title') return p.title; |
102 | if(c.id=='sp_taken') return p.datetaken; | 103 | if(c.id=='sp_taken') return p.datetaken; |
103 | if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ | 104 | if(c.id=='sp_upload') return p.dateupload; /* TODO: unixtime conversion */ |
104 | return c.id; | 105 | return c.id; |
105 | }, | 106 | }, |
106 | setTree: function(t) { this.tree = t }, | 107 | setTree: function(t) { this.tree = t }, |
107 | isContainer: function(r) { return false; }, | 108 | isContainer: function(r) { return false; }, |
108 | isSeparator: function(r) { return false; }, | 109 | isSeparator: function(r) { return false; }, |
109 | isSorted: function(r) { return false; }, | 110 | isSorted: function(r) { return false; }, |
110 | getLevel: function(r) { return 0; }, | 111 | getLevel: function(r) { return 0; }, |
111 | getImageSrc: function(r,c) { return null }, | 112 | getImageSrc: function(r,c) { return null }, |
112 | getRowProperties: function(r,p) {}, | 113 | getRowProperties: function(r,p) {}, |
@@ -135,37 +136,37 @@ var fireflix = { | |||
135 | photoset_id: psid, | 136 | photoset_id: psid, |
136 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' | 137 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' |
137 | }, function(xr) { | 138 | }, function(xr) { |
138 | var x = xr.responseXML; | 139 | var x = xr.responseXML; |
139 | var xp = x.evaluate( | 140 | var xp = x.evaluate( |
140 | '/rsp/photoset/photo', x, null, | 141 | '/rsp/photoset/photo', x, null, |
141 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 142 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
142 | _this.importXPR(xp); | 143 | _this.importXPR(xp); |
143 | }, function(x,s,c,m) { | 144 | }, function(x,s,c,m) { |
144 | _this.fireflix.flickr_failure(x,s,c,m); | 145 | _this.fireflix.flickr_failure(x,s,c,m); |
145 | } | 146 | } |
146 | ); | 147 | ); |
147 | }, | 148 | }, |
148 | on_select: function() { | 149 | on_select: function() { |
149 | if(this.selection.count==1) { | 150 | if(this.selection.count==1) { |
150 | var p = this.photos[this.selection.currentIndex]; | 151 | var p = this.photos[this.selection.currentIndex]; |
151 | document.getElementById('set_photo').src = | 152 | this.set_photo.src = |
152 | this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); | 153 | this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); |
153 | document.getElementById('set_photo').hidden = false; | 154 | this.set_photo.hidden = false; |
154 | }else{ | 155 | }else{ |
155 | document.getElementById('set_photo').hidden = true; | 156 | this.set_photo.hidden = true; |
156 | } | 157 | } |
157 | } | 158 | } |
158 | }, | 159 | }, |
159 | 160 | ||
160 | /* photosets treeview */ | 161 | /* photosets treeview */ |
161 | photosets: { | 162 | photosets: { |
162 | sets: new Array(), | 163 | sets: new Array(), |
163 | fireflix: null, | 164 | fireflix: null, |
164 | init: function(f) { | 165 | init: function(f) { |
165 | this.fireflix = f; | 166 | this.fireflix = f; |
166 | }, | 167 | }, |
167 | rowCount: 0, | 168 | rowCount: 0, |
168 | getCellText: function(r,c) { | 169 | getCellText: function(r,c) { |
169 | var s = this.sets[r]; | 170 | var s = this.sets[r]; |
170 | if(c.id=='sl_name') return s.title; | 171 | if(c.id=='sl_name') return s.title; |
171 | if(c.id=='sl_photos') return s.photos; | 172 | if(c.id=='sl_photos') return s.photos; |
@@ -297,33 +298,34 @@ var fireflix = { | |||
297 | // TODO: check for being a file? | 298 | // TODO: check for being a file? |
298 | var us = decodeURIComponent(ul).split(/[\r\n]/); | 299 | var us = decodeURIComponent(ul).split(/[\r\n]/); |
299 | for(var ui in us) | 300 | for(var ui in us) |
300 | if(/\S/.test(us[ui])) | 301 | if(/\S/.test(us[ui])) |
301 | this.fireflix.uploads.add(us[ui]); | 302 | this.fireflix.uploads.add(us[ui]); |
302 | document.getElementById('fireflix_tabs').selectedTab | 303 | document.getElementById('fireflix_tabs').selectedTab |
303 | = document.getElementById('tab_upload'); | 304 | = document.getElementById('tab_upload'); |
304 | } | 305 | } |
305 | }, | 306 | }, |
306 | 307 | ||
307 | uploads: { | 308 | uploads: { |
308 | fireflix: null, | 309 | fireflix: null, |
309 | init: function(f) { | 310 | init: function(f) { |
310 | this.fireflix=f; | 311 | this.fireflix=f; |
311 | pull_elements(this,document,[ | 312 | pull_elements(this,document,[ |
312 | 'upload_filename','upload_title','upload_file_preview', | 313 | 'upload_filename','upload_title','upload_file_preview', |
313 | 'upload_file_props','upload_progress','upload_tags' | 314 | 'upload_file_props','upload_progress','upload_tags', |
315 | 'cmd_uploads_upload' | ||
314 | ]); | 316 | ]); |
315 | }, | 317 | }, |
316 | files: new Array(), | 318 | files: new Array(), |
317 | rowCount: 0, | 319 | rowCount: 0, |
318 | getCellText: function(r,c) { | 320 | getCellText: function(r,c) { |
319 | var f = this.files[r]; | 321 | var f = this.files[r]; |
320 | if(c.id=='up_file') return f.file; | 322 | if(c.id=='up_file') return f.file; |
321 | if(c.id=='up_title') return f.title; | 323 | if(c.id=='up_title') return f.title; |
322 | if(c.id=='up_status') return f.state; | 324 | if(c.id=='up_status') return f.state; |
323 | return c.id; | 325 | return c.id; |
324 | }, | 326 | }, |
325 | setTree: function(t) { this.tree = t }, | 327 | setTree: function(t) { this.tree = t }, |
326 | isContainer: function(r) { return false; }, | 328 | isContainer: function(r) { return false; }, |
327 | isSeparator: function(r) { return false; }, | 329 | isSeparator: function(r) { return false; }, |
328 | isSorted: function(r) { return false; }, | 330 | isSorted: function(r) { return false; }, |
329 | getLevel: function(r) { return 0; }, | 331 | getLevel: function(r) { return 0; }, |
@@ -388,33 +390,33 @@ var fireflix = { | |||
388 | }, function(x,s,c,m) { | 390 | }, function(x,s,c,m) { |
389 | ff.state='failed'; | 391 | ff.state='failed'; |
390 | ff.flickr_errcode = c; | 392 | ff.flickr_errcode = c; |
391 | ff.flickr_errmsg = m; | 393 | ff.flickr_errmsg = m; |
392 | _this.tree.invalidate(); | 394 | _this.tree.invalidate(); |
393 | window.setTimeout(_this.upload_to,0,_this); | 395 | window.setTimeout(_this.upload_to,0,_this); |
394 | } | 396 | } |
395 | ); | 397 | ); |
396 | return; | 398 | return; |
397 | } | 399 | } |
398 | } | 400 | } |
399 | dump('uploading done\n'); | 401 | dump('uploading done\n'); |
400 | this.on_finish_upload(); | 402 | this.on_finish_upload(); |
401 | }, | 403 | }, |
402 | upload_to: function(_this) { _this.upload_worker(); }, | 404 | upload_to: function(_this) { _this.upload_worker(); }, |
403 | on_file_upload: function(f) { | 405 | on_file_upload: function(f) { |
404 | document.getElementById('cmd_uploads_upload').setAttribute('disabled','true'); | 406 | this.cmd_uploads_upload.setAttribute('disabled','true'); |
405 | for(var fi in this.files) { | 407 | for(var fi in this.files) { |
406 | if(this.files[fi].file==f.file) { | 408 | if(this.files[fi].file==f.file) { |
407 | this.tree.ensureRowIsVisible(fi); | 409 | this.tree.ensureRowIsVisible(fi); |
408 | this.selection.rangedSelect(fi,fi,false); | 410 | this.selection.rangedSelect(fi,fi,false); |
409 | this.selection.currentIndex = fi; | 411 | this.selection.currentIndex = fi; |
410 | this.selToProps(); | 412 | this.selToProps(); |
411 | break; | 413 | break; |
412 | } | 414 | } |
413 | } | 415 | } |
414 | }, | 416 | }, |
415 | on_finish_upload: function() { | 417 | on_finish_upload: function() { |
416 | if(this.batch_ids.length) { | 418 | if(this.batch_ids.length) { |
417 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); | 419 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); |
418 | if(psn!=null) { | 420 | if(psn!=null) { |
419 | var pids = this.batch_ids.join(','); | 421 | var pids = this.batch_ids.join(','); |
420 | var ppid = this.batch_ids[0]; | 422 | var ppid = this.batch_ids[0]; |
@@ -435,33 +437,33 @@ var fireflix = { | |||
435 | photoset_id: npid, | 437 | photoset_id: npid, |
436 | primary_photo_id: ppid, | 438 | primary_photo_id: ppid, |
437 | photo_ids: pids | 439 | photo_ids: pids |
438 | }, function(x) { | 440 | }, function(x) { |
439 | _this.fireflix.refresh_sets(); | 441 | _this.fireflix.refresh_sets(); |
440 | }, function(x,s,c,m) { | 442 | }, function(x,s,c,m) { |
441 | _this.fireflix.flickr_failure(x,s,c,m); | 443 | _this.fireflix.flickr_failure(x,s,c,m); |
442 | } | 444 | } |
443 | ); | 445 | ); |
444 | }, function(x,s,c,m) { | 446 | }, function(x,s,c,m) { |
445 | _this.fireflix.flickr_failure(x,s,c,m); | 447 | _this.fireflix.flickr_failure(x,s,c,m); |
446 | } | 448 | } |
447 | ); | 449 | ); |
448 | } | 450 | } |
449 | } | 451 | } |
450 | this.selection.clearSelection(); | 452 | this.selection.clearSelection(); |
451 | document.getElementById('cmd_uploads_upload').setAttribute('disabled','false'); | 453 | this.cmd_uploads_upload.setAttribute('disabled','false'); |
452 | this.upload_progress.setAttribute('hidden','true'); | 454 | this.upload_progress.setAttribute('hidden','true'); |
453 | }, | 455 | }, |
454 | 456 | ||
455 | clear_list: function() { | 457 | clear_list: function() { |
456 | this.tree.beginUpdateBatch(); | 458 | this.tree.beginUpdateBatch(); |
457 | this.rowCount = 0; | 459 | this.rowCount = 0; |
458 | this.files = new Array(); | 460 | this.files = new Array(); |
459 | this.tree.endUpdateBatch(); | 461 | this.tree.endUpdateBatch(); |
460 | this.selToProps(); | 462 | this.selToProps(); |
461 | }, | 463 | }, |
462 | selectionChanged: function() { | 464 | selectionChanged: function() { |
463 | this.selToProps(); | 465 | this.selToProps(); |
464 | }, | 466 | }, |
465 | disableProps: function() { | 467 | disableProps: function() { |
466 | this.upload_filename.value=''; | 468 | this.upload_filename.value=''; |
467 | this.upload_filename.disabled = true; | 469 | this.upload_filename.disabled = true; |