author | Michael Krelin <hacker@klever.net> | 2006-11-12 22:14:50 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2006-11-12 22:14:50 (UTC) |
commit | 790a0930a6d9eb52020193b8f5aabf5da1075ba3 (patch) (unidiff) | |
tree | 85860b287ce2d3b105229baa781fa67075e7cf95 /content | |
parent | afcae0d9514f35c96484e6db1eb21e76821b5654 (diff) | |
download | fireflix-790a0930a6d9eb52020193b8f5aabf5da1075ba3.zip fireflix-790a0930a6d9eb52020193b8f5aabf5da1075ba3.tar.gz fireflix-790a0930a6d9eb52020193b8f5aabf5da1075ba3.tar.bz2 |
remove unneeded dumps
git-svn-id: http://svn.klever.net/kin/fireflix/trunk@216 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | content/fireflix.js | 2 |
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 | |||
@@ -257,281 +257,279 @@ var fireflix = { | |||
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; |