summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--content/fireflix.js2
1 files changed, 0 insertions, 2 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index a4f13b6..0f51397 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -1,793 +1,791 @@
1function splitascii(s) { 1function splitascii(s) {
2 var rv=''; 2 var rv='';
3 for(var i=0;i<s.length;++i) { 3 for(var i=0;i<s.length;++i) {
4 var w = s.charCodeAt(i); 4 var w = s.charCodeAt(i);
5 rv += String.fromCharCode( 5 rv += String.fromCharCode(
6 w&0xff, (w>>8)&0xff ); 6 w&0xff, (w>>8)&0xff );
7 } 7 }
8 return rv; 8 return rv;
9} 9}
10 10
11 11
12var fireflix = { 12var fireflix = {
13 flickr: new Flickr(), 13 flickr: new Flickr(),
14 init: function() { 14 init: function() {
15 pull_elements(this,document,[ 15 pull_elements(this,document,[
16 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth', 16 'cmd_auth_auth','cmd_auth_done','cmd_auth_unauth',
17 'menu_auth_done','b_auth','b_auth_done','auth_info', 17 'menu_auth_done','b_auth','b_auth_done','auth_info',
18 'loc_strings','cmd_set_props' 18 'loc_strings','cmd_set_props'
19 ]); 19 ]);
20 this.build_menus(); 20 this.build_menus();
21 this.foundphotos.init(this); 21 this.foundphotos.init(this);
22 this.photosets.init(this); 22 this.photosets.init(this);
23 this.photoset.init(this); 23 this.photoset.init(this);
24 this.uploads.init(this); 24 this.uploads.init(this);
25 this.uploadObserver.init(this); 25 this.uploadObserver.init(this);
26 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3'; 26 this.flickr.api_key = '9c43cd66947a57e6f29db1a9da3f72e3';
27 this.flickr.api_shs = '9c33c9e2f0f0cfd5'; 27 this.flickr.api_shs = '9c33c9e2f0f0cfd5';
28 this.flickr.prefs_root = 'net.klever.kin.fireflix'; 28 this.flickr.prefs_root = 'net.klever.kin.fireflix';
29 this.flickr.load_token(); 29 this.flickr.load_token();
30 this.no_auth_info_label = this.auth_info.value; 30 this.no_auth_info_label = this.auth_info.value;
31 this.set_auth_state(this.flickr.token,false); 31 this.set_auth_state(this.flickr.token,false);
32 if(this.flickr.token) { 32 if(this.flickr.token) {
33 this.refresh_stuff(); 33 this.refresh_stuff();
34 }else{ 34 }else{
35 this.on_cmd_auth(); 35 this.on_cmd_auth();
36 } 36 }
37 }, 37 },
38 set_auth_state: function(au,inp) { /* authorized, in progress */ 38 set_auth_state: function(au,inp) { /* authorized, in progress */
39 this.cmd_auth_unauth.disabled = !au; 39 this.cmd_auth_unauth.disabled = !au;
40 this.b_auth.hidden = au || inp; 40 this.b_auth.hidden = au || inp;
41 this.b_auth_done.hidden = !inp; 41 this.b_auth_done.hidden = !inp;
42 this.menu_auth_done.hidden = !inp; 42 this.menu_auth_done.hidden = !inp;
43 this.cmd_auth_done.setAttribute('disabled',!inp); 43 this.cmd_auth_done.setAttribute('disabled',!inp);
44 this.auth_info.disabled = !au; 44 this.auth_info.disabled = !au;
45 if(au) { 45 if(au) {
46 this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */ 46 this.auth_info.value = this.flickr.user.fullname+' ['+this.flickr.user.username+']'; /* TODO: move to locale */
47 }else{ 47 }else{
48 this.auth_info.value = this.no_auth_info_label; 48 this.auth_info.value = this.no_auth_info_label;
49 } 49 }
50 }, 50 },
51 on_cmd_auth: function() { 51 on_cmd_auth: function() {
52 var _this = this; 52 var _this = this;
53 this.flickr.authorize_0( 53 this.flickr.authorize_0(
54 'delete', 54 'delete',
55 function(x,f,u) { 55 function(x,f,u) {
56 _this.openTab(u); 56 _this.openTab(u);
57 _this.set_auth_state(_this.flickr.token,true); 57 _this.set_auth_state(_this.flickr.token,true);
58 }, function(x,s,c,m) { 58 }, function(x,s,c,m) {
59 _this.flickr_failure(x,s,c,m); 59 _this.flickr_failure(x,s,c,m);
60 } 60 }
61 ); 61 );
62 }, 62 },
63 on_cmd_auth_done: function() { 63 on_cmd_auth_done: function() {
64 this.set_auth_state(this.flickr.token,false); 64 this.set_auth_state(this.flickr.token,false);
65 var _this = this; 65 var _this = this;
66 this.flickr.authorize_1( 66 this.flickr.authorize_1(
67 function() { 67 function() {
68 _this.flickr.save_token(); 68 _this.flickr.save_token();
69 _this.refresh_stuff(); 69 _this.refresh_stuff();
70 _this.set_auth_state(_this.flickr.token,false); 70 _this.set_auth_state(_this.flickr.token,false);
71 _this.auth_info.value = 71 _this.auth_info.value =
72 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']'; 72 _this.flickr.user.fullname+' ['+_this.flickr.user.username+']';
73 }, function(x,s,c,m) { 73 }, function(x,s,c,m) {
74 _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */ 74 _this.set_auth_state(_this.flickr.token,false); /* XXX: no reset token? */
75 _this.flickr_failure(x,s,c,m); 75 _this.flickr_failure(x,s,c,m);
76 } 76 }
77 ); 77 );
78 }, 78 },
79 on_cmd_auth_unauth: function() { 79 on_cmd_auth_unauth: function() {
80 this.flickr.reset_token(); 80 this.flickr.reset_token();
81 this.set_auth_state(false,false); 81 this.set_auth_state(false,false);
82 }, 82 },
83 83
84 refresh_sets: function() { this.photosets.refresh_sets(); }, 84 refresh_sets: function() { this.photosets.refresh_sets(); },
85 refresh_stuff: function() { 85 refresh_stuff: function() {
86 this.refresh_sets(); 86 this.refresh_sets();
87 this.refresh_user_tags(); 87 this.refresh_user_tags();
88 }, 88 },
89 89
90 /* photoset treeview */ 90 /* photoset treeview */
91 photoset: { 91 photoset: {
92 photos: new Array(), 92 photos: new Array(),
93 fireflix: null, 93 fireflix: null,
94 init: function(f) { 94 init: function(f) {
95 this.fireflix = f; 95 this.fireflix = f;
96 pull_elements(this,document,[ 'set_photo' ]); 96 pull_elements(this,document,[ 'set_photo' ]);
97 document.getElementById('setphotos').view = this; 97 document.getElementById('setphotos').view = this;
98 }, 98 },
99 rowCount: 0, 99 rowCount: 0,
100 getCellText: function(r,c) { 100 getCellText: function(r,c) {
101 var p = this.photos[r]; 101 var p = this.photos[r];
102 if(c.id=='sp_title') return p.title; 102 if(c.id=='sp_title') return p.title;
103 if(c.id=='sp_taken') return p.datetaken; 103 if(c.id=='sp_taken') return p.datetaken;
104 if(c.id=='sp_upload') { 104 if(c.id=='sp_upload') {
105 var du = new Date(p.dateupload*1000); 105 var du = new Date(p.dateupload*1000);
106 var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate() 106 var rv = du.getFullYear()+'-'+(du.getMonth()+1)+'-'+du.getDate()
107 +' '+ 107 +' '+
108 du.getHours()+':'+du.getMinutes()+':'+du.getSeconds(); 108 du.getHours()+':'+du.getMinutes()+':'+du.getSeconds();
109 return rv.replace(/(\D)(\d)(\D)/,'$10$2$3'); 109 return rv.replace(/(\D)(\d)(\D)/,'$10$2$3');
110 } 110 }
111 return c.id; 111 return c.id;
112 }, 112 },
113 setTree: function(t) { this.tree = t }, 113 setTree: function(t) { this.tree = t },
114 isContainer: function(r) { return false; }, 114 isContainer: function(r) { return false; },
115 isSeparator: function(r) { return false; }, 115 isSeparator: function(r) { return false; },
116 isSorted: function(r) { return false; }, 116 isSorted: function(r) { return false; },
117 getLevel: function(r) { return 0; }, 117 getLevel: function(r) { return 0; },
118 getImageSrc: function(r,c) { return null }, 118 getImageSrc: function(r,c) { return null },
119 getRowProperties: function(r,p) {}, 119 getRowProperties: function(r,p) {},
120 getCellProperties: function(cid,cel,p) {}, 120 getCellProperties: function(cid,cel,p) {},
121 getColumnProperties: function(cid,cel,p) { }, 121 getColumnProperties: function(cid,cel,p) { },
122 cycleHeader: function(cid,e) { }, 122 cycleHeader: function(cid,e) { },
123 getParentIndex: function(r) { return -1; }, 123 getParentIndex: function(r) { return -1; },
124 drop: function(r,o) { }, 124 drop: function(r,o) { },
125 canDropBeforeAfter: function(r,b) { return false }, 125 canDropBeforeAfter: function(r,b) { return false },
126 126
127 importXPR: function(xp) { 127 importXPR: function(xp) {
128 this.tree.beginUpdateBatch(); 128 this.tree.beginUpdateBatch();
129 this.photos = new Array(); 129 this.photos = new Array();
130 var n; while(n=xp.iterateNext()) { 130 var n; while(n=xp.iterateNext()) {
131 this.photos.push(new Photo(n)); 131 this.photos.push(new Photo(n));
132 } 132 }
133 this.rowCount = this.photos.length; 133 this.rowCount = this.photos.length;
134 this.tree.endUpdateBatch(); 134 this.tree.endUpdateBatch();
135 }, 135 },
136 load_photos: function(psid) { 136 load_photos: function(psid) {
137 var _this = this; 137 var _this = this;
138 this.fireflix.flickr.api_call( 138 this.fireflix.flickr.api_call(
139 { 139 {
140 method: 'flickr.photosets.getPhotos', 140 method: 'flickr.photosets.getPhotos',
141 auth_token: 'default', 141 auth_token: 'default',
142 photoset_id: psid, 142 photoset_id: psid,
143 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' 143 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
144 }, function(xr) { 144 }, function(xr) {
145 var x = xr.responseXML; 145 var x = xr.responseXML;
146 var xp = x.evaluate( 146 var xp = x.evaluate(
147 '/rsp/photoset/photo', x, null, 147 '/rsp/photoset/photo', x, null,
148 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 148 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
149 _this.importXPR(xp); 149 _this.importXPR(xp);
150 }, function(x,s,c,m) { 150 }, function(x,s,c,m) {
151 _this.fireflix.flickr_failure(x,s,c,m); 151 _this.fireflix.flickr_failure(x,s,c,m);
152 } 152 }
153 ); 153 );
154 }, 154 },
155 on_select: function() { 155 on_select: function() {
156 if(this.selection.count==1) { 156 if(this.selection.count==1) {
157 var p = this.photos[this.selection.currentIndex]; 157 var p = this.photos[this.selection.currentIndex];
158 this.set_photo.src = 158 this.set_photo.src =
159 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); 159 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t');
160 this.set_photo.hidden = false; 160 this.set_photo.hidden = false;
161 }else{ 161 }else{
162 this.set_photo.hidden = true; 162 this.set_photo.hidden = true;
163 } 163 }
164 } 164 }
165 }, 165 },
166 166
167 /* photosets treeview */ 167 /* photosets treeview */
168 photosets: { 168 photosets: {
169 sets: new Array(), 169 sets: new Array(),
170 fireflix: null, 170 fireflix: null,
171 init: function(f) { 171 init: function(f) {
172 this.fireflix = f; 172 this.fireflix = f;
173 document.getElementById('setslist').view = this; 173 document.getElementById('setslist').view = this;
174 }, 174 },
175 rowCount: 0, 175 rowCount: 0,
176 getCellText: function(r,c) { 176 getCellText: function(r,c) {
177 var s = this.sets[r]; 177 var s = this.sets[r];
178 if(c.id=='sl_name') return s.title; 178 if(c.id=='sl_name') return s.title;
179 if(c.id=='sl_photos') return s.photos; 179 if(c.id=='sl_photos') return s.photos;
180 return c.id; 180 return c.id;
181 }, 181 },
182 setTree: function(t) { this.tree = t }, 182 setTree: function(t) { this.tree = t },
183 isContainer: function(r) { return false; }, 183 isContainer: function(r) { return false; },
184 isSeparator: function(r) { return false; }, 184 isSeparator: function(r) { return false; },
185 isSorted: function() { return false; }, 185 isSorted: function() { return false; },
186 getLevel: function(r) { return 0; }, 186 getLevel: function(r) { return 0; },
187 getImageSrc: function(r,c) { return null }, 187 getImageSrc: function(r,c) { return null },
188 getRowProperties: function(r,p) {}, 188 getRowProperties: function(r,p) {},
189 getCellProperties: function(cid,cel,p) { }, 189 getCellProperties: function(cid,cel,p) { },
190 getColumnProperties: function(cid,cel,p) { }, 190 getColumnProperties: function(cid,cel,p) { },
191 cycleHeader: function(cid,e) { }, 191 cycleHeader: function(cid,e) { },
192 getParentIndex: function(r) { return -1; }, 192 getParentIndex: function(r) { return -1; },
193 drop: function(r,o) { }, 193 drop: function(r,o) { },
194 canDropBeforeAfter: function(r,b) { return false }, 194 canDropBeforeAfter: function(r,b) { return false },
195 195
196 importXPR: function(xp) { 196 importXPR: function(xp) {
197 this.tree.beginUpdateBatch(); 197 this.tree.beginUpdateBatch();
198 this.sets = new Array(); 198 this.sets = new Array();
199 var n; while(n=xp.iterateNext()) { 199 var n; while(n=xp.iterateNext()) {
200 this.sets.push(new Photoset(n)); 200 this.sets.push(new Photoset(n));
201 } 201 }
202 this.rowCount = this.sets.length; 202 this.rowCount = this.sets.length;
203 this.tree.endUpdateBatch(); 203 this.tree.endUpdateBatch();
204 }, 204 },
205 refresh_sets: function() { 205 refresh_sets: function() {
206 var _this = this; 206 var _this = this;
207 this.fireflix.flickr.api_call( 207 this.fireflix.flickr.api_call(
208 { 208 {
209 method: 'flickr.photosets.getList', 209 method: 'flickr.photosets.getList',
210 auth_token: 'default' 210 auth_token: 'default'
211 }, function(xr) { 211 }, function(xr) {
212 var x = xr.responseXML; 212 var x = xr.responseXML;
213 var xp = x.evaluate( 213 var xp = x.evaluate(
214 '/rsp/photosets/photoset', x, null, 214 '/rsp/photosets/photoset', x, null,
215 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 215 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
216 _this.importXPR(xp); 216 _this.importXPR(xp);
217 }, function(x,s,c,m) { 217 }, function(x,s,c,m) {
218 _this.fireflix.flickr_failure(x,s,c,m); 218 _this.fireflix.flickr_failure(x,s,c,m);
219 } 219 }
220 ); 220 );
221 }, 221 },
222 on_select: function() { 222 on_select: function() {
223 if(this.selection.count==1) { 223 if(this.selection.count==1) {
224 this.fireflix.cmd_set_props.setAttribute('disabled','false'); 224 this.fireflix.cmd_set_props.setAttribute('disabled','false');
225 var s = this.sets[this.selection.currentIndex]; 225 var s = this.sets[this.selection.currentIndex];
226 this.fireflix.photoset.load_photos(s.id); 226 this.fireflix.photoset.load_photos(s.id);
227 }else{ 227 }else{
228 this.fireflix.cmd_set_props.setAttribute('disabled','true'); 228 this.fireflix.cmd_set_props.setAttribute('disabled','true');
229 } 229 }
230 } 230 }
231 }, 231 },
232 232
233 refresh_user_tags: function() { 233 refresh_user_tags: function() {
234 var lb = document.getElementById('tagslist'); 234 var lb = document.getElementById('tagslist');
235 var _this = this; 235 var _this = this;
236 this.flickr.api_call( 236 this.flickr.api_call(
237 { 237 {
238 method: 'flickr.tags.getListUser', 238 method: 'flickr.tags.getListUser',
239 auth_token: 'default', 239 auth_token: 'default',
240 }, function(xr) { 240 }, function(xr) {
241 var x = xr.responseXML; 241 var x = xr.responseXML;
242 var xp = x.evaluate( 242 var xp = x.evaluate(
243 '/rsp/who/tags/tag', x, null, 243 '/rsp/who/tags/tag', x, null,
244 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 244 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
245 // TODO: clear list 245 // TODO: clear list
246 var n; while(n=xp.iterateNext()) { 246 var n; while(n=xp.iterateNext()) {
247 lb.appendItem(n.firstChild.nodeValue); 247 lb.appendItem(n.firstChild.nodeValue);
248 } 248 }
249 }, function(x,s,c,m) { 249 }, function(x,s,c,m) {
250 _this.flickr_failure(x,s,c,m); 250 _this.flickr_failure(x,s,c,m);
251 } 251 }
252 ); 252 );
253 }, 253 },
254 254
255 uploadObserver: { 255 uploadObserver: {
256 fireflix: null, 256 fireflix: null,
257 init: function(f) { 257 init: function(f) {
258 this.fireflix = f; 258 this.fireflix = f;
259 }, 259 },
260 getSupportedFlavours: function() { 260 getSupportedFlavours: function() {
261 var rv = new FlavourSet(); 261 var rv = new FlavourSet();
262 rv.appendFlavour('application/x-moz-file','nsIFile'); 262 rv.appendFlavour('application/x-moz-file','nsIFile');
263 rv.appendFlavour('application/x-moz-url'); 263 rv.appendFlavour('application/x-moz-url');
264 rv.appendFlavour('text/uri-list'); 264 rv.appendFlavour('text/uri-list');
265 rv.appendFlavour('text/unicode'); 265 rv.appendFlavour('text/unicode');
266 return rv; 266 return rv;
267 }, 267 },
268 canHandleMultipleItems: true, 268 canHandleMultipleItems: true,
269 onDragOver: function(ev,fl,sess) { 269 onDragOver: function(ev,fl,sess) {
270 return true; 270 return true;
271 }, 271 },
272 onDrop: function(ev,dd,s) { 272 onDrop: function(ev,dd,s) {
273 var ldf = null; 273 var ldf = null;
274 for(var i in dd.dataList) { 274 for(var i in dd.dataList) {
275 var di = dd.dataList[i]; 275 var di = dd.dataList[i];
276 var dif = di.first; 276 var dif = di.first;
277 if( 277 if(
278 ldf==null 278 ldf==null
279 || ldf.flavour.contentType!=dif.flavour.contentType 279 || ldf.flavour.contentType!=dif.flavour.contentType
280 || ldf.contentLength!=dif.contentLength 280 || ldf.contentLength!=dif.contentLength
281 || ldf.data!=dif.data ) 281 || ldf.data!=dif.data )
282 this.drop_item(ev,di,s); 282 this.drop_item(ev,di,s);
283 ldf = dif; 283 ldf = dif;
284 } 284 }
285 }, 285 },
286 drop_item: function(ev,di,s) { 286 drop_item: function(ev,di,s) {
287 var d = di.first; 287 var d = di.first;
288 switch(d.flavour.contentType) { 288 switch(d.flavour.contentType) {
289 case 'text/unicode': 289 case 'text/unicode':
290 this.drop_urilist(ev,d.data,s); 290 this.drop_urilist(ev,d.data,s);
291 break; 291 break;
292 case 'application/x-moz-file': 292 case 'application/x-moz-file':
293 this.fireflix.uploads.add(d.data.path); 293 this.fireflix.uploads.add(d.data.path);
294 document.getElementById('fireflix_tabs').selectedTab 294 document.getElementById('fireflix_tabs').selectedTab
295 = document.getElementById('tab_upload'); 295 = document.getElementById('tab_upload');
296 break; 296 break;
297 case 'text/uri-list': 297 case 'text/uri-list':
298 // is it ascii or could it be utf8? 298 // is it ascii or could it be utf8?
299 this.drop_urilist(ev,splitascii(d.data),s); 299 this.drop_urilist(ev,splitascii(d.data),s);
300 break; 300 break;
301 default: alert(d.flavour.contentType+':'+d.data); break; 301 default: alert(d.flavour.contentType+':'+d.data); break;
302 }; 302 };
303 }, 303 },
304 drop_urilist: function(ev,ul,s) { 304 drop_urilist: function(ev,ul,s) {
305 // TODO: check for being a file? 305 // TODO: check for being a file?
306 var us = decodeURIComponent(ul).split(/[\r\n]/); 306 var us = decodeURIComponent(ul).split(/[\r\n]/);
307 for(var ui in us) 307 for(var ui in us)
308 if(/\S/.test(us[ui])) 308 if(/\S/.test(us[ui]))
309 this.fireflix.uploads.add(us[ui]); 309 this.fireflix.uploads.add(us[ui]);
310 document.getElementById('fireflix_tabs').selectedTab 310 document.getElementById('fireflix_tabs').selectedTab
311 = document.getElementById('tab_upload'); 311 = document.getElementById('tab_upload');
312 } 312 }
313 }, 313 },
314 314
315 uploads: { 315 uploads: {
316 fireflix: null, 316 fireflix: null,
317 init: function(f) { 317 init: function(f) {
318 this.fireflix=f; 318 this.fireflix=f;
319 pull_elements(this,document,[ 319 pull_elements(this,document,[
320 'upload_filename','upload_title','upload_file_preview', 320 'upload_filename','upload_title','upload_file_preview',
321 'upload_file_props','upload_progress','upload_tags', 321 'upload_file_props','upload_progress','upload_tags',
322 'cmd_uploads_upload' 322 'cmd_uploads_upload'
323 ]); 323 ]);
324 document.getElementById('uploadlist').view = this; 324 document.getElementById('uploadlist').view = this;
325 }, 325 },
326 files: new Array(), 326 files: new Array(),
327 rowCount: 0, 327 rowCount: 0,
328 getCellText: function(r,c) { 328 getCellText: function(r,c) {
329 var f = this.files[r]; 329 var f = this.files[r];
330 if(c.id=='up_file') return f.file; 330 if(c.id=='up_file') return f.file;
331 if(c.id=='up_title') return f.title; 331 if(c.id=='up_title') return f.title;
332 if(c.id=='up_status') return f.state; 332 if(c.id=='up_status') return f.state;
333 return c.id; 333 return c.id;
334 }, 334 },
335 setTree: function(t) { this.tree = t }, 335 setTree: function(t) { this.tree = t },
336 isContainer: function(r) { return false; }, 336 isContainer: function(r) { return false; },
337 isSeparator: function(r) { return false; }, 337 isSeparator: function(r) { return false; },
338 isSorted: function(r) { return false; }, 338 isSorted: function(r) { return false; },
339 getLevel: function(r) { return 0; }, 339 getLevel: function(r) { return 0; },
340 getImageSrc: function(r,c) { return null }, 340 getImageSrc: function(r,c) { return null },
341 getRowProperties: function(r,p) { 341 getRowProperties: function(r,p) {
342 try { 342 try {
343 if(!Components) return; 343 if(!Components) return;
344 }catch(e) { return } 344 }catch(e) { return }
345 var f = this.files[r]; 345 var f = this.files[r];
346 var as = Components.classes['@mozilla.org/atom-service;1']. 346 var as = Components.classes['@mozilla.org/atom-service;1'].
347 getService(Components.interfaces.nsIAtomService); 347 getService(Components.interfaces.nsIAtomService);
348 p.AppendElement(as.getAtom(f.state)); 348 p.AppendElement(as.getAtom(f.state));
349 }, 349 },
350 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); }, 350 getCellProperties: function(r,c,p) { this.getRowProperties(r,p); },
351 getColumnProperties: function(c,p) { }, 351 getColumnProperties: function(c,p) { },
352 cycleHeader: function(cid,e) { }, 352 cycleHeader: function(cid,e) { },
353 getParentIndex: function(r) { return -1; }, 353 getParentIndex: function(r) { return -1; },
354 drop: function(r,o) { }, 354 drop: function(r,o) { },
355 canDropBeforeAfter: function(r,b) { return false }, 355 canDropBeforeAfter: function(r,b) { return false },
356 356
357 add: function(f) { 357 add: function(f) {
358 if(f.indexOf('file:/')==0) { 358 if(f.indexOf('file:/')==0) {
359 f = f.substr(5); 359 f = f.substr(5);
360 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-) 360 while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-)
361 f = f.substr(1); 361 f = f.substr(1);
362 } 362 }
363 } 363 }
364 var t = f; 364 var t = f;
365 var ls = t.lastIndexOf('/'); 365 var ls = t.lastIndexOf('/');
366 if(ls>0) t = t.substr(ls+1); 366 if(ls>0) t = t.substr(ls+1);
367 ls = t.lastIndexOf('\\'); 367 ls = t.lastIndexOf('\\');
368 if(ls>0) t = t.substr(ls+1); 368 if(ls>0) t = t.substr(ls+1);
369 var ld = t.lastIndexOf('.'); 369 var ld = t.lastIndexOf('.');
370 if(ld>0) t = t.substr(0,ld); 370 if(ld>0) t = t.substr(0,ld);
371 this.files.push( { 371 this.files.push( {
372 file: f, 372 file: f,
373 title: t, 373 title: t,
374 tags: '', 374 tags: '',
375 state: 'pending' 375 state: 'pending'
376 } ); 376 } );
377 this.rowCount = this.files.length; 377 this.rowCount = this.files.length;
378 this.tree.rowCountChanged(this.rowCount-1,1); 378 this.tree.rowCountChanged(this.rowCount-1,1);
379 }, 379 },
380 380
381 upload_worker: function() { 381 upload_worker: function() {
382 for(var f in this.files) { 382 for(var f in this.files) {
383 if(this.files[f].state=='pending') { 383 if(this.files[f].state=='pending') {
384 var ff = this.files[f]; 384 var ff = this.files[f];
385 dump('upload '+ff.file+'\n');
386 this.on_file_upload(ff); 385 this.on_file_upload(ff);
387 ff.state='uploading'; 386 ff.state='uploading';
388 this.tree.invalidate(); 387 this.tree.invalidate();
389 var _this = this; 388 var _this = this;
390 this.fireflix.flickr.upload_file( 389 this.fireflix.flickr.upload_file(
391 ff.file, { title: ff.title, tags: ff.tags }, 390 ff.file, { title: ff.title, tags: ff.tags },
392 function(x,p) { 391 function(x,p) {
393 ff.photoid = p; 392 ff.photoid = p;
394 _this.batch_ids.push(p); 393 _this.batch_ids.push(p);
395 ff.state='completed'; 394 ff.state='completed';
396 _this.tree.invalidate(); 395 _this.tree.invalidate();
397 window.setTimeout(_this.upload_to,0,_this); 396 window.setTimeout(_this.upload_to,0,_this);
398 }, function(x,s,c,m) { 397 }, function(x,s,c,m) {
399 ff.state='failed'; 398 ff.state='failed';
400 ff.flickr_errcode = c; 399 ff.flickr_errcode = c;
401 ff.flickr_errmsg = m; 400 ff.flickr_errmsg = m;
402 _this.tree.invalidate(); 401 _this.tree.invalidate();
403 window.setTimeout(_this.upload_to,0,_this); 402 window.setTimeout(_this.upload_to,0,_this);
404 } 403 }
405 ); 404 );
406 return; 405 return;
407 } 406 }
408 } 407 }
409 dump('uploading done\n');
410 this.on_finish_upload(); 408 this.on_finish_upload();
411 }, 409 },
412 upload_to: function(_this) { _this.upload_worker(); }, 410 upload_to: function(_this) { _this.upload_worker(); },
413 on_file_upload: function(f) { 411 on_file_upload: function(f) {
414 this.cmd_uploads_upload.setAttribute('disabled','true'); 412 this.cmd_uploads_upload.setAttribute('disabled','true');
415 for(var fi in this.files) { 413 for(var fi in this.files) {
416 if(this.files[fi].file==f.file) { 414 if(this.files[fi].file==f.file) {
417 this.tree.ensureRowIsVisible(fi); 415 this.tree.ensureRowIsVisible(fi);
418 this.selection.rangedSelect(fi,fi,false); 416 this.selection.rangedSelect(fi,fi,false);
419 this.selection.currentIndex = fi; 417 this.selection.currentIndex = fi;
420 this.selToProps(); 418 this.selToProps();
421 break; 419 break;
422 } 420 }
423 } 421 }
424 }, 422 },
425 on_finish_upload: function() { 423 on_finish_upload: function() {
426 if(this.batch_ids.length) { 424 if(this.batch_ids.length) {
427 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); 425 var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset'));
428 if(psn!=null) { 426 if(psn!=null) {
429 var pids = this.batch_ids.join(','); 427 var pids = this.batch_ids.join(',');
430 var ppid = this.batch_ids[0]; 428 var ppid = this.batch_ids[0];
431 var _this = this; 429 var _this = this;
432 this.fireflix.flickr.api_call( 430 this.fireflix.flickr.api_call(
433 { 431 {
434 method: 'flickr.photosets.create', 432 method: 'flickr.photosets.create',
435 auth_token: 'default', 433 auth_token: 'default',
436 title: psn, 434 title: psn,
437 primary_photo_id: ppid 435 primary_photo_id: ppid
438 }, function(x) { 436 }, function(x) {
439 var npid = 437 var npid =
440 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id'); 438 x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id');
441 _this.fireflix.flickr.api_call( 439 _this.fireflix.flickr.api_call(
442 { 440 {
443 method: 'flickr.photosets.editPhotos', 441 method: 'flickr.photosets.editPhotos',
444 auth_token: 'default', 442 auth_token: 'default',
445 photoset_id: npid, 443 photoset_id: npid,
446 primary_photo_id: ppid, 444 primary_photo_id: ppid,
447 photo_ids: pids 445 photo_ids: pids
448 }, function(x) { 446 }, function(x) {
449 _this.fireflix.refresh_sets(); 447 _this.fireflix.refresh_sets();
450 }, function(x,s,c,m) { 448 }, function(x,s,c,m) {
451 _this.fireflix.flickr_failure(x,s,c,m); 449 _this.fireflix.flickr_failure(x,s,c,m);
452 } 450 }
453 ); 451 );
454 }, function(x,s,c,m) { 452 }, function(x,s,c,m) {
455 _this.fireflix.flickr_failure(x,s,c,m); 453 _this.fireflix.flickr_failure(x,s,c,m);
456 } 454 }
457 ); 455 );
458 } 456 }
459 } 457 }
460 this.selection.clearSelection(); 458 this.selection.clearSelection();
461 this.cmd_uploads_upload.setAttribute('disabled','false'); 459 this.cmd_uploads_upload.setAttribute('disabled','false');
462 this.upload_progress.setAttribute('hidden','true'); 460 this.upload_progress.setAttribute('hidden','true');
463 }, 461 },
464 462
465 clear_list: function() { 463 clear_list: function() {
466 this.tree.beginUpdateBatch(); 464 this.tree.beginUpdateBatch();
467 this.rowCount = 0; 465 this.rowCount = 0;
468 this.files = new Array(); 466 this.files = new Array();
469 this.tree.endUpdateBatch(); 467 this.tree.endUpdateBatch();
470 this.selToProps(); 468 this.selToProps();
471 }, 469 },
472 selectionChanged: function() { 470 selectionChanged: function() {
473 this.selToProps(); 471 this.selToProps();
474 }, 472 },
475 disableProps: function() { 473 disableProps: function() {
476 this.upload_filename.value=''; 474 this.upload_filename.value='';
477 this.upload_filename.disabled = true; 475 this.upload_filename.disabled = true;
478 this.upload_title.value=''; 476 this.upload_title.value='';
479 this.upload_title.disabled = true; 477 this.upload_title.disabled = true;
480 this.upload_file_preview.src = null; 478 this.upload_file_preview.src = null;
481 this.upload_file_props.hidden = true; 479 this.upload_file_props.hidden = true;
482 this.upload_tags.value=''; 480 this.upload_tags.value='';
483 this.upload_tags.disabled = true; 481 this.upload_tags.disabled = true;
484 }, 482 },
485 selToProps: function() { 483 selToProps: function() {
486 if(!this.selection.count) { 484 if(!this.selection.count) {
487 this.disableProps(); 485 this.disableProps();
488 }else if(this.selection.count==1) { 486 }else if(this.selection.count==1) {
489 var f=this.files[this.selection.currentIndex]; 487 var f=this.files[this.selection.currentIndex];
490 if(f==null || f.state!='pending') { 488 if(f==null || f.state!='pending') {
491 this.disableProps(); 489 this.disableProps();
492 }else{ 490 }else{
493 this.upload_filename.value = f.file; 491 this.upload_filename.value = f.file;
494 this.upload_filename.disabled = false; 492 this.upload_filename.disabled = false;
495 this.upload_title.value = f.title; 493 this.upload_title.value = f.title;
496 this.upload_title.disabled = false; 494 this.upload_title.disabled = false;
497 this.upload_file_preview.src = 'file:///'+f.file; 495 this.upload_file_preview.src = 'file:///'+f.file;
498 this.upload_file_props.hidden = false; 496 this.upload_file_props.hidden = false;
499 this.upload_tags.value = f.tags; 497 this.upload_tags.value = f.tags;
500 this.upload_tags.disabled = false; 498 this.upload_tags.disabled = false;
501 } 499 }
502 }else{ 500 }else{
503 var ftitle = null; var onetitle = true; 501 var ftitle = null; var onetitle = true;
504 var ftags = null; var onetag = true; 502 var ftags = null; var onetag = true;
505 var fs = 0; 503 var fs = 0;
506 for(var ff in this.files) { 504 for(var ff in this.files) {
507 if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { 505 if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) {
508 ++fs; 506 ++fs;
509 if(ftitle==null) { 507 if(ftitle==null) {
510 ftitle = this.files[ff].title; 508 ftitle = this.files[ff].title;
511 }else if(ftitle!=this.files[ff].title) { 509 }else if(ftitle!=this.files[ff].title) {
512 onetitle = false; 510 onetitle = false;
513 } 511 }
514 if(ftags==null) { 512 if(ftags==null) {
515 ftags = this.files[ff].tags; 513 ftags = this.files[ff].tags;
516 }else if(ftags!=this.files[ff].tags) { 514 }else if(ftags!=this.files[ff].tags) {
517 onetag = false; 515 onetag = false;
518 } 516 }
519 } 517 }
520 } 518 }
521 if(fs) { 519 if(fs) {
522 this.upload_filename.value=''; 520 this.upload_filename.value='';
523 this.upload_filename.disabled = true; 521 this.upload_filename.disabled = true;
524 if(onetitle) 522 if(onetitle)
525 this.upload_title.value = ftitle; 523 this.upload_title.value = ftitle;
526 this.upload_title.disabled = false; 524 this.upload_title.disabled = false;
527 if(onetag) 525 if(onetag)
528 this.upload_tags.value = ftags; 526 this.upload_tags.value = ftags;
529 this.upload_tags.disabled = false; 527 this.upload_tags.disabled = false;
530 this.upload_file_preview.src = null; 528 this.upload_file_preview.src = null;
531 this.upload_file_props.hidden = false; 529 this.upload_file_props.hidden = false;
532 }else 530 }else
533 this.disableProps(); 531 this.disableProps();
534 } 532 }
535 }, 533 },
536 propsToSel: function(prop) { 534 propsToSel: function(prop) {
537 if(this.selection.count<=0) return; 535 if(this.selection.count<=0) return;
538 for(var ff in this.files) { 536 for(var ff in this.files) {
539 if(this.selection.isSelected(ff) && this.files[ff].state=='pending') { 537 if(this.selection.isSelected(ff) && this.files[ff].state=='pending') {
540 if(prop=='filename') 538 if(prop=='filename')
541 this.files[ff].file = this.upload_filename.value; 539 this.files[ff].file = this.upload_filename.value;
542 if(prop=='title') 540 if(prop=='title')
543 this.files[ff].title = this.upload_title.value; 541 this.files[ff].title = this.upload_title.value;
544 if(prop=='tags') 542 if(prop=='tags')
545 this.files[ff].tags = this.upload_tags.value; 543 this.files[ff].tags = this.upload_tags.value;
546 this.tree.invalidateRow(ff); 544 this.tree.invalidateRow(ff);
547 } 545 }
548 } 546 }
549 }, 547 },
550 548
551 on_upload: function() { 549 on_upload: function() {
552 this.selToProps(); 550 this.selToProps();
553 this.batch_ids = new Array(); 551 this.batch_ids = new Array();
554 this.upload_progress.value=0; 552 this.upload_progress.value=0;
555 this.upload_progress.setAttribute('hidden','false'); 553 this.upload_progress.setAttribute('hidden','false');
556 this.upload_worker(); 554 this.upload_worker();
557 }, 555 },
558 on_clear: function() { 556 on_clear: function() {
559 this.clear_list(); 557 this.clear_list();
560 }, 558 },
561 on_remove: function() { 559 on_remove: function() {
562 if(this.selection.count) { 560 if(this.selection.count) {
563 this.tree.beginUpdateBatch(); 561 this.tree.beginUpdateBatch();
564 for(var i=this.files.length-1;i>=0;--i) { 562 for(var i=this.files.length-1;i>=0;--i) {
565 if(this.selection.isSelected(i)) { 563 if(this.selection.isSelected(i)) {
566 this.files.splice(i,1); 564 this.files.splice(i,1);
567 this.rowCount--; 565 this.rowCount--;
568 } 566 }
569 } 567 }
570 this.tree.endUpdateBatch(); 568 this.tree.endUpdateBatch();
571 this.selection.clearSelection(); 569 this.selection.clearSelection();
572 } 570 }
573 }, 571 },
574 on_add: function() { 572 on_add: function() {
575 var ifp = Components.interfaces.nsIFilePicker; 573 var ifp = Components.interfaces.nsIFilePicker;
576 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp); 574 var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp);
577 fp.init(window, "Select a File", ifp.modeOpenMultiple); 575 fp.init(window, "Select a File", ifp.modeOpenMultiple);
578 fp.appendFilters(ifp.filterImages); 576 fp.appendFilters(ifp.filterImages);
579 var rv = fp.show(); 577 var rv = fp.show();
580 if(rv==ifp.returnOK) { 578 if(rv==ifp.returnOK) {
581 var ff = fp.files; 579 var ff = fp.files;
582 while(ff.hasMoreElements()) { 580 while(ff.hasMoreElements()) {
583 var f = ff.getNext(); 581 var f = ff.getNext();
584 f.QueryInterface(Components.interfaces.nsIFile); 582 f.QueryInterface(Components.interfaces.nsIFile);
585 this.add(f.path); 583 this.add(f.path);
586 } 584 }
587 } 585 }
588 } 586 }
589 }, 587 },
590 588
591 on_set_props: function() { 589 on_set_props: function() {
592 var pset = this.photosets.sets[this.photosets.selection.currentIndex]; 590 var pset = this.photosets.sets[this.photosets.selection.currentIndex];
593 window.openDialog( 591 window.openDialog(
594 "chrome://fireflix/content/photoset-props.xul", 592 "chrome://fireflix/content/photoset-props.xul",
595 null, "dependent,modal,dialog,chrome", this, 593 null, "dependent,modal,dialog,chrome", this,
596 pset ); 594 pset );
597 if(pset.dirty) { 595 if(pset.dirty) {
598 var _this = this; 596 var _this = this;
599 this.flickr.api_call( 597 this.flickr.api_call(
600 { 598 {
601 method: 'flickr.photosets.editMeta', 599 method: 'flickr.photosets.editMeta',
602 auth_token: 'default', 600 auth_token: 'default',
603 photoset_id: pset.id, 601 photoset_id: pset.id,
604 title: pset.title, 602 title: pset.title,
605 description: pset.description 603 description: pset.description
606 }, function(xr) { 604 }, function(xr) {
607 pset.dirty = false; 605 pset.dirty = false;
608 _this.flickr.api_call( 606 _this.flickr.api_call(
609 { 607 {
610 method: 'flickr.photosets.getPhotos', 608 method: 'flickr.photosets.getPhotos',
611 auth_token: 'default', 609 auth_token: 'default',
612 photoset_id: pset.id 610 photoset_id: pset.id
613 }, function(xr) { 611 }, function(xr) {
614 var x = xr.responseXML; 612 var x = xr.responseXML;
615 var xp = x.evaluate( 613 var xp = x.evaluate(
616 '/rsp/photoset/photo', x, null, 614 '/rsp/photoset/photo', x, null,
617 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); 615 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
618 var phids = new Array(); 616 var phids = new Array();
619 var priph = null; 617 var priph = null;
620 var n; while(n=xp.iterateNext()) { 618 var n; while(n=xp.iterateNext()) {
621 var pid = n.getAttribute('id'); 619 var pid = n.getAttribute('id');
622 phids.push( pid ); 620 phids.push( pid );
623 if(pid==pset.primary && n.getAttribute('isprimary')!='1') 621 if(pid==pset.primary && n.getAttribute('isprimary')!='1')
624 priph = pid; 622 priph = pid;
625 } 623 }
626 if(priph) { 624 if(priph) {
627 _this.flickr.api_call( 625 _this.flickr.api_call(
628 { 626 {
629 method: 'flickr.photosets.editPhotos', 627 method: 'flickr.photosets.editPhotos',
630 auth_token: 'default', 628 auth_token: 'default',
631 photoset_id: pset.id, 629 photoset_id: pset.id,
632 primary_photo_id: priph, 630 primary_photo_id: priph,
633 photo_ids: phids.join(',') 631 photo_ids: phids.join(',')
634 }, function() { }, function(x,s,c,m) { /* flickr.photosets.editPhotos */ 632 }, function() { }, function(x,s,c,m) { /* flickr.photosets.editPhotos */
635 _this.flickr_failure(x,s,c,m); 633 _this.flickr_failure(x,s,c,m);
636 } 634 }
637 ); 635 );
638 } 636 }
639 }, function(x,s,c,m) { /* flickr.photosets.getPhotos */ 637 }, function(x,s,c,m) { /* flickr.photosets.getPhotos */
640 _this.flickr_failure(x,s,c,m); 638 _this.flickr_failure(x,s,c,m);
641 } 639 }
642 ); 640 );
643 }, function(x,s,c,m) { /* flickr.photosets.editMeta */ 641 }, function(x,s,c,m) { /* flickr.photosets.editMeta */
644 _this.flickr_failure(x,s,c,m); 642 _this.flickr_failure(x,s,c,m);
645 } 643 }
646 ); 644 );
647 } 645 }
648 }, 646 },
649 on_refresh_sets: function() { 647 on_refresh_sets: function() {
650 this.refresh_sets(); 648 this.refresh_sets();
651 }, 649 },
652 on_cmd_sets_html: function(csfx,ev) { 650 on_cmd_sets_html: function(csfx,ev) {
653 var uti = csfx.charAt(0); var utl = csfx.charAt(1); 651 var uti = csfx.charAt(0); var utl = csfx.charAt(1);
654 var rv = this.build_html(this.photoset.photos,uti,utl); 652 var rv = this.build_html(this.photoset.photos,uti,utl);
655 this.popup_content(rv); 653 this.popup_content(rv);
656 }, 654 },
657 655
658 on_cmd_uploads_html: function(csfx,ev) { 656 on_cmd_uploads_html: function(csfx,ev) {
659 var uti = csfx.charAt(0); var utl = csfx.charAt(1); 657 var uti = csfx.charAt(0); var utl = csfx.charAt(1);
660 var pids = new Array(); 658 var pids = new Array();
661 for(var f in this.uploads.files) { 659 for(var f in this.uploads.files) {
662 if(this.uploads.selection.isSelected(f)) 660 if(this.uploads.selection.isSelected(f))
663 if(this.uploads.files[f].photoid) 661 if(this.uploads.files[f].photoid)
664 pids.push(this.uploads.files[f].photoid); 662 pids.push(this.uploads.files[f].photoid);
665 } 663 }
666 var pp = this.uploads.rowCount*2; if(pp>500) pp = 500; 664 var pp = this.uploads.rowCount*2; if(pp>500) pp = 500;
667 var _this = this; 665 var _this = this;
668 this.flickr.api_call( 666 this.flickr.api_call(
669 { 667 {
670 method: 'flickr.photos.search', 668 method: 'flickr.photos.search',
671 auth_token: 'default', 669 auth_token: 'default',
672 extras: 'original_format', 670 extras: 'original_format',
673 user_id: 'me', 671 user_id: 'me',
674 per_page: pp 672 per_page: pp
675 }, 673 },
676 function(xr) { 674 function(xr) {
677 var x = xr.responseXML; 675 var x = xr.responseXML;
678 var rv = ''; 676 var rv = '';
679 for(var pn in pids) { 677 for(var pn in pids) {
680 var p = pids[pn]; 678 var p = pids[pn];
681 var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x)); 679 var pp = new Photo(xp_node('/rsp/photos/photo[@id='+p+']',x));
682 rv += _this.photo_html(pp,uti,utl)+'\n'; 680 rv += _this.photo_html(pp,uti,utl)+'\n';
683 } 681 }
684 _this.popup_content(rv); 682 _this.popup_content(rv);
685 }, function(x,s,c,m) { 683 }, function(x,s,c,m) {
686 _this.flickr_failure(x,s,c,m); 684 _this.flickr_failure(x,s,c,m);
687 } 685 }
688 ); 686 );
689 }, 687 },
690 688
691 /* 689 /*
692 * 690 *
693 */ 691 */
694 foundphotos: { 692 foundphotos: {
695 fireflix: null, 693 fireflix: null,
696 init: function(f) { 694 init: function(f) {
697 this.fireflix = f; 695 this.fireflix = f;
698 pull_elements(this,document,[ 696 pull_elements(this,document,[
699 'search_for','search_tags','search_mine', 697 'search_for','search_tags','search_mine',
700 'searchresult_props','search_photo', 698 'searchresult_props','search_photo',
701 'searchresult_title','searchresult_description', 699 'searchresult_title','searchresult_description',
702 'search_page','cmd_search_prev_page','cmd_search_next_page' 700 'search_page','cmd_search_prev_page','cmd_search_next_page'
703 ]); 701 ]);
704 document.getElementById('searchresults').view = this; 702 document.getElementById('searchresults').view = this;
705 }, 703 },
706 photos: new Array(), 704 photos: new Array(),
707 rowCount: 0, 705 rowCount: 0,
708 getCellText: function(r,c) { 706 getCellText: function(r,c) {
709 var p = this.photos[r]; 707 var p = this.photos[r];
710 if(c.id=='sr_title') return p.title; 708 if(c.id=='sr_title') return p.title;
711 return c.id; 709 return c.id;
712 }, 710 },
713 setTree: function(t) { this.tree = t }, 711 setTree: function(t) { this.tree = t },
714 isContainer: function(r) { return false }, 712 isContainer: function(r) { return false },
715 isSeparator: function(r) { return false }, 713 isSeparator: function(r) { return false },
716 isSorted: function(r) { return false }, 714 isSorted: function(r) { return false },
717 getLevel: function(r) { return 0 }, 715 getLevel: function(r) { return 0 },
718 getImageSrc: function(r,c) { return null }, 716 getImageSrc: function(r,c) { return null },
719 getRowProperties: function(r,p) { }, 717 getRowProperties: function(r,p) { },
720 getCellProperties: function(cid,cel,p) { }, 718 getCellProperties: function(cid,cel,p) { },
721 getColumnProperties: function(cid,cel,p) { }, 719 getColumnProperties: function(cid,cel,p) { },
722 cycleHeader: function(cid,e) { }, 720 cycleHeader: function(cid,e) { },
723 getParentIndex: function(r) { return -1 }, 721 getParentIndex: function(r) { return -1 },
724 drop: function(r,o) { }, 722 drop: function(r,o) { },
725 canDropBeforeAfter: function(r,b) { return false }, 723 canDropBeforeAfter: function(r,b) { return false },
726 724
727 importXPR: function(xp) { 725 importXPR: function(xp) {
728 this.selection.clearSelection(); 726 this.selection.clearSelection();
729 this.selection.currentIndex = -1; 727 this.selection.currentIndex = -1;
730 this.searchresult_props.hidden = true; 728 this.searchresult_props.hidden = true;
731 this.tree.beginUpdateBatch(); 729 this.tree.beginUpdateBatch();
732 this.photos = new Array(); 730 this.photos = new Array();
733 var n; while(n=xp.iterateNext()) { 731 var n; while(n=xp.iterateNext()) {
734 this.photos.push(new Photo(n)); 732 this.photos.push(new Photo(n));
735 } 733 }
736 this.rowCount = this.photos.length; 734 this.rowCount = this.photos.length;
737 this.tree.endUpdateBatch(); 735 this.tree.endUpdateBatch();
738 }, 736 },
739 paging: { 737 paging: {
740 pars: null, 738 pars: null,
741 page: null, pages: null, perpage: null, total: null 739 page: null, pages: null, perpage: null, total: null
742 }, 740 },
743 search_photos: function() { 741 search_photos: function() {
744 var pars = { 742 var pars = {
745 method: 'flickr.photos.search', 743 method: 'flickr.photos.search',
746 auth_token: 'default', 744 auth_token: 'default',
747 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo' 745 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo'
748 }; 746 };
749 if(this.search_mine.checked) 747 if(this.search_mine.checked)
750 pars.user_id='me'; 748 pars.user_id='me';
751 if(this.search_tags.checked) { 749 if(this.search_tags.checked) {
752 pars.tags=this.search_for.value.split(/ +/).join(','); 750 pars.tags=this.search_for.value.split(/ +/).join(',');
753 }else{ 751 }else{
754 pars.text=this.search_for.value; 752 pars.text=this.search_for.value;
755 } 753 }
756 this.paging.pars = new Object(); 754 this.paging.pars = new Object();
757 this.paging.page = null; this.paging.pages = null; 755 this.paging.page = null; this.paging.pages = null;
758 this.paging.perpage = null; this.paging.total = null; 756 this.paging.perpage = null; this.paging.total = null;
759 for(var p in pars) this.paging.pars[p] = pars[p]; 757 for(var p in pars) this.paging.pars[p] = pars[p];
760 this.perform_search(pars); 758 this.perform_search(pars);
761 }, 759 },
762 perform_search: function(p) { 760 perform_search: function(p) {
763 var _this = this; 761 var _this = this;
764 this.fireflix.flickr.api_call( p, 762 this.fireflix.flickr.api_call( p,
765 function(xr) { 763 function(xr) {
766 var x = xr.responseXML; 764 var x = xr.responseXML;
767 var xp = xp_nodes('/rsp/photos/photo',x); 765 var xp = xp_nodes('/rsp/photos/photo',x);
768 _this.importXPR(xp); 766 _this.importXPR(xp);
769 _this.tree.ensureRowIsVisible(0); 767 _this.tree.ensureRowIsVisible(0);
770 xp = xp_node('/rsp/photos',x); 768 xp = xp_node('/rsp/photos',x);
771 _this.paging.page = parseInt(xp.getAttribute('page')); 769 _this.paging.page = parseInt(xp.getAttribute('page'));
772 _this.paging.pages = parseInt(xp.getAttribute('pages')); 770 _this.paging.pages = parseInt(xp.getAttribute('pages'));
773 _this.paging.perpage = parseInt(xp.getAttribute('perpage')); 771 _this.paging.perpage = parseInt(xp.getAttribute('perpage'));
774 _this.paging.total = parseInt(xp.getAttribute('total')); 772 _this.paging.total = parseInt(xp.getAttribute('total'));
775 _this.update_paging(); 773 _this.update_paging();
776 _this.on_select(); 774 _this.on_select();
777 }, function(x,s,c,m) { 775 }, function(x,s,c,m) {
778 _this.fireflix.flickr_failure(x,s,c,m); 776 _this.fireflix.flickr_failure(x,s,c,m);
779 } 777 }
780 ); 778 );
781 }, 779 },
782 on_cmd_prev: function(ev) { 780 on_cmd_prev: function(ev) {
783 var pars = new Object(); 781 var pars = new Object();
784 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 782 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; 783 pars.page=this.paging.page-1; pars.per_page=this.paging.perpage;
786 this.perform_search(pars); 784 this.perform_search(pars);
787 }, 785 },
788 on_cmd_next: function(ev) { 786 on_cmd_next: function(ev) {
789 var pars = new Object(); 787 var pars = new Object();
790 for(var p in this.paging.pars) pars[p] = this.paging.pars[p]; 788 for(var p in this.paging.pars) pars[p] = this.paging.pars[p];
791 pars.page=this.paging.page+1; pars.per_page=this.paging.perpage; 789 pars.page=this.paging.page+1; pars.per_page=this.paging.perpage;
792 this.perform_search(pars); 790 this.perform_search(pars);
793 }, 791 },