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