-rw-r--r-- | content/fireflix.js | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 6681303..0f01d26 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -655,192 +655,193 @@ var fireflix = { | |||
655 | if(this.uploads.files[f].photoid) | 655 | if(this.uploads.files[f].photoid) |
656 | pids.push(this.uploads.files[f].photoid); | 656 | pids.push(this.uploads.files[f].photoid); |
657 | } | 657 | } |
658 | var pp = this.uploads.rowCount*2; if(pp>500) pp = 500; | 658 | var pp = this.uploads.rowCount*2; if(pp>500) pp = 500; |
659 | var _this = this; | 659 | var _this = this; |
660 | this.flickr.api_call( | 660 | this.flickr.api_call( |
661 | { | 661 | { |
662 | method: 'flickr.photos.search', | 662 | method: 'flickr.photos.search', |
663 | auth_token: 'default', | 663 | auth_token: 'default', |
664 | extras: 'original_format', | 664 | extras: 'original_format', |
665 | user_id: 'me', | 665 | user_id: 'me', |
666 | per_page: pp | 666 | per_page: pp |
667 | }, | 667 | }, |
668 | function(xr) { | 668 | function(xr) { |
669 | var x = xr.responseXML; | 669 | var x = xr.responseXML; |
670 | var rv = ''; | 670 | var rv = ''; |
671 | for(var pn in pids) { | 671 | for(var pn in pids) { |
672 | var p = pids[pn]; | 672 | var p = pids[pn]; |
673 | var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x)); | 673 | var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x)); |
674 | rv += _this.photo_html(pp,uti,utl)+'\n'; | 674 | rv += _this.photo_html(pp,uti,utl)+'\n'; |
675 | } | 675 | } |
676 | _this.popup_content(rv); | 676 | _this.popup_content(rv); |
677 | }, function(x,s,c,m) { | 677 | }, function(x,s,c,m) { |
678 | _this.flickr_failure(x,s,c,m); | 678 | _this.flickr_failure(x,s,c,m); |
679 | } | 679 | } |
680 | ); | 680 | ); |
681 | }, | 681 | }, |
682 | 682 | ||
683 | /* | 683 | /* |
684 | * | 684 | * |
685 | */ | 685 | */ |
686 | foundphotos: { | 686 | foundphotos: { |
687 | fireflix: null, | 687 | fireflix: null, |
688 | init: function(f) { | 688 | init: function(f) { |
689 | this.fireflix = f; | 689 | this.fireflix = f; |
690 | pull_elements(this,document,[ | 690 | pull_elements(this,document,[ |
691 | 'search_for','search_tags','search_mine', | 691 | 'search_for','search_tags','search_mine', |
692 | 'searchresult_props','search_photo', | 692 | 'searchresult_props','search_photo', |
693 | 'searchresult_title','searchresult_description' | 693 | 'searchresult_title','searchresult_description' |
694 | ]); | 694 | ]); |
695 | document.getElementById('searchresults').view = this; | 695 | document.getElementById('searchresults').view = this; |
696 | }, | 696 | }, |
697 | photos: new Array(), | 697 | photos: new Array(), |
698 | rowCount: 0, | 698 | rowCount: 0, |
699 | getCellText: function(r,c) { | 699 | getCellText: function(r,c) { |
700 | var p = this.photos[r]; | 700 | var p = this.photos[r]; |
701 | if(c.id=='sr_title') return p.title; | 701 | if(c.id=='sr_title') return p.title; |
702 | return c.id; | 702 | return c.id; |
703 | }, | 703 | }, |
704 | setTree: function(t) { this.tree = t }, | 704 | setTree: function(t) { this.tree = t }, |
705 | isContainer: function(r) { return false }, | 705 | isContainer: function(r) { return false }, |
706 | isSeparator: function(r) { return false }, | 706 | isSeparator: function(r) { return false }, |
707 | isSorted: function(r) { return false }, | 707 | isSorted: function(r) { return false }, |
708 | getLevel: function(r) { return 0 }, | 708 | getLevel: function(r) { return 0 }, |
709 | getImageSrc: function(r,c) { return null }, | 709 | getImageSrc: function(r,c) { return null }, |
710 | getRowProperties: function(r,p) { }, | 710 | getRowProperties: function(r,p) { }, |
711 | getCellProperties: function(cid,cel,p) { }, | 711 | getCellProperties: function(cid,cel,p) { }, |
712 | getColumnProperties: function(cid,cel,p) { }, | 712 | getColumnProperties: function(cid,cel,p) { }, |
713 | cycleHeader: function(cid,e) { }, | 713 | cycleHeader: function(cid,e) { }, |
714 | getParentIndex: function(r) { return -1 }, | 714 | getParentIndex: function(r) { return -1 }, |
715 | drop: function(r,o) { }, | 715 | drop: function(r,o) { }, |
716 | canDropBeforeAfter: function(r,b) { return false }, | 716 | canDropBeforeAfter: function(r,b) { return false }, |
717 | 717 | ||
718 | importXPR: function(xp) { | 718 | importXPR: function(xp) { |
719 | this.selection.clearSelection(); | 719 | this.selection.clearSelection(); |
720 | this.selection.currentIndex = -1; | 720 | this.selection.currentIndex = -1; |
721 | this.searchresult_props.hidden = true; | 721 | this.searchresult_props.hidden = true; |
722 | this.tree.beginUpdateBatch(); | 722 | this.tree.beginUpdateBatch(); |
723 | this.photos = new Array(); | 723 | this.photos = new Array(); |
724 | var n; while(n=xp.iterateNext()) { | 724 | var n; while(n=xp.iterateNext()) { |
725 | this.photos.push(new Photo(n)); | 725 | this.photos.push(new Photo(n)); |
726 | } | 726 | } |
727 | this.rowCount = this.photos.length; | 727 | this.rowCount = this.photos.length; |
728 | this.tree.endUpdateBatch(); | 728 | this.tree.endUpdateBatch(); |
729 | }, | 729 | }, |
730 | search_photos: function() { | 730 | search_photos: function() { |
731 | var pars = { | 731 | var pars = { |
732 | method: 'flickr.photos.search', | 732 | method: 'flickr.photos.search', |
733 | auth_token: 'default', | 733 | auth_token: 'default', |
734 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' | 734 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' |
735 | }; | 735 | }; |
736 | if(this.search_mine.checked) | 736 | if(this.search_mine.checked) |
737 | pars.user_id='me'; | 737 | pars.user_id='me'; |
738 | if(this.search_tags.checked) { | 738 | if(this.search_tags.checked) { |
739 | pars.tags=this.search_for.value.split(/ +/).join(','); | 739 | pars.tags=this.search_for.value.split(/ +/).join(','); |
740 | }else{ | 740 | }else{ |
741 | pars.text=this.search_for.value; | 741 | pars.text=this.search_for.value; |
742 | } | 742 | } |
743 | var _this = this; | 743 | var _this = this; |
744 | this.fireflix.flickr.api_call( pars, | 744 | this.fireflix.flickr.api_call( pars, |
745 | function(xr) { | 745 | function(xr) { |
746 | var x = xr.responseXML; | 746 | var x = xr.responseXML; |
747 | var xp = x.evaluate( | 747 | var xp = x.evaluate( |
748 | '/rsp/photos/photo', x, null, | 748 | '/rsp/photos/photo', x, null, |
749 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 749 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
750 | _this.importXPR(xp); | 750 | _this.importXPR(xp); |
751 | _this.tree.ensureRowIsVisible(0); | ||
751 | _this.on_select(); | 752 | _this.on_select(); |
752 | }, function(x,s,c,m) { | 753 | }, function(x,s,c,m) { |
753 | _this.fireflix.flickr_failure(x,s,c,m); | 754 | _this.fireflix.flickr_failure(x,s,c,m); |
754 | } | 755 | } |
755 | ); | 756 | ); |
756 | }, | 757 | }, |
757 | render_description_frame: function(content) { | 758 | render_description_frame: function(content) { |
758 | if(!content) { | 759 | if(!content) { |
759 | this.searchresult_description.innerHTML = ''; | 760 | this.searchresult_description.innerHTML = ''; |
760 | }else{ | 761 | }else{ |
761 | this.searchresult_description.innerHTML = content?content:''; | 762 | this.searchresult_description.innerHTML = content?content:''; |
762 | /* of all linking elements flickr only allows a */ | 763 | /* of all linking elements flickr only allows a */ |
763 | var as = this.searchresult_description.getElementsByTagName('a'); | 764 | var as = this.searchresult_description.getElementsByTagName('a'); |
764 | for(var a=0;a<as.length;++a) | 765 | for(var a=0;a<as.length;++a) |
765 | as.item(a).setAttribute('target','_blank'); | 766 | as.item(a).setAttribute('target','_blank'); |
766 | } | 767 | } |
767 | }, | 768 | }, |
768 | on_select: function() { | 769 | on_select: function() { |
769 | if(this.selection.currentIndex<0) { | 770 | if(this.selection.currentIndex<0) { |
770 | this.searchresult_props.hidden = true; | 771 | this.searchresult_props.hidden = true; |
771 | }else{ | 772 | }else{ |
772 | var p = this.photos[this.selection.currentIndex]; | 773 | var p = this.photos[this.selection.currentIndex]; |
773 | if(!p) { | 774 | if(!p) { |
774 | this.searchresult_props.hidden = true; | 775 | this.searchresult_props.hidden = true; |
775 | }else{ | 776 | }else{ |
776 | this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); | 777 | this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); |
777 | this.searchresult_title.value = p.title; | 778 | this.searchresult_title.value = p.title; |
778 | this.render_description_frame(null); | 779 | this.render_description_frame(null); |
779 | if(p.description==null && p.description==undefined) { | 780 | if(p.description==null && p.description==undefined) { |
780 | var pid = p.id; | 781 | var pid = p.id; |
781 | var ci = this.selection.currentIndex; | 782 | var ci = this.selection.currentIndex; |
782 | var _this = this; | 783 | var _this = this; |
783 | this.fireflix.flickr.api_call( | 784 | this.fireflix.flickr.api_call( |
784 | { | 785 | { |
785 | method: 'flickr.photos.getInfo', | 786 | method: 'flickr.photos.getInfo', |
786 | auth_token: 'default', | 787 | auth_token: 'default', |
787 | photo_id: p.id, | 788 | photo_id: p.id, |
788 | secret: p.secret | 789 | secret: p.secret |
789 | }, function(xr) { | 790 | }, function(xr) { |
790 | var pp = _this.photos[ci]; | 791 | var pp = _this.photos[ci]; |
791 | if(ci==_this.selection.currentIndex && pp.id==pid) { | 792 | if(ci==_this.selection.currentIndex && pp.id==pid) { |
792 | var n = xp_node('/rsp/photo',xr.responseXML); | 793 | var n = xp_node('/rsp/photo',xr.responseXML); |
793 | pp.fromNode_(n); | 794 | pp.fromNode_(n); |
794 | _this.render_description_frame(pp.description); | 795 | _this.render_description_frame(pp.description); |
795 | } | 796 | } |
796 | }, function(x,s,c,m) { | 797 | }, function(x,s,c,m) { |
797 | _this.fireflix.flickr_failure(x,s,c,m); | 798 | _this.fireflix.flickr_failure(x,s,c,m); |
798 | } | 799 | } |
799 | ); | 800 | ); |
800 | this.searchresult_props.hidden = false; | 801 | this.searchresult_props.hidden = false; |
801 | }else{ | 802 | }else{ |
802 | this.render_description_frame(p.description); | 803 | this.render_description_frame(p.description); |
803 | } | 804 | } |
804 | } | 805 | } |
805 | } | 806 | } |
806 | }, | 807 | }, |
807 | on_cmd_open: function(ev) { | 808 | on_cmd_open: function(ev) { |
808 | if(this.selection.currentIndex<0) | 809 | if(this.selection.currentIndex<0) |
809 | return; | 810 | return; |
810 | var p = this.photos[this.selection.currentIndex]; | 811 | var p = this.photos[this.selection.currentIndex]; |
811 | if(!p.id) | 812 | if(!p.id) |
812 | return; | 813 | return; |
813 | this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); | 814 | this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); |
814 | } | 815 | } |
815 | }, | 816 | }, |
816 | 817 | ||
817 | photo_html: function(p,i,l) { | 818 | photo_html: function(p,i,l) { |
818 | // TODO: add alt/title when possible | 819 | // TODO: add alt/title when possible |
819 | var rv = | 820 | var rv = |
820 | '<a href="'+this.flickr.make_photo_url(p,l)+'">' + | 821 | '<a href="'+this.flickr.make_photo_url(p,l)+'">' + |
821 | '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+ | 822 | '<img src="'+this.flickr.make_photo_url(p,i)+'" />'+ |
822 | '</a>'; | 823 | '</a>'; |
823 | return rv; | 824 | return rv; |
824 | }, | 825 | }, |
825 | build_html: function(photos,uti,utl) { | 826 | build_html: function(photos,uti,utl) { |
826 | var rv = ''; | 827 | var rv = ''; |
827 | for(var i in photos) { | 828 | for(var i in photos) { |
828 | var p = photos[i]; | 829 | var p = photos[i]; |
829 | rv += this.photo_html(p,utl,uti)+'\n'; | 830 | rv += this.photo_html(p,utl,uti)+'\n'; |
830 | } | 831 | } |
831 | return rv; | 832 | return rv; |
832 | }, | 833 | }, |
833 | 834 | ||
834 | popup_content: function(s) { | 835 | popup_content: function(s) { |
835 | window.openDialog( | 836 | window.openDialog( |
836 | "chrome://fireflix/content/generated-content.xul", | 837 | "chrome://fireflix/content/generated-content.xul", |
837 | null, "dialog,chrome", this, s ); | 838 | null, "dialog,chrome", this, s ); |
838 | }, | 839 | }, |
839 | copy_to_clipboard: function(s) { | 840 | copy_to_clipboard: function(s) { |
840 | var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"] | 841 | var ch = Components.classes["@mozilla.org/widget/clipboardhelper;1"] |
841 | .getService(Components.interfaces.nsIClipboardHelper); | 842 | .getService(Components.interfaces.nsIClipboardHelper); |
842 | ch.copyString(s); | 843 | ch.copyString(s); |
843 | }, | 844 | }, |
844 | openTab: function(l) { | 845 | openTab: function(l) { |
845 | var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( | 846 | var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService( |
846 | Components.interfaces.nsIWindowMediator ); | 847 | Components.interfaces.nsIWindowMediator ); |