summaryrefslogtreecommitdiffabout
path: root/content
Unidiff
Diffstat (limited to 'content') (more/less context) (show whitespace changes)
-rw-r--r--content/fireflix.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/content/fireflix.js b/content/fireflix.js
index d70ab4d..34cfd3e 100644
--- a/content/fireflix.js
+++ b/content/fireflix.js
@@ -140,208 +140,202 @@ var fireflix = {
140 auth_token: 'default', 140 auth_token: 'default',
141 photoset_id: psid, 141 photoset_id: psid,
142 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update' 142 extras: 'license,date_upload,date_taken,owner_name,icon_server,original_format,last_update'
143 }, function(x,j) { 143 }, function(x,j) {
144 that.import_json(j.photoset.photo); 144 that.import_json(j.photoset.photo);
145 }, function(x,s,c,m) { 145 }, function(x,s,c,m) {
146 that.fireflix.flickr_failure(x,s,c,m); 146 that.fireflix.flickr_failure(x,s,c,m);
147 } 147 }
148 ); 148 );
149 }, 149 },
150 on_select: function() { 150 on_select: function() {
151 if(this.selection.count==1) { 151 if(this.selection.count==1) {
152 var p = this.photos[this.selection.currentIndex]; 152 var p = this.photos[this.selection.currentIndex];
153 this.set_photo.src = 153 this.set_photo.src =
154 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t'); 154 this.fireflix.flickr.get_photo_url(p.server,p.id,p.secret,'t');
155 this.set_photo_props.hidden = false; 155 this.set_photo_props.hidden = false;
156 }else{ 156 }else{
157 this.set_photo_props.hidden = true; 157 this.set_photo_props.hidden = true;
158 } 158 }
159 }, 159 },
160 on_cmd_open: function(ev) { 160 on_cmd_open: function(ev) {
161 if(this.selection.currentIndex<0) return; 161 if(this.selection.currentIndex<0) return;
162 var p = this.photos[this.selection.currentIndex]; 162 var p = this.photos[this.selection.currentIndex];
163 if(!p.id) return; 163 if(!p.id) return;
164 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p')); 164 this.fireflix.openTab(this.fireflix.flickr.make_photo_url(p,'p'));
165 } 165 }
166 }, 166 },
167 167
168 /* photosets treeview */ 168 /* photosets treeview */
169 photosets: { 169 photosets: {
170 sets: new Array(), 170 sets: new Array(),
171 fireflix: null, 171 fireflix: null,
172 init: function(f) { 172 init: function(f) {
173 this.fireflix = f; 173 this.fireflix = f;
174 document.getElementById('setslist').view = this; 174 document.getElementById('setslist').view = this;
175 }, 175 },
176 rowCount: 0, 176 rowCount: 0,
177 getCellText: function(r,c) { 177 getCellText: function(r,c) {
178 var s = this.sets[r]; 178 var s = this.sets[r];
179 if(c.id=='sl_name') return s.title; 179 if(c.id=='sl_name') return s.title;
180 if(c.id=='sl_photos') return s.photos; 180 if(c.id=='sl_photos') return s.photos;
181 return c.id; 181 return c.id;
182 }, 182 },
183 setTree: function(t) { this.tree = t }, 183 setTree: function(t) { this.tree = t },
184 isContainer: function(r) { return false; }, 184 isContainer: function(r) { return false; },
185 isSeparator: function(r) { return false; }, 185 isSeparator: function(r) { return false; },
186 isSorted: function() { return false; }, 186 isSorted: function() { return false; },
187 getLevel: function(r) { return 0; }, 187 getLevel: function(r) { return 0; },
188 getImageSrc: function(r,c) { return null }, 188 getImageSrc: function(r,c) { return null },
189 getRowProperties: function(r,p) {}, 189 getRowProperties: function(r,p) {},
190 getCellProperties: function(cid,cel,p) { }, 190 getCellProperties: function(cid,cel,p) { },
191 getColumnProperties: function(cid,cel,p) { }, 191 getColumnProperties: function(cid,cel,p) { },
192 cycleHeader: function(cid,e) { }, 192 cycleHeader: function(cid,e) { },
193 getParentIndex: function(r) { return -1; }, 193 getParentIndex: function(r) { return -1; },
194 drop: function(r,o) { }, 194 drop: function(r,o) { },
195 canDropBeforeAfter: function(r,b) { return false }, 195 canDropBeforeAfter: function(r,b) { return false },
196 196
197 import_json: function(j) { 197 import_json: function(j) {
198 this.tree.beginUpdateBatch(); 198 this.tree.beginUpdateBatch();
199 this.sets = new Array(); 199 this.sets = new Array();
200 for(var i in j) this.sets.push(new Photoset(j[i])); 200 for(var i in j) this.sets.push(new Photoset(j[i]));
201 this.rowCount = this.sets.length; 201 this.rowCount = this.sets.length;
202 this.tree.endUpdateBatch(); 202 this.tree.endUpdateBatch();
203 }, 203 },
204 refresh_sets: function() { 204 refresh_sets: function() {
205 var that = this; 205 var that = this;
206 this.fireflix.flickr.api_call_json( 206 this.fireflix.flickr.api_call_json(
207 { 207 {
208 method: 'flickr.photosets.getList', 208 method: 'flickr.photosets.getList',
209 auth_token: 'default' 209 auth_token: 'default'
210 }, function(x,j) { 210 }, function(x,j) {
211 that.import_json(j.photosets.photoset); 211 that.import_json(j.photosets.photoset);
212 }, function(x,s,c,m) { 212 }, function(x,s,c,m) {
213 that.fireflix.flickr_failure(x,s,c,m); 213 that.fireflix.flickr_failure(x,s,c,m);
214 } 214 }
215 ); 215 );
216 }, 216 },
217 on_select: function() { 217 on_select: function() {
218 if(this.selection.count==1) { 218 if(this.selection.count==1) {
219 this.fireflix.cmd_set_props.setAttribute('disabled','false'); 219 this.fireflix.cmd_set_props.setAttribute('disabled','false');
220 var s = this.sets[this.selection.currentIndex]; 220 var s = this.sets[this.selection.currentIndex];
221 this.fireflix.photoset.load_photos(s.id); 221 this.fireflix.photoset.load_photos(s.id);
222 }else{ 222 }else{
223 this.fireflix.cmd_set_props.setAttribute('disabled','true'); 223 this.fireflix.cmd_set_props.setAttribute('disabled','true');
224 } 224 }
225 }, 225 },
226 on_cmd_open_in_flickr: function(ev) { 226 on_cmd_open_in_flickr: function(ev) {
227 if(this.selection.currentIndex<0) return; 227 if(this.selection.currentIndex<0) return;
228 var p = this.sets[this.selection.currentIndex]; 228 var p = this.sets[this.selection.currentIndex];
229 if(!p.id) return; 229 if(!p.id) return;
230 this.fireflix.openTab(this.fireflix.flickr.make_photoset_url(p)); 230 this.fireflix.openTab(this.fireflix.flickr.make_photoset_url(p));
231 } 231 }
232 }, 232 },
233 233
234 refresh_user_tags: function() { 234 refresh_user_tags: function() {
235 var lb = document.getElementById('tagslist'); 235 var lb = document.getElementById('tagslist');
236 var _this = this; 236 var that = this;
237 this.flickr.api_call( 237 this.flickr.api_call_json(
238 { 238 {
239 method: 'flickr.tags.getListUser', 239 method: 'flickr.tags.getListUser',
240 auth_token: 'default', 240 auth_token: 'default',
241 }, function(xr) { 241 }, function(x,j) {
242 var x = xr.responseXML; 242 var tt = j.who.tags.tag;
243 var xp = x.evaluate( 243 for(var i in tt) lb.appendItem(tt[i]._content);
244 '/rsp/who/tags/tag', x, null,
245 XPathResult.ORDERED_NODE_ITERATOR_TYPE, null );
246 // TODO: clear list
247 var n; while(n=xp.iterateNext()) {
248 lb.appendItem(n.firstChild.nodeValue);
249 }
250 }, function(x,s,c,m) { 244 }, function(x,s,c,m) {
251 _this.flickr_failure(x,s,c,m); 245 that.flickr_failure(x,s,c,m);
252 } 246 }
253 ); 247 );
254 }, 248 },
255 249
256 uploadObserver: { 250 uploadObserver: {
257 fireflix: null, 251 fireflix: null,
258 init: function(f) { 252 init: function(f) {
259 this.fireflix = f; 253 this.fireflix = f;
260 }, 254 },
261 getSupportedFlavours: function() { 255 getSupportedFlavours: function() {
262 var rv = new FlavourSet(); 256 var rv = new FlavourSet();
263 rv.appendFlavour('application/x-moz-file','nsIFile'); 257 rv.appendFlavour('application/x-moz-file','nsIFile');
264 rv.appendFlavour('application/x-moz-url'); 258 rv.appendFlavour('application/x-moz-url');
265 rv.appendFlavour('text/uri-list'); 259 rv.appendFlavour('text/uri-list');
266 rv.appendFlavour('text/unicode'); 260 rv.appendFlavour('text/unicode');
267 return rv; 261 return rv;
268 }, 262 },
269 canHandleMultipleItems: true, 263 canHandleMultipleItems: true,
270 onDragOver: function(ev,fl,sess) { 264 onDragOver: function(ev,fl,sess) {
271 return true; 265 return true;
272 }, 266 },
273 onDrop: function(ev,dd,s) { 267 onDrop: function(ev,dd,s) {
274 var ldf = null; 268 var ldf = null;
275 for(var i in dd.dataList) { 269 for(var i in dd.dataList) {
276 var di = dd.dataList[i]; 270 var di = dd.dataList[i];
277 var dif = di.first; 271 var dif = di.first;
278 if( 272 if(
279 ldf==null 273 ldf==null
280 || ldf.flavour.contentType!=dif.flavour.contentType 274 || ldf.flavour.contentType!=dif.flavour.contentType
281 || ldf.contentLength!=dif.contentLength 275 || ldf.contentLength!=dif.contentLength
282 || ldf.data!=dif.data ) 276 || ldf.data!=dif.data )
283 this.drop_item(ev,di,s); 277 this.drop_item(ev,di,s);
284 ldf = dif; 278 ldf = dif;
285 } 279 }
286 }, 280 },
287 drop_item: function(ev,di,s) { 281 drop_item: function(ev,di,s) {
288 var d = di.first; 282 var d = di.first;
289 switch(d.flavour.contentType) { 283 switch(d.flavour.contentType) {
290 case 'text/unicode': 284 case 'text/unicode':
291 this.drop_urilist(ev,d.data,s); 285 this.drop_urilist(ev,d.data,s);
292 break; 286 break;
293 case 'application/x-moz-file': 287 case 'application/x-moz-file':
294 this.fireflix.uploads.add(d.data.path); 288 this.fireflix.uploads.add(d.data.path);
295 document.getElementById('fireflix_tabs').selectedTab 289 document.getElementById('fireflix_tabs').selectedTab
296 = document.getElementById('tab_upload'); 290 = document.getElementById('tab_upload');
297 break; 291 break;
298 case 'text/uri-list': 292 case 'text/uri-list':
299 // is it ascii or could it be utf8? 293 // is it ascii or could it be utf8?
300 this.drop_urilist(ev,splitascii(d.data),s); 294 this.drop_urilist(ev,splitascii(d.data),s);
301 break; 295 break;
302 default: alert(d.flavour.contentType+':'+d.data); break; 296 default: alert(d.flavour.contentType+':'+d.data); break;
303 }; 297 };
304 }, 298 },
305 drop_urilist: function(ev,ul,s) { 299 drop_urilist: function(ev,ul,s) {
306 // TODO: check for being a file? 300 // TODO: check for being a file?
307 var us = decodeURIComponent(ul).split(/[\r\n]/); 301 var us = decodeURIComponent(ul).split(/[\r\n]/);
308 for(var ui in us) 302 for(var ui in us)
309 if(/\S/.test(us[ui])) 303 if(/\S/.test(us[ui]))
310 this.fireflix.uploads.add(us[ui]); 304 this.fireflix.uploads.add(us[ui]);
311 document.getElementById('fireflix_tabs').selectedTab 305 document.getElementById('fireflix_tabs').selectedTab
312 = document.getElementById('tab_upload'); 306 = document.getElementById('tab_upload');
313 } 307 }
314 }, 308 },
315 309
316 uploads: { 310 uploads: {
317 fireflix: null, 311 fireflix: null,
318 init: function(f) { 312 init: function(f) {
319 this.fireflix=f; 313 this.fireflix=f;
320 pull_elements(this,document,[ 314 pull_elements(this,document,[
321 'upload_filename','upload_title','upload_file_preview', 315 'upload_filename','upload_title','upload_file_preview',
322 'upload_file_props','upload_progress','upload_tags', 316 'upload_file_props','upload_progress','upload_tags',
323 'cmd_uploads_upload', 'upload_failure', 'upload_is_public', 317 'cmd_uploads_upload', 'upload_failure', 'upload_is_public',
324 'upload_is_friends', 'upload_is_family' 318 'upload_is_friends', 'upload_is_family'
325 ]); 319 ]);
326 document.getElementById('uploadlist').view = this; 320 document.getElementById('uploadlist').view = this;
327 this.upload_is_public.addEventListener( 321 this.upload_is_public.addEventListener(
328 'CheckboxStateChange', { that: this, 322 'CheckboxStateChange', { that: this,
329 handleEvent: function(ev) { this.that.propsToSel('is_public'); } 323 handleEvent: function(ev) { this.that.propsToSel('is_public'); }
330 }, false ); 324 }, false );
331 this.upload_is_friends.addEventListener( 325 this.upload_is_friends.addEventListener(
332 'CheckboxStateChange', { that: this, 326 'CheckboxStateChange', { that: this,
333 handleEvent: function(ev) { this.that.propsToSel('is_friends'); } 327 handleEvent: function(ev) { this.that.propsToSel('is_friends'); }
334 }, false ); 328 }, false );
335 this.upload_is_family.addEventListener( 329 this.upload_is_family.addEventListener(
336 'CheckboxStateChange', { that: this, 330 'CheckboxStateChange', { that: this,
337 handleEvent: function(ev) { this.that.propsToSel('is_family'); } 331 handleEvent: function(ev) { this.that.propsToSel('is_family'); }
338 }, false ); 332 }, false );
339 }, 333 },
340 files: new Array(), 334 files: new Array(),
341 rowCount: 0, 335 rowCount: 0,
342 getCellText: function(r,c) { 336 getCellText: function(r,c) {
343 var f = this.files[r]; 337 var f = this.files[r];
344 if(c.id=='up_file') return f.file; 338 if(c.id=='up_file') return f.file;
345 if(c.id=='up_title') return f.title; 339 if(c.id=='up_title') return f.title;
346 if(c.id=='up_status') return f.state; 340 if(c.id=='up_status') return f.state;
347 return c.id; 341 return c.id;