summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2006-10-02 19:51:26 (UTC)
committer Michael Krelin <hacker@klever.net>2006-10-02 19:51:26 (UTC)
commit5ebff6dee62ada9c0559f65381ccd92892911151 (patch) (unidiff)
treeca36d8fd3da98846eda11d38cc049ff6dd8c5915
parentb568e40a49d810d49bcc4af3bcb81ee1812627a5 (diff)
downloadfireflix-5ebff6dee62ada9c0559f65381ccd92892911151.zip
fireflix-5ebff6dee62ada9c0559f65381ccd92892911151.tar.gz
fireflix-5ebff6dee62ada9c0559f65381ccd92892911151.tar.bz2
preparse photo descriptions to avoid breaking things because of invalid html in description
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@181 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js14
-rw-r--r--locale/en-US/fireflix.properties2
2 files changed, 12 insertions, 4 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index 92c42f4..966630c 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -753,100 +753,106 @@ var fireflix = {
753 for(var p in pars) this.paging.pars[p] = pars[p]; 753 for(var p in pars) this.paging.pars[p] = pars[p];
754 this.perform_search(pars); 754 this.perform_search(pars);
755 }, 755 },
756 perform_search: function(p) { 756 perform_search: function(p) {
757 var _this = this; 757 var _this = this;
758 this.fireflix.flickr.api_call( p, 758 this.fireflix.flickr.api_call( p,
759 function(xr) { 759 function(xr) {
760 var x = xr.responseXML; 760 var x = xr.responseXML;
761 var xp = xp_nodes('/rsp/photos/photo',x); 761 var xp = xp_nodes('/rsp/photos/photo',x);
762 _this.importXPR(xp); 762 _this.importXPR(xp);
763 _this.tree.ensureRowIsVisible(0); 763 _this.tree.ensureRowIsVisible(0);
764 xp = xp_node('/rsp/photos',x); 764 xp = xp_node('/rsp/photos',x);
765 _this.paging.page = parseInt(xp.getAttribute('page')); 765 _this.paging.page = parseInt(xp.getAttribute('page'));
766 _this.paging.pages = parseInt(xp.getAttribute('pages')); 766 _this.paging.pages = parseInt(xp.getAttribute('pages'));
767 _this.paging.perpage = parseInt(xp.getAttribute('perpage')); 767 _this.paging.perpage = parseInt(xp.getAttribute('perpage'));
768 _this.paging.total = parseInt(xp.getAttribute('total')); 768 _this.paging.total = parseInt(xp.getAttribute('total'));
769 _this.update_paging(); 769 _this.update_paging();
770 _this.on_select(); 770 _this.on_select();
771 }, function(x,s,c,m) { 771 }, function(x,s,c,m) {
772 _this.fireflix.flickr_failure(x,s,c,m); 772 _this.fireflix.flickr_failure(x,s,c,m);
773 } 773 }
774 ); 774 );
775 }, 775 },
776 on_cmd_prev: function(ev) { 776 on_cmd_prev: function(ev) {
777 var pars = new Object(); 777 var pars = new Object();
778 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 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; 779 pars.page=this.paging.page-1; pars.per_page=this.paging.perpage;
780 this.perform_search(pars); 780 this.perform_search(pars);
781 }, 781 },
782 on_cmd_next: function(ev) { 782 on_cmd_next: function(ev) {
783 var pars = new Object(); 783 var pars = new Object();
784 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 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; 785 pars.page=this.paging.page+1; pars.per_page=this.paging.perpage;
786 this.perform_search(pars); 786 this.perform_search(pars);
787 }, 787 },
788 update_paging: function() { 788 update_paging: function() {
789 if(! (this.paging.pars && this.paging.page && this.paging.pages) ) { 789 if(! (this.paging.pars && this.paging.page && this.paging.pages) ) {
790 this.search_page.value=''; this.search_page.hidden = true; 790 this.search_page.value=''; this.search_page.hidden = true;
791 this.cmd_search_prev_page.setAttribute('disabled','true'); 791 this.cmd_search_prev_page.setAttribute('disabled','true');
792 this.cmd_search_next_page.setAttribute('disabled','true'); 792 this.cmd_search_next_page.setAttribute('disabled','true');
793 }else{ 793 }else{
794 this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]); 794 this.search_page.value=this.fireflix.loc_strings.getFormattedString('search_page',[this.paging.page,this.paging.pages]);
795 this.search_page.hidden=false; 795 this.search_page.hidden=false;
796 this.cmd_search_prev_page.setAttribute('disabled',(this.paging.page>1)?'false':'true'); 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'); 797 this.cmd_search_next_page.setAttribute('disabled',(this.paging.page<this.paging.pages)?'false':'true');
798 } 798 }
799 }, 799 },
800 render_description_frame: function(content) { 800 render_description_frame: function(content) {
801 if(!content) { 801 this.searchresult_description.innerHTML = '';
802 this.searchresult_description.innerHTML = ''; 802 if(content) {
803 }else{ 803 var dp = new DOMParser();
804 this.searchresult_description.innerHTML = content?content:''; 804 var pd = dp.parseFromString(
805 '<div xmlns="http://www.w3.org/1999/xhtml">'+content+'</div>', 'text/xml' );
806 var de = pd.documentElement;
807 if(de.tagName=='parsererror')
808 this.searchresult_description.innerHTML=this.fireflix.loc_strings.getString('broken_description');
809 else
810 this.searchresult_description.appendChild(de);
805 /* of all linking elements flickr only allows a */ 811 /* of all linking elements flickr only allows a */
806 var as = this.searchresult_description.getElementsByTagName('a'); 812 var as = this.searchresult_description.getElementsByTagName('a');
807 for(var a=0;a<as.length;++a) 813 for(var a=0;a<as.length;++a)
808 as.item(a).setAttribute('target','_blank'); 814 as.item(a).setAttribute('target','_blank');
809 } 815 }
810 }, 816 },
811 on_select: function() { 817 on_select: function() {
812 if(this.selection.currentIndex<0) { 818 if(this.selection.currentIndex<0) {
813 this.searchresult_props.hidden = true; 819 this.searchresult_props.hidden = true;
814 }else{ 820 }else{
815 var p = this.photos[this.selection.currentIndex]; 821 var p = this.photos[this.selection.currentIndex];
816 if(!p) { 822 if(!p) {
817 this.searchresult_props.hidden = true; 823 this.searchresult_props.hidden = true;
818 }else{ 824 }else{
819 this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t'); 825 this.search_photo.src = this.fireflix.flickr.make_photo_url(p,'t');
820 this.searchresult_title.value = p.title; 826 this.searchresult_title.value = p.title;
821 this.searchresult_title.tooltipText = p.title; 827 this.searchresult_title.tooltipText = p.title;
822 this.render_description_frame(null); 828 this.render_description_frame(null);
823 if(p.description==null && p.description==undefined) { 829 if(p.description==null && p.description==undefined) {
824 var pid = p.id; 830 var pid = p.id;
825 var ci = this.selection.currentIndex; 831 var ci = this.selection.currentIndex;
826 var _this = this; 832 var _this = this;
827 this.fireflix.flickr.api_call( 833 this.fireflix.flickr.api_call(
828 { 834 {
829 method: 'flickr.photos.getInfo', 835 method: 'flickr.photos.getInfo',
830 auth_token: 'default', 836 auth_token: 'default',
831 photo_id: p.id, 837 photo_id: p.id,
832 secret: p.secret 838 secret: p.secret
833 }, function(xr) { 839 }, function(xr) {
834 var pp = _this.photos[ci]; 840 var pp = _this.photos[ci];
835 if(ci==_this.selection.currentIndex && pp.id==pid) { 841 if(ci==_this.selection.currentIndex && pp.id==pid) {
836 var n = xp_node('/rsp/photo',xr.responseXML); 842 var n = xp_node('/rsp/photo',xr.responseXML);
837 pp.fromNode_(n); 843 pp.fromNode_(n);
838 _this.render_description_frame(pp.description); 844 _this.render_description_frame(pp.description);
839 } 845 }
840 }, function(x,s,c,m) { 846 }, function(x,s,c,m) {
841 _this.fireflix.flickr_failure(x,s,c,m); 847 _this.fireflix.flickr_failure(x,s,c,m);
842 } 848 }
843 ); 849 );
844 this.searchresult_props.hidden = false; 850 this.searchresult_props.hidden = false;
845 }else{ 851 }else{
846 this.render_description_frame(p.description); 852 this.render_description_frame(p.description);
847 } 853 }
848 } 854 }
849 } 855 }
850 }, 856 },
851 on_cmd_open: function(ev) { 857 on_cmd_open: function(ev) {
852 if(this.selection.currentIndex<0) 858 if(this.selection.currentIndex<0)
diff --git a/locale/en-US/fireflix.properties b/locale/en-US/fireflix.properties
index 18300ff..f583040 100644
--- a/locale/en-US/fireflix.properties
+++ b/locale/en-US/fireflix.properties
@@ -1,13 +1,15 @@
1postUploadPhotoset=Create a new photoset for uploaded photos (cancel if you don't want to create a photoset) 1postUploadPhotoset=Create a new photoset for uploaded photos (cancel if you don't want to create a photoset)
2 2
3menutitle_Images=Images 3menutitle_Images=Images
4menutitle_Links=Linked to… 4menutitle_Links=Linked to…
5urltype_s=Small square (75x75) 5urltype_s=Small square (75x75)
6urltype_t=Thumbnail (fits in 100x100) 6urltype_t=Thumbnail (fits in 100x100)
7urltype_m=Small (fits in 240x240) 7urltype_m=Small (fits in 240x240)
8urltype__=Medium (fits in 500x500) 8urltype__=Medium (fits in 500x500)
9urltype_b=Large (fits in 1024x1024) 9urltype_b=Large (fits in 1024x1024)
10urltype_o=Original image 10urltype_o=Original image
11urltype_p=Flickr photo URL 11urltype_p=Flickr photo URL
12 12
13search_page=Page %S of %S 13search_page=Page %S of %S
14
15broken_description=Broken photo description