author | Michael Krelin <hacker@klever.net> | 2006-10-01 23:53:31 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-10-01 23:53:31 (UTC) |
commit | b6a122d536aef024b69d40cdf2ac0332d7c14607 (patch) (unidiff) | |
tree | 5b6f01eb73f858e6caaf22301e23d7b6b996ffea | |
parent | 455df70118b045c6053b33ae2f0318a70e4f96b8 (diff) | |
download | fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.zip fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.tar.gz fireflix-b6a122d536aef024b69d40cdf2ac0332d7c14607.tar.bz2 |
paginating through search results
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@179 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix-panel.xul | 13 | ||||
-rw-r--r-- | content/fireflix.css | 10 | ||||
-rw-r--r-- | content/fireflix.js | 50 | ||||
-rw-r--r-- | content/util.js | 7 | ||||
-rw-r--r-- | locale/en-US/fireflix.dtd | 2 | ||||
-rw-r--r-- | locale/en-US/fireflix.properties | 2 |
6 files changed, 79 insertions, 5 deletions
diff --git a/content/fireflix-panel.xul b/content/fireflix-panel.xul index 398dd78..bf6df73 100644 --- a/content/fireflix-panel.xul +++ b/content/fireflix-panel.xul | |||
@@ -39,24 +39,30 @@ | |||
39 | <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/> | 39 | <menuitem command="cmd_auth_done" hidden="true" id="menu_auth_done"/> |
40 | <menuitem command="cmd_auth_unauth" /> | 40 | <menuitem command="cmd_auth_unauth" /> |
41 | <menuseparator/> | 41 | <menuseparator/> |
42 | <menuitem command="cmd_auth_open_flickr"/> | 42 | <menuitem command="cmd_auth_open_flickr"/> |
43 | </popup> | 43 | </popup> |
44 | </popupset> | 44 | </popupset> |
45 | 45 | ||
46 | <commandset id="cmdset_search"> | 46 | <commandset id="cmdset_search"> |
47 | <command id="cmd_search" label="&panel.search.cmd_search.label;" | 47 | <command id="cmd_search" label="&panel.search.cmd_search.label;" |
48 | oncommand="fireflix.foundphotos.search_photos()"/> | 48 | oncommand="fireflix.foundphotos.search_photos()"/> |
49 | <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;" | 49 | <command id="cmd_search_open" label="&panel.search.cmd_search_open.label;" |
50 | oncommand="fireflix.foundphotos.on_cmd_open(event)" /> | 50 | oncommand="fireflix.foundphotos.on_cmd_open(event)" /> |
51 | <command id="cmd_search_prev_page" | ||
52 | label="&panel.search.cmd_search_prev_page.label;" | ||
53 | oncommand="fireflix.foundphotos.on_cmd_prev(event)" disabled="true"/> | ||
54 | <command id="cmd_search_next_page" | ||
55 | label="&panel.search.cmd_search_next_page.label;" | ||
56 | oncommand="fireflix.foundphotos.on_cmd_next(event)" disabled="true"/> | ||
51 | </commandset> | 57 | </commandset> |
52 | 58 | ||
53 | <commandset id="cmdset_sets"> | 59 | <commandset id="cmdset_sets"> |
54 | <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;" | 60 | <command id="cmd_refresh_sets" label="&panel.sets.cmd_refresh_sets;" |
55 | oncommand="fireflix.on_refresh_sets()" /> | 61 | oncommand="fireflix.on_refresh_sets()" /> |
56 | <command id="cmd_set_props" label="&panel.sets.cmd_properties;" | 62 | <command id="cmd_set_props" label="&panel.sets.cmd_properties;" |
57 | oncommand="fireflix.on_set_props()" disabled="true" /> | 63 | oncommand="fireflix.on_set_props()" disabled="true" /> |
58 | </commandset> | 64 | </commandset> |
59 | 65 | ||
60 | <popupset> | 66 | <popupset> |
61 | <popup id="sets_menu"> | 67 | <popup id="sets_menu"> |
62 | <menuitem command="cmd_set_props"/> | 68 | <menuitem command="cmd_set_props"/> |
@@ -121,24 +127,31 @@ | |||
121 | accesskey="s"/> | 127 | accesskey="s"/> |
122 | <textbox id="search_for" flex="1"/> | 128 | <textbox id="search_for" flex="1"/> |
123 | </hbox> | 129 | </hbox> |
124 | <hbox> | 130 | <hbox> |
125 | <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;" | 131 | <checkbox id="search_tags" label="&panel.search.mode.tagsonly.label;" |
126 | tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false" | 132 | tooltiptext="&panel.search.mode.tagsonly.tip;" checked="false" |
127 | accesskey="t" /> | 133 | accesskey="t" /> |
128 | <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/> | 134 | <checkbox id="search_mine" label="&panel.search.mode.mine.label;" checked="true" accesskey="m"/> |
129 | <spacer flex="1"/> | 135 | <spacer flex="1"/> |
130 | <button command="cmd_search"/> | 136 | <button command="cmd_search"/> |
131 | </hbox> | 137 | </hbox> |
132 | </groupbox> | 138 | </groupbox> |
139 | <hbox> | ||
140 | <button command="cmd_search_prev_page"/> | ||
141 | <spacer flex="1"/> | ||
142 | <label id="search_page" hidden="true"/> | ||
143 | <spacer flex="1"/> | ||
144 | <button command="cmd_search_next_page"/> | ||
145 | </hbox> | ||
133 | <tree id="searchresults" rows="2" flex="1" | 146 | <tree id="searchresults" rows="2" flex="1" |
134 | onselect="fireflix.foundphotos.on_select()" | 147 | onselect="fireflix.foundphotos.on_select()" |
135 | ondblclick="fireflix.foundphotos.on_cmd_open(event)" | 148 | ondblclick="fireflix.foundphotos.on_cmd_open(event)" |
136 | onkeypress="if(event.keyCode==event.DOM_VK_RETURN) | 149 | onkeypress="if(event.keyCode==event.DOM_VK_RETURN) |
137 | fireflix.foundphotos.on_cmd_open(event)"> | 150 | fireflix.foundphotos.on_cmd_open(event)"> |
138 | <treecols> | 151 | <treecols> |
139 | <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" /> | 152 | <treecol id="sr_title" label="&panel.search.col.title.label;" flex="2" crop="end" align="start" /> |
140 | </treecols> | 153 | </treecols> |
141 | <treechildren/> | 154 | <treechildren/> |
142 | </tree> | 155 | </tree> |
143 | <groupbox id="searchresult_props" orient="horizontal" hidden="true"> | 156 | <groupbox id="searchresult_props" orient="horizontal" hidden="true"> |
144 | <vbox width="100" pack="center"> | 157 | <vbox width="100" pack="center"> |
diff --git a/content/fireflix.css b/content/fireflix.css index 71080d1..9e7bf6b 100644 --- a/content/fireflix.css +++ b/content/fireflix.css | |||
@@ -78,12 +78,22 @@ div#searchresult_description { | |||
78 | font-size: 90%; | 78 | font-size: 90%; |
79 | margin: 0.1ex 0.5ex; | 79 | margin: 0.1ex 0.5ex; |
80 | } | 80 | } |
81 | 81 | ||
82 | #copying div { | 82 | #copying div { |
83 | margin: 1ex 1em; | 83 | margin: 1ex 1em; |
84 | font-family: courier, monospace; | 84 | font-family: courier, monospace; |
85 | font-size: 9pt; | 85 | font-size: 9pt; |
86 | padding: 2px; | 86 | padding: 2px; |
87 | border: dotted 1px gray; | 87 | border: dotted 1px gray; |
88 | background: white; | 88 | background: white; |
89 | } | 89 | } |
90 | |||
91 | label#search_page { | ||
92 | font-weight: bold; | ||
93 | background: white; color: #404040; | ||
94 | border-color: #c0c0c0 #404040 #404040 #c0c0c0; | ||
95 | border-style: solid; | ||
96 | border-width: 1px; | ||
97 | -moz-border-radius: 1em; | ||
98 | padding: 0.5ex 1ex; | ||
99 | } | ||
diff --git a/content/fireflix.js b/content/fireflix.js index e144aae..92c42f4 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -683,25 +683,26 @@ var fireflix = { | |||
683 | }, | 683 | }, |
684 | 684 | ||
685 | /* | 685 | /* |
686 | * | 686 | * |
687 | */ | 687 | */ |
688 | foundphotos: { | 688 | foundphotos: { |
689 | fireflix: null, | 689 | fireflix: null, |
690 | init: function(f) { | 690 | init: function(f) { |
691 | this.fireflix = f; | 691 | this.fireflix = f; |
692 | pull_elements(this,document,[ | 692 | pull_elements(this,document,[ |
693 | 'search_for','search_tags','search_mine', | 693 | 'search_for','search_tags','search_mine', |
694 | 'searchresult_props','search_photo', | 694 | 'searchresult_props','search_photo', |
695 | 'searchresult_title','searchresult_description' | 695 | 'searchresult_title','searchresult_description', |
696 | 'search_page','cmd_search_prev_page','cmd_search_next_page' | ||
696 | ]); | 697 | ]); |
697 | document.getElementById('searchresults').view = this; | 698 | document.getElementById('searchresults').view = this; |
698 | }, | 699 | }, |
699 | photos: new Array(), | 700 | photos: new Array(), |
700 | rowCount: 0, | 701 | rowCount: 0, |
701 | getCellText: function(r,c) { | 702 | getCellText: function(r,c) { |
702 | var p = this.photos[r]; | 703 | var p = this.photos[r]; |
703 | if(c.id=='sr_title') return p.title; | 704 | if(c.id=='sr_title') return p.title; |
704 | return c.id; | 705 | return c.id; |
705 | }, | 706 | }, |
706 | setTree: function(t) { this.tree = t }, | 707 | setTree: function(t) { this.tree = t }, |
707 | isContainer: function(r) { return false }, | 708 | isContainer: function(r) { return false }, |
@@ -720,52 +721,91 @@ var fireflix = { | |||
720 | importXPR: function(xp) { | 721 | importXPR: function(xp) { |
721 | this.selection.clearSelection(); | 722 | this.selection.clearSelection(); |
722 | this.selection.currentIndex = -1; | 723 | this.selection.currentIndex = -1; |
723 | this.searchresult_props.hidden = true; | 724 | this.searchresult_props.hidden = true; |
724 | this.tree.beginUpdateBatch(); | 725 | this.tree.beginUpdateBatch(); |
725 | this.photos = new Array(); | 726 | this.photos = new Array(); |
726 | var n; while(n=xp.iterateNext()) { | 727 | var n; while(n=xp.iterateNext()) { |
727 | this.photos.push(new Photo(n)); | 728 | this.photos.push(new Photo(n)); |
728 | } | 729 | } |
729 | this.rowCount = this.photos.length; | 730 | this.rowCount = this.photos.length; |
730 | this.tree.endUpdateBatch(); | 731 | this.tree.endUpdateBatch(); |
731 | }, | 732 | }, |
733 | paging: { | ||
734 | pars: null, | ||
735 | page: null, pages: null, perpage: null, total: null | ||
736 | }, | ||
732 | search_photos: function() { | 737 | search_photos: function() { |
733 | var pars = { | 738 | var pars = { |
734 | method: 'flickr.photos.search', | 739 | method: 'flickr.photos.search', |
735 | auth_token: 'default', | 740 | auth_token: 'default', |
736 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' | 741 | extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' |
737 | }; | 742 | }; |
738 | if(this.search_mine.checked) | 743 | if(this.search_mine.checked) |
739 | pars.user_id='me'; | 744 | pars.user_id='me'; |
740 | if(this.search_tags.checked) { | 745 | if(this.search_tags.checked) { |
741 | pars.tags=this.search_for.value.split(/ +/).join(','); | 746 | pars.tags=this.search_for.value.split(/ +/).join(','); |
742 | }else{ | 747 | }else{ |
743 | pars.text=this.search_for.value; | 748 | pars.text=this.search_for.value; |
744 | } | 749 | } |
750 | this.paging.pars = new Object(); | ||
751 | this.paging.page = null; this.paging.pages = null; | ||
752 | this.paging.perpage = null; this.paging.total = null; | ||
753 | for(var p in pars) this.paging.pars[p] = pars[p]; | ||
754 | this.perform_search(pars); | ||
755 | }, | ||
756 | perform_search: function(p) { | ||
745 | var _this = this; | 757 | var _this = this; |
746 | this.fireflix.flickr.api_call( pars, | 758 | this.fireflix.flickr.api_call( p, |
747 | function(xr) { | 759 | function(xr) { |
748 | var x = xr.responseXML; | 760 | var x = xr.responseXML; |
749 | var xp = x.evaluate( | 761 | var xp = xp_nodes('/rsp/photos/photo',x); |
750 | '/rsp/photos/photo', x, null, | ||
751 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | ||
752 | _this.importXPR(xp); | 762 | _this.importXPR(xp); |
753 | _this.tree.ensureRowIsVisible(0); | 763 | _this.tree.ensureRowIsVisible(0); |
764 | xp = xp_node('/rsp/photos',x); | ||
765 | _this.paging.page = parseInt(xp.getAttribute('page')); | ||
766 | _this.paging.pages = parseInt(xp.getAttribute('pages')); | ||
767 | _this.paging.perpage = parseInt(xp.getAttribute('perpage')); | ||
768 | _this.paging.total = parseInt(xp.getAttribute('total')); | ||
769 | _this.update_paging(); | ||
754 | _this.on_select(); | 770 | _this.on_select(); |
755 | }, function(x,s,c,m) { | 771 | }, function(x,s,c,m) { |
756 | _this.fireflix.flickr_failure(x,s,c,m); | 772 | _this.fireflix.flickr_failure(x,s,c,m); |
757 | } | 773 | } |
758 | ); | 774 | ); |
759 | }, | 775 | }, |
776 | on_cmd_prev: function(ev) { | ||
777 | var pars = new Object(); | ||
778 | for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; | ||
779 | pars.page=this.paging.page-1; pars.per_page=this.paging.perpage; | ||
780 | this.perform_search(pars); | ||
781 | }, | ||
782 | on_cmd_next: function(ev) { | ||
783 | var pars = new Object(); | ||
784 | for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; | ||
785 | pars.page=this.paging.page+1; pars.per_page=this.paging.perpage; | ||
786 | this.perform_search(pars); | ||
787 | }, | ||
788 | update_paging: function() { | ||
789 | if(! (this.paging.pars && this.paging.page && this.paging.pages) ) { | ||
790 | this.search_page.value=''; this.search_page.hidden = true; | ||
791 | this.cmd_search_prev_page.setAttribute('disabled','true'); | ||
792 | this.cmd_search_next_page.setAttribute('disabled','true'); | ||
793 | }else{ | ||
794 | this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]); | ||
795 | this.search_page.hidden=false; | ||
796 | this.cmd_search_prev_page.setAttribute('disabled',(this.paging.page>1)?'false':'true'); | ||
797 | this.cmd_search_next_page.setAttribute('disabled',(this.paging.page<this.paging.pages)?'false':'true'); | ||
798 | } | ||
799 | }, | ||
760 | render_description_frame: function(content) { | 800 | render_description_frame: function(content) { |
761 | if(!content) { | 801 | if(!content) { |
762 | this.searchresult_description.innerHTML = ''; | 802 | this.searchresult_description.innerHTML = ''; |
763 | }else{ | 803 | }else{ |
764 | this.searchresult_description.innerHTML = content?content:''; | 804 | this.searchresult_description.innerHTML = content?content:''; |
765 | /* of all linking elements flickr only allows a */ | 805 | /* of all linking elements flickr only allows a */ |
766 | var as = this.searchresult_description.getElementsByTagName('a'); | 806 | var as = this.searchresult_description.getElementsByTagName('a'); |
767 | for(var a=0;a<as.length;++a) | 807 | for(var a=0;a<as.length;++a) |
768 | as.item(a).setAttribute('target','_blank'); | 808 | as.item(a).setAttribute('target','_blank'); |
769 | } | 809 | } |
770 | }, | 810 | }, |
771 | on_select: function() { | 811 | on_select: function() { |
diff --git a/content/util.js b/content/util.js index c4af09e..ccc61cf 100644 --- a/content/util.js +++ b/content/util.js | |||
@@ -49,22 +49,29 @@ function xp_str(xp,x) { | |||
49 | var rv = x.evaluate( | 49 | var rv = x.evaluate( |
50 | xp, x, null, XPathResult.STRING_TYPE, null ); | 50 | xp, x, null, XPathResult.STRING_TYPE, null ); |
51 | return rv.stringValue; | 51 | return rv.stringValue; |
52 | } | 52 | } |
53 | /* | 53 | /* |
54 | * extract xpath-specified node | 54 | * extract xpath-specified node |
55 | */ | 55 | */ |
56 | function xp_node(xp,x) { | 56 | function xp_node(xp,x) { |
57 | var rv = x.evaluate( | 57 | var rv = x.evaluate( |
58 | xp, x, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); | 58 | xp, x, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ); |
59 | return rv.singleNodeValue; | 59 | return rv.singleNodeValue; |
60 | } | 60 | } |
61 | /* | ||
62 | * extract xpath-specified ordered set of nodes | ||
63 | */ | ||
64 | function xp_nodes(xp,x) { | ||
65 | return x.evaluate( | ||
66 | xp, x, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); | ||
67 | } | ||
61 | 68 | ||
62 | /* | 69 | /* |
63 | * pull in elements into documents as a member variables | 70 | * pull in elements into documents as a member variables |
64 | */ | 71 | */ |
65 | function pull_elements(th,d,els) { | 72 | function pull_elements(th,d,els) { |
66 | for(var e in els) { | 73 | for(var e in els) { |
67 | var en=els[e]; | 74 | var en=els[e]; |
68 | th[en] = d.getElementById(en); | 75 | th[en] = d.getElementById(en); |
69 | } | 76 | } |
70 | } | 77 | } |
diff --git a/locale/en-US/fireflix.dtd b/locale/en-US/fireflix.dtd index f4ceb79..88ec6fb 100644 --- a/locale/en-US/fireflix.dtd +++ b/locale/en-US/fireflix.dtd | |||
@@ -26,24 +26,26 @@ | |||
26 | <!ENTITY panel.tabs.search "Search" > | 26 | <!ENTITY panel.tabs.search "Search" > |
27 | <!ENTITY panel.tabs.sets "Sets" > | 27 | <!ENTITY panel.tabs.sets "Sets" > |
28 | <!ENTITY panel.tabs.tags "Tags" > | 28 | <!ENTITY panel.tabs.tags "Tags" > |
29 | <!ENTITY panel.tabs.upload "Upload" > | 29 | <!ENTITY panel.tabs.upload "Upload" > |
30 | 30 | ||
31 | <!ENTITY panel.search.cmd_search.label "Search" > | 31 | <!ENTITY panel.search.cmd_search.label "Search" > |
32 | <!ENTITY panel.search.search_for.label "Search for:" > | 32 | <!ENTITY panel.search.search_for.label "Search for:" > |
33 | <!ENTITY panel.search.mode.tagsonly.label "tags"> | 33 | <!ENTITY panel.search.mode.tagsonly.label "tags"> |
34 | <!ENTITY panel.search.mode.tagsonly.tip "Search tags only"> | 34 | <!ENTITY panel.search.mode.tagsonly.tip "Search tags only"> |
35 | <!ENTITY panel.search.mode.mine.label "mine"> | 35 | <!ENTITY panel.search.mode.mine.label "mine"> |
36 | <!ENTITY panel.search.col.title.label "Title"> | 36 | <!ENTITY panel.search.col.title.label "Title"> |
37 | <!ENTITY panel.search.cmd_search_open.label "Open"> | 37 | <!ENTITY panel.search.cmd_search_open.label "Open"> |
38 | <!ENTITY panel.search.cmd_search_prev_page.label "«"> | ||
39 | <!ENTITY panel.search.cmd_search_next_page.label "»"> | ||
38 | 40 | ||
39 | <!ENTITY panel.sets.name.label "Set"> | 41 | <!ENTITY panel.sets.name.label "Set"> |
40 | <!ENTITY panel.sets.name.tip "Photoset name"> | 42 | <!ENTITY panel.sets.name.tip "Photoset name"> |
41 | <!ENTITY panel.sets.photos.label "Photos"> | 43 | <!ENTITY panel.sets.photos.label "Photos"> |
42 | <!ENTITY panel.sets.photos.tip "Number of photos in set"> | 44 | <!ENTITY panel.sets.photos.tip "Number of photos in set"> |
43 | 45 | ||
44 | <!ENTITY panel.sets.cmd_refresh_sets "Refresh"> | 46 | <!ENTITY panel.sets.cmd_refresh_sets "Refresh"> |
45 | <!ENTITY panel.sets.cmd_properties "Properties"> | 47 | <!ENTITY panel.sets.cmd_properties "Properties"> |
46 | 48 | ||
47 | <!ENTITY panel.sets.generate_html "Generate HTML"> | 49 | <!ENTITY panel.sets.generate_html "Generate HTML"> |
48 | 50 | ||
49 | <!ENTITY panel.setphotos.title.label "Title"> | 51 | <!ENTITY panel.setphotos.title.label "Title"> |
diff --git a/locale/en-US/fireflix.properties b/locale/en-US/fireflix.properties index 7caa12f..18300ff 100644 --- a/locale/en-US/fireflix.properties +++ b/locale/en-US/fireflix.properties | |||
@@ -1,11 +1,13 @@ | |||
1 | postUploadPhotoset=Create a new photoset for uploaded photos (cancel if you don't want to create a photoset) | 1 | postUploadPhotoset=Create a new photoset for uploaded photos (cancel if you don't want to create a photoset) |
2 | 2 | ||
3 | menutitle_Images=Images | 3 | menutitle_Images=Images |
4 | menutitle_Links=Linked to… | 4 | menutitle_Links=Linked to… |
5 | urltype_s=Small square (75x75) | 5 | urltype_s=Small square (75x75) |
6 | urltype_t=Thumbnail (fits in 100x100) | 6 | urltype_t=Thumbnail (fits in 100x100) |
7 | urltype_m=Small (fits in 240x240) | 7 | urltype_m=Small (fits in 240x240) |
8 | urltype__=Medium (fits in 500x500) | 8 | urltype__=Medium (fits in 500x500) |
9 | urltype_b=Large (fits in 1024x1024) | 9 | urltype_b=Large (fits in 1024x1024) |
10 | urltype_o=Original image | 10 | urltype_o=Original image |
11 | urltype_p=Flickr photo URL | 11 | urltype_p=Flickr photo URL |
12 | |||
13 | search_page=Page %S of %S | ||