summaryrefslogtreecommitdiffabout
path: root/content/fireflix.js
Unidiff
Diffstat (limited to 'content/fireflix.js') (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js50
1 files changed, 45 insertions, 5 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index e144aae..92c42f4 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -692,7 +692,8 @@ var fireflix = {
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 },
@@ -729,6 +730,10 @@ var fireflix = {
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',
@@ -742,21 +747,56 @@ var fireflix = {
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 = '';