summaryrefslogtreecommitdiffabout
path: root/content/fireflix.js
Unidiff
Diffstat (limited to 'content/fireflix.js') (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js2
1 files changed, 0 insertions, 2 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index a4f13b6..0f51397 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -337,121 +337,119 @@ var fireflix = {
337 isSeparator: function(r) { return false; }, 337 isSeparator: function(r) { return false; },
338 isSorted: function(r) { return false; }, 338 isSorted: function(r) { return false; },
339 getLevel: function(r) { return 0; }, 339 getLevel: function(r) { return 0; },
340 getImageSrc: function(r,c) { return null }, 340 getImageSrc: function(r,c) { return null },
341 getRowProperties: function(r,p) { 341 getRowProperties: function(r,p) {
342 try { 342 try {
343 if(!Components) return; 343 if(!Components) return;
344 }catch(e) { return } 344 }catch(e) { return }
345 var f = this.files[r]; 345 var f = this.files[r];
346 var as = Components.classes['@mozilla.org/atom-service;1']. 346 var as = Components.classes['@mozilla.org/atom-service;1'].
347 getService(Components.interfaces.nsIAtomService); 347 getService(Components.interfaces.nsIAtomService);
348 p.AppendElement(as.getAtom(f.state)); 348 p.AppendElement(as.getAtom(f.state));
349 }, 349 },
350 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); }, 350 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); },
351 getColumnProperties: function(c,p) { }, 351 getColumnProperties: function(c,p) { },
352 cycleHeader: function(cid,e) { }, 352 cycleHeader: function(cid,e) { },
353 getParentIndex: function(r) { return -1; }, 353 getParentIndex: function(r) { return -1; },
354 drop: function(r,o) { }, 354 drop: function(r,o) { },
355 canDropBeforeAfter: function(r,b) { return false }, 355 canDropBeforeAfter: function(r,b) { return false },
356 356
357 add: function(f) { 357 add: function(f) {
358 if(f.indexOf('file:/')==0) { 358 if(f.indexOf('file:/')==0) {
359 f = f.substr(5); 359 f = f.substr(5);
360 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-) 360 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-)
361 f = f.substr(1); 361 f = f.substr(1);
362 } 362 }
363 } 363 }
364 var t = f; 364 var t = f;
365 var ls = t.lastIndexOf('/'); 365 var ls = t.lastIndexOf('/');
366 if(ls>0) t = t.substr(ls+1); 366 if(ls>0) t = t.substr(ls+1);
367 ls = t.lastIndexOf('\\'); 367 ls = t.lastIndexOf('\\');
368 if(ls>0) t = t.substr(ls+1); 368 if(ls>0) t = t.substr(ls+1);
369 var ld = t.lastIndexOf('.'); 369 var ld = t.lastIndexOf('.');
370 if(ld>0) t = t.substr(0,ld); 370 if(ld>0) t = t.substr(0,ld);
371 this.files.push( { 371 this.files.push( {
372 file: f, 372 file: f,
373 title: t, 373 title: t,
374 tags: '', 374 tags: '',
375 state: 'pending' 375 state: 'pending'
376 } ); 376 } );
377 this.rowCount = this.files.length; 377 this.rowCount = this.files.length;
378 this.tree.rowCountChanged(this.rowCount-1,1); 378 this.tree.rowCountChanged(this.rowCount-1,1);
379 }, 379 },
380 380
381 upload_worker: function() { 381 upload_worker: function() {
382 for(var f in this.files) { 382 for(var f in this.files) {
383 if(this.files[f].state=='pending') { 383 if(this.files[f].state=='pending') {
384 var ff = this.files[f]; 384 var ff = this.files[f];
385 dump('upload '+ff.file+'\n');
386 this.on_file_upload(ff); 385 this.on_file_upload(ff);
387 ff.state='uploading'; 386 ff.state='uploading';
388 this.tree.invalidate(); 387 this.tree.invalidate();
389 var _this = this; 388 var _this = this;
390 this.fireflix.flickr.upload_file( 389 this.fireflix.flickr.upload_file(
391 ff.file, { title: ff.title, tags: ff.tags }, 390 ff.file, { title: ff.title, tags: ff.tags },
392 function(x,p) { 391 function(x,p) {
393 ff.photoid = p; 392 ff.photoid = p;
394 _this.batch_ids.push(p); 393 _this.batch_ids.push(p);
395 ff.state='completed'; 394 ff.state='completed';
396 _this.tree.invalidate(); 395 _this.tree.invalidate();
397 window.setTimeout(_this.upload_to,0,_this); 396 window.setTimeout(_this.upload_to,0,_this);
398 }, function(x,s,c,m) { 397 }, function(x,s,c,m) {
399 ff.state='failed'; 398 ff.state='failed';
400 ff.flickr_errcode = c; 399 ff.flickr_errcode = c;
401 ff.flickr_errmsg = m; 400 ff.flickr_errmsg = m;
402 _this.tree.invalidate(); 401 _this.tree.invalidate();
403 window.setTimeout(_this.upload_to,0,_this); 402 window.setTimeout(_this.upload_to,0,_this);
404 } 403 }
405 ); 404 );
406 return; 405 return;
407 } 406 }
408 } 407 }
409 dump('uploading done\n');
410 this.on_finish_upload(); 408 this.on_finish_upload();
411 }, 409 },
412 upload_to: function(_this) { _this.upload_worker(); }, 410 upload_to: function(_this) { _this.upload_worker(); },
413 on_file_upload: function(f) { 411 on_file_upload: function(f) {
414 this.cmd_uploads_upload.setAttribute('disabled','true'); 412 this.cmd_uploads_upload.setAttribute('disabled','true');
415 for(var fi in this.files) { 413 for(var fi in this.files) {
416 if(this.files[fi].file==f.file) { 414 if(this.files[fi].file==f.file) {
417 this.tree.ensureRowIsVisible(fi); 415 this.tree.ensureRowIsVisible(fi);
418 this.selection.rangedSelect(fi,fi,false); 416 this.selection.rangedSelect(fi,fi,false);
419 this.selection.currentIndex = fi; 417 this.selection.currentIndex = fi;
420 this.selToProps(); 418 this.selToProps();
421 break; 419 break;
422 } 420 }
423 } 421 }
424 }, 422 },
425 on_finish_upload: function() { 423 on_finish_upload: function() {
426 if(this.batch_ids.length) { 424 if(this.batch_ids.length) {
427 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); 425 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset'));
428 if(psn!=null) { 426 if(psn!=null) {
429 var pids = this.batch_ids.join(','); 427 var pids = this.batch_ids.join(',');
430 var ppid = this.batch_ids[0]; 428 var ppid = this.batch_ids[0];
431 var _this = this; 429 var _this = this;
432 this.fireflix.flickr.api_call( 430 this.fireflix.flickr.api_call(
433 { 431 {
434 method: 'flickr.photosets.create', 432 method: 'flickr.photosets.create',
435 auth_token: 'default', 433 auth_token: 'default',
436 title: psn, 434 title: psn,
437 primary_photo_id: ppid 435 primary_photo_id: ppid
438 }, function(x) { 436 }, function(x) {
439 var npid = 437 var npid =
440 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id'); 438 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id');
441 _this.fireflix.flickr.api_call( 439 _this.fireflix.flickr.api_call(
442 { 440 {
443 method: 'flickr.photosets.editPhotos', 441 method: 'flickr.photosets.editPhotos',
444 auth_token: 'default', 442 auth_token: 'default',
445 photoset_id: npid, 443 photoset_id: npid,
446 primary_photo_id: ppid, 444 primary_photo_id: ppid,
447 photo_ids: pids 445 photo_ids: pids
448 }, function(x) { 446 }, function(x) {
449 _this.fireflix.refresh_sets(); 447 _this.fireflix.refresh_sets();
450 }, function(x,s,c,m) { 448 }, function(x,s,c,m) {
451 _this.fireflix.flickr_failure(x,s,c,m); 449 _this.fireflix.flickr_failure(x,s,c,m);
452 } 450 }
453 ); 451 );
454 }, function(x,s,c,m) { 452 }, function(x,s,c,m) {
455 _this.fireflix.flickr_failure(x,s,c,m); 453 _this.fireflix.flickr_failure(x,s,c,m);
456 } 454 }
457 ); 455 );