author | Michael Krelin <hacker@klever.net> | 2011-08-28 16:22:04 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2011-08-28 16:22:04 (UTC) |
commit | e58247a43552504e34ae31a5262a8a9dd338243c (patch) (unidiff) | |
tree | 010174a32497fa0e085de0902799197f703e678a | |
parent | aa13caca14bac3ed268ac6fb62f0270e40b24e48 (diff) | |
download | fireflix-e58247a43552504e34ae31a5262a8a9dd338243c.zip fireflix-e58247a43552504e34ae31a5262a8a9dd338243c.tar.gz fireflix-e58247a43552504e34ae31a5262a8a9dd338243c.tar.bz2 |
more json calls
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | content/fireflix.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 283e930..d70ab4d 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -384,153 +384,152 @@ var fireflix = { | |||
384 | if(ld>0) t = t.substr(0,ld); | 384 | if(ld>0) t = t.substr(0,ld); |
385 | this.files.push( { | 385 | this.files.push( { |
386 | file: f, | 386 | file: f, |
387 | title: t, | 387 | title: t, |
388 | tags: '', | 388 | tags: '', |
389 | is_public: true, is_friend: false, is_family: false, | 389 | is_public: true, is_friend: false, is_family: false, |
390 | state: 'pending' | 390 | state: 'pending' |
391 | } ); | 391 | } ); |
392 | this.rowCount = this.files.length; | 392 | this.rowCount = this.files.length; |
393 | this.tree.rowCountChanged(this.rowCount-1,1); | 393 | this.tree.rowCountChanged(this.rowCount-1,1); |
394 | }, | 394 | }, |
395 | 395 | ||
396 | upload_worker: function() { | 396 | upload_worker: function() { |
397 | for(var f in this.files) { | 397 | for(var f in this.files) { |
398 | if(this.files[f].state=='pending') { | 398 | if(this.files[f].state=='pending') { |
399 | var ff = this.files[f]; | 399 | var ff = this.files[f]; |
400 | this.on_file_upload(ff); | 400 | this.on_file_upload(ff); |
401 | ff.state='uploading'; | 401 | ff.state='uploading'; |
402 | this.tree.invalidate(); | 402 | this.tree.invalidate(); |
403 | var _this = this; | 403 | var _this = this; |
404 | this.fireflix.flickr.upload_file( | 404 | this.fireflix.flickr.upload_file( |
405 | ff.file, { | 405 | ff.file, { |
406 | title: ff.title, tags: ff.tags, | 406 | title: ff.title, tags: ff.tags, |
407 | is_public: ff.is_public?'1':'0', | 407 | is_public: ff.is_public?'1':'0', |
408 | is_friend: ff.is_friend?'1':'0', | 408 | is_friend: ff.is_friend?'1':'0', |
409 | is_family: ff.is_family?'1':'0' | 409 | is_family: ff.is_family?'1':'0' |
410 | }, function(x,p) { | 410 | }, function(x,p) { |
411 | ff.photoid = p; | 411 | ff.photoid = p; |
412 | _this.batch_ids.push(p); | 412 | _this.batch_ids.push(p); |
413 | ff.state='completed'; | 413 | ff.state='completed'; |
414 | _this.tree.invalidate(); | 414 | _this.tree.invalidate(); |
415 | window.setTimeout(_this.upload_to,0,_this); | 415 | window.setTimeout(_this.upload_to,0,_this); |
416 | }, function(x,s,c,m) { | 416 | }, function(x,s,c,m) { |
417 | ff.state='failed'; | 417 | ff.state='failed'; |
418 | ff.flickr_errcode = c; | 418 | ff.flickr_errcode = c; |
419 | ff.flickr_errmsg = m; | 419 | ff.flickr_errmsg = m; |
420 | _this.tree.invalidate(); | 420 | _this.tree.invalidate(); |
421 | window.setTimeout(_this.upload_to,0,_this); | 421 | window.setTimeout(_this.upload_to,0,_this); |
422 | } | 422 | } |
423 | ); | 423 | ); |
424 | return; | 424 | return; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | this.on_finish_upload(); | 427 | this.on_finish_upload(); |
428 | }, | 428 | }, |
429 | upload_to: function(_this) { _this.upload_worker(); }, | 429 | upload_to: function(_this) { _this.upload_worker(); }, |
430 | on_file_upload: function(f) { | 430 | on_file_upload: function(f) { |
431 | this.cmd_uploads_upload.setAttribute('disabled','true'); | 431 | this.cmd_uploads_upload.setAttribute('disabled','true'); |
432 | for(var fi in this.files) { | 432 | for(var fi in this.files) { |
433 | if(this.files[fi].file==f.file) { | 433 | if(this.files[fi].file==f.file) { |
434 | this.tree.ensureRowIsVisible(fi); | 434 | this.tree.ensureRowIsVisible(fi); |
435 | this.selection.rangedSelect(fi,fi,false); | 435 | this.selection.rangedSelect(fi,fi,false); |
436 | this.selection.currentIndex = fi; | 436 | this.selection.currentIndex = fi; |
437 | this.selToProps(); | 437 | this.selToProps(); |
438 | break; | 438 | break; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | }, | 441 | }, |
442 | on_finish_upload: function() { | 442 | on_finish_upload: function() { |
443 | if(this.batch_ids.length) { | 443 | if(this.batch_ids.length) { |
444 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); | 444 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); |
445 | if(psn!=null) { | 445 | if(psn!=null) { |
446 | var pids = this.batch_ids.join(','); | 446 | var pids = this.batch_ids.join(','); |
447 | var ppid = this.batch_ids[0]; | 447 | var ppid = this.batch_ids[0]; |
448 | var _this = this; | 448 | var that = this; |
449 | this.fireflix.flickr.api_call( | 449 | this.fireflix.flickr.api_call_json( |
450 | { | 450 | { |
451 | method: 'flickr.photosets.create', | 451 | method: 'flickr.photosets.create', |
452 | auth_token: 'default', | 452 | auth_token: 'default', |
453 | title: psn, | 453 | title: psn, |
454 | primary_photo_id: ppid | 454 | primary_photo_id: ppid |
455 | }, function(x) { | 455 | }, function(x,j) { |
456 | var npid = | 456 | var npid = j.photoset.id; |
457 | x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id'); | 457 | that.fireflix.flickr.api_call_json( |
458 | _this.fireflix.flickr.api_call( | ||
459 | { | 458 | { |
460 | method: 'flickr.photosets.editPhotos', | 459 | method: 'flickr.photosets.editPhotos', |
461 | auth_token: 'default', | 460 | auth_token: 'default', |
462 | photoset_id: npid, | 461 | photoset_id: npid, |
463 | primary_photo_id: ppid, | 462 | primary_photo_id: ppid, |
464 | photo_ids: pids | 463 | photo_ids: pids |
465 | }, function(x) { | 464 | }, function(x,j) { |
466 | _this.fireflix.refresh_sets(); | 465 | that.fireflix.refresh_sets(); |
467 | }, function(x,s,c,m) { | 466 | }, function(x,s,c,m) { |
468 | _this.fireflix.flickr_failure(x,s,c,m); | 467 | that.fireflix.flickr_failure(x,s,c,m); |
469 | } | 468 | } |
470 | ); | 469 | ); |
471 | }, function(x,s,c,m) { | 470 | }, function(x,s,c,m) { |
472 | _this.fireflix.flickr_failure(x,s,c,m); | 471 | that.fireflix.flickr_failure(x,s,c,m); |
473 | } | 472 | } |
474 | ); | 473 | ); |
475 | } | 474 | } |
476 | } | 475 | } |
477 | this.selection.clearSelection(); | 476 | this.selection.clearSelection(); |
478 | this.cmd_uploads_upload.setAttribute('disabled','false'); | 477 | this.cmd_uploads_upload.setAttribute('disabled','false'); |
479 | this.upload_progress.setAttribute('hidden','true'); | 478 | this.upload_progress.setAttribute('hidden','true'); |
480 | }, | 479 | }, |
481 | 480 | ||
482 | clear_list: function() { | 481 | clear_list: function() { |
483 | this.tree.beginUpdateBatch(); | 482 | this.tree.beginUpdateBatch(); |
484 | this.rowCount = 0; | 483 | this.rowCount = 0; |
485 | this.files = new Array(); | 484 | this.files = new Array(); |
486 | this.tree.endUpdateBatch(); | 485 | this.tree.endUpdateBatch(); |
487 | this.selToProps(); | 486 | this.selToProps(); |
488 | }, | 487 | }, |
489 | selectionChanged: function() { | 488 | selectionChanged: function() { |
490 | this.selToProps(); | 489 | this.selToProps(); |
491 | }, | 490 | }, |
492 | disableProps: function() { | 491 | disableProps: function() { |
493 | this.upload_filename.value=''; | 492 | this.upload_filename.value=''; |
494 | this.upload_filename.disabled = true; | 493 | this.upload_filename.disabled = true; |
495 | this.upload_title.value=''; | 494 | this.upload_title.value=''; |
496 | this.upload_title.disabled = true; | 495 | this.upload_title.disabled = true; |
497 | this.upload_file_preview.src = null; | 496 | this.upload_file_preview.src = null; |
498 | this.upload_tags.value=''; | 497 | this.upload_tags.value=''; |
499 | this.upload_tags.disabled = true; | 498 | this.upload_tags.disabled = true; |
500 | this.upload_is_public.disabled = true; | 499 | this.upload_is_public.disabled = true; |
501 | this.upload_is_friends.disabled = true; | 500 | this.upload_is_friends.disabled = true; |
502 | this.upload_is_family.disabled = true; | 501 | this.upload_is_family.disabled = true; |
503 | /* this.upload_file_props.hidden = true; */ | 502 | /* this.upload_file_props.hidden = true; */ |
504 | }, | 503 | }, |
505 | selToProps: function() { | 504 | selToProps: function() { |
506 | if(!this.selection.count) { | 505 | if(!this.selection.count) { |
507 | this.disableProps(); | 506 | this.disableProps(); |
508 | this.upload_file_props.hidden = true; | 507 | this.upload_file_props.hidden = true; |
509 | }else if(this.selection.count==1) { | 508 | }else if(this.selection.count==1) { |
510 | var f=this.files[this.selection.currentIndex]; | 509 | var f=this.files[this.selection.currentIndex]; |
511 | if(f==null) { | 510 | if(f==null) { |
512 | this.disableProps(); | 511 | this.disableProps(); |
513 | this.upload_file_props.hidden = true; | 512 | this.upload_file_props.hidden = true; |
514 | }else{ | 513 | }else{ |
515 | var inactives = f.state!='pending'; | 514 | var inactives = f.state!='pending'; |
516 | this.upload_filename.value = f.file; this.upload_filename.disabled = inactives; | 515 | this.upload_filename.value = f.file; this.upload_filename.disabled = inactives; |
517 | this.upload_title.value = f.title; this.upload_title.disabled = inactives; | 516 | this.upload_title.value = f.title; this.upload_title.disabled = inactives; |
518 | this.upload_file_preview.src = 'file:///'+f.file; | 517 | this.upload_file_preview.src = 'file:///'+f.file; |
519 | this.upload_tags.value = f.tags; this.upload_tags.disabled = inactives; | 518 | this.upload_tags.value = f.tags; this.upload_tags.disabled = inactives; |
520 | this.upload_is_public.checked = f.is_public; this.upload_is_public.disabled = inactives; | 519 | this.upload_is_public.checked = f.is_public; this.upload_is_public.disabled = inactives; |
521 | this.upload_is_friends.checked = f.is_friend; this.upload_is_friends.disabled = inactives; | 520 | this.upload_is_friends.checked = f.is_friend; this.upload_is_friends.disabled = inactives; |
522 | this.upload_is_family.checked = f.is_family; this.upload_is_family.disabled = inactives; | 521 | this.upload_is_family.checked = f.is_family; this.upload_is_family.disabled = inactives; |
523 | if(f.state=='failed') { | 522 | if(f.state=='failed') { |
524 | this.upload_failure.textContent=((f.flickr_errcode<0)?'':f.flickr_errcode+': ')+f.flickr_errmsg; | 523 | this.upload_failure.textContent=((f.flickr_errcode<0)?'':f.flickr_errcode+': ')+f.flickr_errmsg; |
525 | this.upload_failure.hidden = false; | 524 | this.upload_failure.hidden = false; |
526 | }else{ | 525 | }else{ |
527 | this.upload_failure.hidden = true; | 526 | this.upload_failure.hidden = true; |
528 | } | 527 | } |
529 | this.upload_file_props.hidden = false; | 528 | this.upload_file_props.hidden = false; |
530 | } | 529 | } |
531 | }else{ | 530 | }else{ |
532 | var ftitle = null; var onetitle = true; | 531 | var ftitle = null; var onetitle = true; |
533 | var ftags = null; var onetag = true; | 532 | var ftags = null; var onetag = true; |
534 | var fs = 0; | 533 | var fs = 0; |
535 | for(var ff in this.files) { | 534 | for(var ff in this.files) { |
536 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { | 535 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { |