-rw-r--r-- | content/fireflix.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/content/fireflix.js b/content/fireflix.js index 283e930..d70ab4d 100644 --- a/content/fireflix.js +++ b/content/fireflix.js | |||
@@ -256,409 +256,408 @@ var fireflix = { | |||
256 | uploadObserver: { | 256 | uploadObserver: { |
257 | fireflix: null, | 257 | fireflix: null, |
258 | init: function(f) { | 258 | init: function(f) { |
259 | this.fireflix = f; | 259 | this.fireflix = f; |
260 | }, | 260 | }, |
261 | getSupportedFlavours: function() { | 261 | getSupportedFlavours: function() { |
262 | var rv = new FlavourSet(); | 262 | var rv = new FlavourSet(); |
263 | rv.appendFlavour('application/x-moz-file','nsIFile'); | 263 | rv.appendFlavour('application/x-moz-file','nsIFile'); |
264 | rv.appendFlavour('application/x-moz-url'); | 264 | rv.appendFlavour('application/x-moz-url'); |
265 | rv.appendFlavour('text/uri-list'); | 265 | rv.appendFlavour('text/uri-list'); |
266 | rv.appendFlavour('text/unicode'); | 266 | rv.appendFlavour('text/unicode'); |
267 | return rv; | 267 | return rv; |
268 | }, | 268 | }, |
269 | canHandleMultipleItems: true, | 269 | canHandleMultipleItems: true, |
270 | onDragOver: function(ev,fl,sess) { | 270 | onDragOver: function(ev,fl,sess) { |
271 | return true; | 271 | return true; |
272 | }, | 272 | }, |
273 | onDrop: function(ev,dd,s) { | 273 | onDrop: function(ev,dd,s) { |
274 | var ldf = null; | 274 | var ldf = null; |
275 | for(var i in dd.dataList) { | 275 | for(var i in dd.dataList) { |
276 | var di = dd.dataList[i]; | 276 | var di = dd.dataList[i]; |
277 | var dif = di.first; | 277 | var dif = di.first; |
278 | if( | 278 | if( |
279 | ldf==null | 279 | ldf==null |
280 | || ldf.flavour.contentType!=dif.flavour.contentType | 280 | || ldf.flavour.contentType!=dif.flavour.contentType |
281 | || ldf.contentLength!=dif.contentLength | 281 | || ldf.contentLength!=dif.contentLength |
282 | || ldf.data!=dif.data ) | 282 | || ldf.data!=dif.data ) |
283 | this.drop_item(ev,di,s); | 283 | this.drop_item(ev,di,s); |
284 | ldf = dif; | 284 | ldf = dif; |
285 | } | 285 | } |
286 | }, | 286 | }, |
287 | drop_item: function(ev,di,s) { | 287 | drop_item: function(ev,di,s) { |
288 | var d = di.first; | 288 | var d = di.first; |
289 | switch(d.flavour.contentType) { | 289 | switch(d.flavour.contentType) { |
290 | case 'text/unicode': | 290 | case 'text/unicode': |
291 | this.drop_urilist(ev,d.data,s); | 291 | this.drop_urilist(ev,d.data,s); |
292 | break; | 292 | break; |
293 | case 'application/x-moz-file': | 293 | case 'application/x-moz-file': |
294 | this.fireflix.uploads.add(d.data.path); | 294 | this.fireflix.uploads.add(d.data.path); |
295 | document.getElementById('fireflix_tabs').selectedTab | 295 | document.getElementById('fireflix_tabs').selectedTab |
296 | = document.getElementById('tab_upload'); | 296 | = document.getElementById('tab_upload'); |
297 | break; | 297 | break; |
298 | case 'text/uri-list': | 298 | case 'text/uri-list': |
299 | // is it ascii or could it be utf8? | 299 | // is it ascii or could it be utf8? |
300 | this.drop_urilist(ev,splitascii(d.data),s); | 300 | this.drop_urilist(ev,splitascii(d.data),s); |
301 | break; | 301 | break; |
302 | default: alert(d.flavour.contentType+':'+d.data); break; | 302 | default: alert(d.flavour.contentType+':'+d.data); break; |
303 | }; | 303 | }; |
304 | }, | 304 | }, |
305 | drop_urilist: function(ev,ul,s) { | 305 | drop_urilist: function(ev,ul,s) { |
306 | // TODO: check for being a file? | 306 | // TODO: check for being a file? |
307 | var us = decodeURIComponent(ul).split(/[\r\n]/); | 307 | var us = decodeURIComponent(ul).split(/[\r\n]/); |
308 | for(var ui in us) | 308 | for(var ui in us) |
309 | if(/\S/.test(us[ui])) | 309 | if(/\S/.test(us[ui])) |
310 | this.fireflix.uploads.add(us[ui]); | 310 | this.fireflix.uploads.add(us[ui]); |
311 | document.getElementById('fireflix_tabs').selectedTab | 311 | document.getElementById('fireflix_tabs').selectedTab |
312 | = document.getElementById('tab_upload'); | 312 | = document.getElementById('tab_upload'); |
313 | } | 313 | } |
314 | }, | 314 | }, |
315 | 315 | ||
316 | uploads: { | 316 | uploads: { |
317 | fireflix: null, | 317 | fireflix: null, |
318 | init: function(f) { | 318 | init: function(f) { |
319 | this.fireflix=f; | 319 | this.fireflix=f; |
320 | pull_elements(this,document,[ | 320 | pull_elements(this,document,[ |
321 | 'upload_filename','upload_title','upload_file_preview', | 321 | 'upload_filename','upload_title','upload_file_preview', |
322 | 'upload_file_props','upload_progress','upload_tags', | 322 | 'upload_file_props','upload_progress','upload_tags', |
323 | 'cmd_uploads_upload', 'upload_failure', 'upload_is_public', | 323 | 'cmd_uploads_upload', 'upload_failure', 'upload_is_public', |
324 | 'upload_is_friends', 'upload_is_family' | 324 | 'upload_is_friends', 'upload_is_family' |
325 | ]); | 325 | ]); |
326 | document.getElementById('uploadlist').view = this; | 326 | document.getElementById('uploadlist').view = this; |
327 | this.upload_is_public.addEventListener( | 327 | this.upload_is_public.addEventListener( |
328 | 'CheckboxStateChange', { that: this, | 328 | 'CheckboxStateChange', { that: this, |
329 | handleEvent: function(ev) { this.that.propsToSel('is_public'); } | 329 | handleEvent: function(ev) { this.that.propsToSel('is_public'); } |
330 | }, false ); | 330 | }, false ); |
331 | this.upload_is_friends.addEventListener( | 331 | this.upload_is_friends.addEventListener( |
332 | 'CheckboxStateChange', { that: this, | 332 | 'CheckboxStateChange', { that: this, |
333 | handleEvent: function(ev) { this.that.propsToSel('is_friends'); } | 333 | handleEvent: function(ev) { this.that.propsToSel('is_friends'); } |
334 | }, false ); | 334 | }, false ); |
335 | this.upload_is_family.addEventListener( | 335 | this.upload_is_family.addEventListener( |
336 | 'CheckboxStateChange', { that: this, | 336 | 'CheckboxStateChange', { that: this, |
337 | handleEvent: function(ev) { this.that.propsToSel('is_family'); } | 337 | handleEvent: function(ev) { this.that.propsToSel('is_family'); } |
338 | }, false ); | 338 | }, false ); |
339 | }, | 339 | }, |
340 | files: new Array(), | 340 | files: new Array(), |
341 | rowCount: 0, | 341 | rowCount: 0, |
342 | getCellText: function(r,c) { | 342 | getCellText: function(r,c) { |
343 | var f = this.files[r]; | 343 | var f = this.files[r]; |
344 | if(c.id=='up_file') return f.file; | 344 | if(c.id=='up_file') return f.file; |
345 | if(c.id=='up_title') return f.title; | 345 | if(c.id=='up_title') return f.title; |
346 | if(c.id=='up_status') return f.state; | 346 | if(c.id=='up_status') return f.state; |
347 | return c.id; | 347 | return c.id; |
348 | }, | 348 | }, |
349 | setTree: function(t) { this.tree = t }, | 349 | setTree: function(t) { this.tree = t }, |
350 | isContainer: function(r) { return false; }, | 350 | isContainer: function(r) { return false; }, |
351 | isSeparator: function(r) { return false; }, | 351 | isSeparator: function(r) { return false; }, |
352 | isSorted: function(r) { return false; }, | 352 | isSorted: function(r) { return false; }, |
353 | getLevel: function(r) { return 0; }, | 353 | getLevel: function(r) { return 0; }, |
354 | getImageSrc: function(r,c) { return null }, | 354 | getImageSrc: function(r,c) { return null }, |
355 | getRowProperties: function(r,p) { | 355 | getRowProperties: function(r,p) { |
356 | try { | 356 | try { |
357 | if(!Components) return; | 357 | if(!Components) return; |
358 | }catch(e) { return } | 358 | }catch(e) { return } |
359 | var f = this.files[r]; | 359 | var f = this.files[r]; |
360 | var as = Components.classes['@mozilla.org/atom-service;1']. | 360 | var as = Components.classes['@mozilla.org/atom-service;1']. |
361 | getService(Components.interfaces.nsIAtomService); | 361 | getService(Components.interfaces.nsIAtomService); |
362 | p.AppendElement(as.getAtom(f.state)); | 362 | p.AppendElement(as.getAtom(f.state)); |
363 | }, | 363 | }, |
364 | getCellProperties: function(r,c,p) { this.getRowProperties(r,p); }, | 364 | getCellProperties: function(r,c,p) { this.getRowProperties(r,p); }, |
365 | getColumnProperties: function(c,p) { }, | 365 | getColumnProperties: function(c,p) { }, |
366 | cycleHeader: function(cid,e) { }, | 366 | cycleHeader: function(cid,e) { }, |
367 | getParentIndex: function(r) { return -1; }, | 367 | getParentIndex: function(r) { return -1; }, |
368 | drop: function(r,o) { }, | 368 | drop: function(r,o) { }, |
369 | canDropBeforeAfter: function(r,b) { return false }, | 369 | canDropBeforeAfter: function(r,b) { return false }, |
370 | 370 | ||
371 | add: function(f) { | 371 | add: function(f) { |
372 | if(f.indexOf('file:/')==0) { | 372 | if(f.indexOf('file:/')==0) { |
373 | f = f.substr(5); | 373 | f = f.substr(5); |
374 | while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-) | 374 | while(f.substr(0,2)=='//') { // XXX: not very performant, is it? ;-) |
375 | f = f.substr(1); | 375 | f = f.substr(1); |
376 | } | 376 | } |
377 | } | 377 | } |
378 | var t = f; | 378 | var t = f; |
379 | var ls = t.lastIndexOf('/'); | 379 | var ls = t.lastIndexOf('/'); |
380 | if(ls>0) t = t.substr(ls+1); | 380 | if(ls>0) t = t.substr(ls+1); |
381 | ls = t.lastIndexOf('\\'); | 381 | ls = t.lastIndexOf('\\'); |
382 | if(ls>0) t = t.substr(ls+1); | 382 | if(ls>0) t = t.substr(ls+1); |
383 | var ld = t.lastIndexOf('.'); | 383 | var ld = t.lastIndexOf('.'); |
384 | if(ld>0) t = t.substr(0,ld); | 384 | if(ld>0) t = t.substr(0,ld); |
385 | this.files.push( { | 385 | this.files.push( { |
386 | file: f, | 386 | file: f, |
387 | title: t, | 387 | title: t, |
388 | tags: '', | 388 | tags: '', |
389 | is_public: true, is_friend: false, is_family: false, | 389 | is_public: true, is_friend: false, is_family: false, |
390 | state: 'pending' | 390 | state: 'pending' |
391 | } ); | 391 | } ); |
392 | this.rowCount = this.files.length; | 392 | this.rowCount = this.files.length; |
393 | this.tree.rowCountChanged(this.rowCount-1,1); | 393 | this.tree.rowCountChanged(this.rowCount-1,1); |
394 | }, | 394 | }, |
395 | 395 | ||
396 | upload_worker: function() { | 396 | upload_worker: function() { |
397 | for(var f in this.files) { | 397 | for(var f in this.files) { |
398 | if(this.files[f].state=='pending') { | 398 | if(this.files[f].state=='pending') { |
399 | var ff = this.files[f]; | 399 | var ff = this.files[f]; |
400 | this.on_file_upload(ff); | 400 | this.on_file_upload(ff); |
401 | ff.state='uploading'; | 401 | ff.state='uploading'; |
402 | this.tree.invalidate(); | 402 | this.tree.invalidate(); |
403 | var _this = this; | 403 | var _this = this; |
404 | this.fireflix.flickr.upload_file( | 404 | this.fireflix.flickr.upload_file( |
405 | ff.file, { | 405 | ff.file, { |
406 | title: ff.title, tags: ff.tags, | 406 | title: ff.title, tags: ff.tags, |
407 | is_public: ff.is_public?'1':'0', | 407 | is_public: ff.is_public?'1':'0', |
408 | is_friend: ff.is_friend?'1':'0', | 408 | is_friend: ff.is_friend?'1':'0', |
409 | is_family: ff.is_family?'1':'0' | 409 | is_family: ff.is_family?'1':'0' |
410 | }, function(x,p) { | 410 | }, function(x,p) { |
411 | ff.photoid = p; | 411 | ff.photoid = p; |
412 | _this.batch_ids.push(p); | 412 | _this.batch_ids.push(p); |
413 | ff.state='completed'; | 413 | ff.state='completed'; |
414 | _this.tree.invalidate(); | 414 | _this.tree.invalidate(); |
415 | window.setTimeout(_this.upload_to,0,_this); | 415 | window.setTimeout(_this.upload_to,0,_this); |
416 | }, function(x,s,c,m) { | 416 | }, function(x,s,c,m) { |
417 | ff.state='failed'; | 417 | ff.state='failed'; |
418 | ff.flickr_errcode = c; | 418 | ff.flickr_errcode = c; |
419 | ff.flickr_errmsg = m; | 419 | ff.flickr_errmsg = m; |
420 | _this.tree.invalidate(); | 420 | _this.tree.invalidate(); |
421 | window.setTimeout(_this.upload_to,0,_this); | 421 | window.setTimeout(_this.upload_to,0,_this); |
422 | } | 422 | } |
423 | ); | 423 | ); |
424 | return; | 424 | return; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | this.on_finish_upload(); | 427 | this.on_finish_upload(); |
428 | }, | 428 | }, |
429 | upload_to: function(_this) { _this.upload_worker(); }, | 429 | upload_to: function(_this) { _this.upload_worker(); }, |
430 | on_file_upload: function(f) { | 430 | on_file_upload: function(f) { |
431 | this.cmd_uploads_upload.setAttribute('disabled','true'); | 431 | this.cmd_uploads_upload.setAttribute('disabled','true'); |
432 | for(var fi in this.files) { | 432 | for(var fi in this.files) { |
433 | if(this.files[fi].file==f.file) { | 433 | if(this.files[fi].file==f.file) { |
434 | this.tree.ensureRowIsVisible(fi); | 434 | this.tree.ensureRowIsVisible(fi); |
435 | this.selection.rangedSelect(fi,fi,false); | 435 | this.selection.rangedSelect(fi,fi,false); |
436 | this.selection.currentIndex = fi; | 436 | this.selection.currentIndex = fi; |
437 | this.selToProps(); | 437 | this.selToProps(); |
438 | break; | 438 | break; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | }, | 441 | }, |
442 | on_finish_upload: function() { | 442 | on_finish_upload: function() { |
443 | if(this.batch_ids.length) { | 443 | if(this.batch_ids.length) { |
444 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); | 444 | var psn = prompt(this.fireflix.loc_strings.getString('postUploadPhotoset')); |
445 | if(psn!=null) { | 445 | if(psn!=null) { |
446 | var pids = this.batch_ids.join(','); | 446 | var pids = this.batch_ids.join(','); |
447 | var ppid = this.batch_ids[0]; | 447 | var ppid = this.batch_ids[0]; |
448 | var _this = this; | 448 | var that = this; |
449 | this.fireflix.flickr.api_call( | 449 | this.fireflix.flickr.api_call_json( |
450 | { | 450 | { |
451 | method: 'flickr.photosets.create', | 451 | method: 'flickr.photosets.create', |
452 | auth_token: 'default', | 452 | auth_token: 'default', |
453 | title: psn, | 453 | title: psn, |
454 | primary_photo_id: ppid | 454 | primary_photo_id: ppid |
455 | }, function(x) { | 455 | }, function(x,j) { |
456 | var npid = | 456 | var npid = j.photoset.id; |
457 | x.responseXML.getElementsByTagName('photoset').item(0).getAttribute('id'); | 457 | that.fireflix.flickr.api_call_json( |
458 | _this.fireflix.flickr.api_call( | ||
459 | { | 458 | { |
460 | method: 'flickr.photosets.editPhotos', | 459 | method: 'flickr.photosets.editPhotos', |
461 | auth_token: 'default', | 460 | auth_token: 'default', |
462 | photoset_id: npid, | 461 | photoset_id: npid, |
463 | primary_photo_id: ppid, | 462 | primary_photo_id: ppid, |
464 | photo_ids: pids | 463 | photo_ids: pids |
465 | }, function(x) { | 464 | }, function(x,j) { |
466 | _this.fireflix.refresh_sets(); | 465 | that.fireflix.refresh_sets(); |
467 | }, function(x,s,c,m) { | 466 | }, function(x,s,c,m) { |
468 | _this.fireflix.flickr_failure(x,s,c,m); | 467 | that.fireflix.flickr_failure(x,s,c,m); |
469 | } | 468 | } |
470 | ); | 469 | ); |
471 | }, function(x,s,c,m) { | 470 | }, function(x,s,c,m) { |
472 | _this.fireflix.flickr_failure(x,s,c,m); | 471 | that.fireflix.flickr_failure(x,s,c,m); |
473 | } | 472 | } |
474 | ); | 473 | ); |
475 | } | 474 | } |
476 | } | 475 | } |
477 | this.selection.clearSelection(); | 476 | this.selection.clearSelection(); |
478 | this.cmd_uploads_upload.setAttribute('disabled','false'); | 477 | this.cmd_uploads_upload.setAttribute('disabled','false'); |
479 | this.upload_progress.setAttribute('hidden','true'); | 478 | this.upload_progress.setAttribute('hidden','true'); |
480 | }, | 479 | }, |
481 | 480 | ||
482 | clear_list: function() { | 481 | clear_list: function() { |
483 | this.tree.beginUpdateBatch(); | 482 | this.tree.beginUpdateBatch(); |
484 | this.rowCount = 0; | 483 | this.rowCount = 0; |
485 | this.files = new Array(); | 484 | this.files = new Array(); |
486 | this.tree.endUpdateBatch(); | 485 | this.tree.endUpdateBatch(); |
487 | this.selToProps(); | 486 | this.selToProps(); |
488 | }, | 487 | }, |
489 | selectionChanged: function() { | 488 | selectionChanged: function() { |
490 | this.selToProps(); | 489 | this.selToProps(); |
491 | }, | 490 | }, |
492 | disableProps: function() { | 491 | disableProps: function() { |
493 | this.upload_filename.value=''; | 492 | this.upload_filename.value=''; |
494 | this.upload_filename.disabled = true; | 493 | this.upload_filename.disabled = true; |
495 | this.upload_title.value=''; | 494 | this.upload_title.value=''; |
496 | this.upload_title.disabled = true; | 495 | this.upload_title.disabled = true; |
497 | this.upload_file_preview.src = null; | 496 | this.upload_file_preview.src = null; |
498 | this.upload_tags.value=''; | 497 | this.upload_tags.value=''; |
499 | this.upload_tags.disabled = true; | 498 | this.upload_tags.disabled = true; |
500 | this.upload_is_public.disabled = true; | 499 | this.upload_is_public.disabled = true; |
501 | this.upload_is_friends.disabled = true; | 500 | this.upload_is_friends.disabled = true; |
502 | this.upload_is_family.disabled = true; | 501 | this.upload_is_family.disabled = true; |
503 | /* this.upload_file_props.hidden = true; */ | 502 | /* this.upload_file_props.hidden = true; */ |
504 | }, | 503 | }, |
505 | selToProps: function() { | 504 | selToProps: function() { |
506 | if(!this.selection.count) { | 505 | if(!this.selection.count) { |
507 | this.disableProps(); | 506 | this.disableProps(); |
508 | this.upload_file_props.hidden = true; | 507 | this.upload_file_props.hidden = true; |
509 | }else if(this.selection.count==1) { | 508 | }else if(this.selection.count==1) { |
510 | var f=this.files[this.selection.currentIndex]; | 509 | var f=this.files[this.selection.currentIndex]; |
511 | if(f==null) { | 510 | if(f==null) { |
512 | this.disableProps(); | 511 | this.disableProps(); |
513 | this.upload_file_props.hidden = true; | 512 | this.upload_file_props.hidden = true; |
514 | }else{ | 513 | }else{ |
515 | var inactives = f.state!='pending'; | 514 | var inactives = f.state!='pending'; |
516 | this.upload_filename.value = f.file; this.upload_filename.disabled = inactives; | 515 | this.upload_filename.value = f.file; this.upload_filename.disabled = inactives; |
517 | this.upload_title.value = f.title; this.upload_title.disabled = inactives; | 516 | this.upload_title.value = f.title; this.upload_title.disabled = inactives; |
518 | this.upload_file_preview.src = 'file:///'+f.file; | 517 | this.upload_file_preview.src = 'file:///'+f.file; |
519 | this.upload_tags.value = f.tags; this.upload_tags.disabled = inactives; | 518 | this.upload_tags.value = f.tags; this.upload_tags.disabled = inactives; |
520 | this.upload_is_public.checked = f.is_public; this.upload_is_public.disabled = inactives; | 519 | this.upload_is_public.checked = f.is_public; this.upload_is_public.disabled = inactives; |
521 | this.upload_is_friends.checked = f.is_friend; this.upload_is_friends.disabled = inactives; | 520 | this.upload_is_friends.checked = f.is_friend; this.upload_is_friends.disabled = inactives; |
522 | this.upload_is_family.checked = f.is_family; this.upload_is_family.disabled = inactives; | 521 | this.upload_is_family.checked = f.is_family; this.upload_is_family.disabled = inactives; |
523 | if(f.state=='failed') { | 522 | if(f.state=='failed') { |
524 | this.upload_failure.textContent=((f.flickr_errcode<0)?'':f.flickr_errcode+': ')+f.flickr_errmsg; | 523 | this.upload_failure.textContent=((f.flickr_errcode<0)?'':f.flickr_errcode+': ')+f.flickr_errmsg; |
525 | this.upload_failure.hidden = false; | 524 | this.upload_failure.hidden = false; |
526 | }else{ | 525 | }else{ |
527 | this.upload_failure.hidden = true; | 526 | this.upload_failure.hidden = true; |
528 | } | 527 | } |
529 | this.upload_file_props.hidden = false; | 528 | this.upload_file_props.hidden = false; |
530 | } | 529 | } |
531 | }else{ | 530 | }else{ |
532 | var ftitle = null; var onetitle = true; | 531 | var ftitle = null; var onetitle = true; |
533 | var ftags = null; var onetag = true; | 532 | var ftags = null; var onetag = true; |
534 | var fs = 0; | 533 | var fs = 0; |
535 | for(var ff in this.files) { | 534 | for(var ff in this.files) { |
536 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { | 535 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending' ) { |
537 | ++fs; | 536 | ++fs; |
538 | if(ftitle==null) { | 537 | if(ftitle==null) { |
539 | ftitle = this.files[ff].title; | 538 | ftitle = this.files[ff].title; |
540 | }else if(ftitle!=this.files[ff].title) { | 539 | }else if(ftitle!=this.files[ff].title) { |
541 | onetitle = false; | 540 | onetitle = false; |
542 | } | 541 | } |
543 | if(ftags==null) { | 542 | if(ftags==null) { |
544 | ftags = this.files[ff].tags; | 543 | ftags = this.files[ff].tags; |
545 | }else if(ftags!=this.files[ff].tags) { | 544 | }else if(ftags!=this.files[ff].tags) { |
546 | onetag = false; | 545 | onetag = false; |
547 | } | 546 | } |
548 | } | 547 | } |
549 | } | 548 | } |
550 | if(fs) { | 549 | if(fs) { |
551 | this.upload_filename.value=''; | 550 | this.upload_filename.value=''; |
552 | this.upload_filename.disabled = true; | 551 | this.upload_filename.disabled = true; |
553 | if(onetitle) | 552 | if(onetitle) |
554 | this.upload_title.value = ftitle; | 553 | this.upload_title.value = ftitle; |
555 | this.upload_title.disabled = false; | 554 | this.upload_title.disabled = false; |
556 | if(onetag) | 555 | if(onetag) |
557 | this.upload_tags.value = ftags; | 556 | this.upload_tags.value = ftags; |
558 | this.upload_tags.disabled = false; | 557 | this.upload_tags.disabled = false; |
559 | this.upload_file_preview.src = null; | 558 | this.upload_file_preview.src = null; |
560 | this.upload_failure.hidden = true; | 559 | this.upload_failure.hidden = true; |
561 | this.upload_file_props.hidden = false; | 560 | this.upload_file_props.hidden = false; |
562 | }else | 561 | }else |
563 | this.disableProps(); | 562 | this.disableProps(); |
564 | this.upload_file_props.hidden = true; | 563 | this.upload_file_props.hidden = true; |
565 | } | 564 | } |
566 | }, | 565 | }, |
567 | propsToSel: function(prop) { | 566 | propsToSel: function(prop) { |
568 | if(this.selection.count<=0) return; | 567 | if(this.selection.count<=0) return; |
569 | for(var ff in this.files) { | 568 | for(var ff in this.files) { |
570 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending') { | 569 | if(this.selection.isSelected(ff) && this.files[ff].state=='pending') { |
571 | if(prop=='filename') this.files[ff].file = this.upload_filename.value; | 570 | if(prop=='filename') this.files[ff].file = this.upload_filename.value; |
572 | if(prop=='title') this.files[ff].title = this.upload_title.value; | 571 | if(prop=='title') this.files[ff].title = this.upload_title.value; |
573 | if(prop=='tags') this.files[ff].tags = this.upload_tags.value; | 572 | if(prop=='tags') this.files[ff].tags = this.upload_tags.value; |
574 | if(prop=='is_public') this.files[ff].is_public = this.upload_is_public.checked; | 573 | if(prop=='is_public') this.files[ff].is_public = this.upload_is_public.checked; |
575 | if(prop=='is_friends') this.files[ff].is_friend = this.upload_is_friends.checked; | 574 | if(prop=='is_friends') this.files[ff].is_friend = this.upload_is_friends.checked; |
576 | if(prop=='is_family') this.files[ff].is_family = this.upload_is_family.checked; | 575 | if(prop=='is_family') this.files[ff].is_family = this.upload_is_family.checked; |
577 | this.tree.invalidateRow(ff); | 576 | this.tree.invalidateRow(ff); |
578 | } | 577 | } |
579 | } | 578 | } |
580 | }, | 579 | }, |
581 | 580 | ||
582 | on_upload: function() { | 581 | on_upload: function() { |
583 | this.selToProps(); | 582 | this.selToProps(); |
584 | this.batch_ids = new Array(); | 583 | this.batch_ids = new Array(); |
585 | this.upload_progress.value=0; | 584 | this.upload_progress.value=0; |
586 | this.upload_progress.setAttribute('hidden','false'); | 585 | this.upload_progress.setAttribute('hidden','false'); |
587 | this.upload_worker(); | 586 | this.upload_worker(); |
588 | }, | 587 | }, |
589 | on_clear: function() { | 588 | on_clear: function() { |
590 | this.clear_list(); | 589 | this.clear_list(); |
591 | }, | 590 | }, |
592 | on_remove: function() { | 591 | on_remove: function() { |
593 | if(this.selection.count) { | 592 | if(this.selection.count) { |
594 | this.tree.beginUpdateBatch(); | 593 | this.tree.beginUpdateBatch(); |
595 | for(var i=this.files.length-1;i>=0;--i) { | 594 | for(var i=this.files.length-1;i>=0;--i) { |
596 | if(this.selection.isSelected(i)) { | 595 | if(this.selection.isSelected(i)) { |
597 | this.files.splice(i,1); | 596 | this.files.splice(i,1); |
598 | this.rowCount--; | 597 | this.rowCount--; |
599 | } | 598 | } |
600 | } | 599 | } |
601 | this.tree.endUpdateBatch(); | 600 | this.tree.endUpdateBatch(); |
602 | this.selection.clearSelection(); | 601 | this.selection.clearSelection(); |
603 | } | 602 | } |
604 | }, | 603 | }, |
605 | on_add: function() { | 604 | on_add: function() { |
606 | var ifp = Components.interfaces.nsIFilePicker; | 605 | var ifp = Components.interfaces.nsIFilePicker; |
607 | var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp); | 606 | var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(ifp); |
608 | fp.init(window, "Select a File", ifp.modeOpenMultiple); | 607 | fp.init(window, "Select a File", ifp.modeOpenMultiple); |
609 | fp.appendFilters(ifp.filterImages); | 608 | fp.appendFilters(ifp.filterImages); |
610 | var rv = fp.show(); | 609 | var rv = fp.show(); |
611 | if(rv==ifp.returnOK) { | 610 | if(rv==ifp.returnOK) { |
612 | var ff = fp.files; | 611 | var ff = fp.files; |
613 | while(ff.hasMoreElements()) { | 612 | while(ff.hasMoreElements()) { |
614 | var f = ff.getNext(); | 613 | var f = ff.getNext(); |
615 | f.QueryInterface(Components.interfaces.nsIFile); | 614 | f.QueryInterface(Components.interfaces.nsIFile); |
616 | this.add(f.path); | 615 | this.add(f.path); |
617 | } | 616 | } |
618 | } | 617 | } |
619 | }, | 618 | }, |
620 | on_cmd_open: function(ev) { | 619 | on_cmd_open: function(ev) { |
621 | if(this.selection.currentIndex<0) return; | 620 | if(this.selection.currentIndex<0) return; |
622 | var f = this.files[this.selection.currentIndex]; | 621 | var f = this.files[this.selection.currentIndex]; |
623 | if(f.photoid) { | 622 | if(f.photoid) { |
624 | this.fireflix.openTab( | 623 | this.fireflix.openTab( |
625 | this.fireflix.flickr.make_uploader_edit_url(f.photoid) | 624 | this.fireflix.flickr.make_uploader_edit_url(f.photoid) |
626 | ); | 625 | ); |
627 | }else{ | 626 | }else{ |
628 | this.fireflix.openTab( 'file://'+f.file); | 627 | this.fireflix.openTab( 'file://'+f.file); |
629 | } | 628 | } |
630 | } | 629 | } |
631 | }, | 630 | }, |
632 | 631 | ||
633 | on_set_props: function() { | 632 | on_set_props: function() { |
634 | var pset = this.photosets.sets[this.photosets.selection.currentIndex]; | 633 | var pset = this.photosets.sets[this.photosets.selection.currentIndex]; |
635 | window.openDialog( | 634 | window.openDialog( |
636 | "chrome://fireflix/content/photoset-props.xul", | 635 | "chrome://fireflix/content/photoset-props.xul", |
637 | null, "dependent,modal,dialog,chrome", this, | 636 | null, "dependent,modal,dialog,chrome", this, |
638 | pset ); | 637 | pset ); |
639 | if(pset.dirty) { | 638 | if(pset.dirty) { |
640 | var _this = this; | 639 | var _this = this; |
641 | this.flickr.api_call( | 640 | this.flickr.api_call( |
642 | { | 641 | { |
643 | method: 'flickr.photosets.editMeta', | 642 | method: 'flickr.photosets.editMeta', |
644 | auth_token: 'default', | 643 | auth_token: 'default', |
645 | photoset_id: pset.id, | 644 | photoset_id: pset.id, |
646 | title: pset.title, | 645 | title: pset.title, |
647 | description: pset.description | 646 | description: pset.description |
648 | }, function(xr) { | 647 | }, function(xr) { |
649 | pset.dirty = false; | 648 | pset.dirty = false; |
650 | _this.flickr.api_call( | 649 | _this.flickr.api_call( |
651 | { | 650 | { |
652 | method: 'flickr.photosets.getPhotos', | 651 | method: 'flickr.photosets.getPhotos', |
653 | auth_token: 'default', | 652 | auth_token: 'default', |
654 | photoset_id: pset.id | 653 | photoset_id: pset.id |
655 | }, function(xr) { | 654 | }, function(xr) { |
656 | var x = xr.responseXML; | 655 | var x = xr.responseXML; |
657 | var xp = x.evaluate( | 656 | var xp = x.evaluate( |
658 | '/rsp/photoset/photo', x, null, | 657 | '/rsp/photoset/photo', x, null, |
659 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); | 658 | XPathResult.ORDERED_NODE_ITERATOR_TYPE, null ); |
660 | var phids = new Array(); | 659 | var phids = new Array(); |
661 | var priph = null; | 660 | var priph = null; |
662 | var n; while(n=xp.iterateNext()) { | 661 | var n; while(n=xp.iterateNext()) { |
663 | var pid = n.getAttribute('id'); | 662 | var pid = n.getAttribute('id'); |
664 | phids.push( pid ); | 663 | phids.push( pid ); |