Changeset 874
- Timestamp:
- 2008-03-12 02:36:44 (8 months ago)
- Files:
-
- trunk/chrome/content/common/overlayFunctions.js (modified) (3 diffs)
- trunk/chrome/content/dta/addurl.js (modified) (3 diffs)
- trunk/chrome/content/dta/manager.js (modified) (1 diff)
- trunk/chrome/content/integration/elements.js (modified) (4 diffs)
- trunk/chrome/content/integration/elements.xul (modified) (1 diff)
- trunk/chrome/locale/en-US/menu.dtd (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/common/overlayFunctions.js
r871 r874 314 314 } 315 315 } 316 return this.ios.newURI(rel, doc.characterSet, this.ios.newURI(base, doc.characterSet, null)) .spec;316 return this.ios.newURI(rel, doc.characterSet, this.ios.newURI(base, doc.characterSet, null)); 317 317 }, 318 318 … … 326 326 } 327 327 try { 328 ref = this.composeURL(doc, b[i].getAttribute('href')) ;328 ref = this.composeURL(doc, b[i].getAttribute('href')).spec; 329 329 } 330 330 catch (ex) { … … 337 337 }, 338 338 339 saveSingleLink : function(turbo, url, referrer, description ) {339 saveSingleLink : function(turbo, url, referrer, description, postData) { 340 340 var item = { 341 341 'url': url, trunk/chrome/content/dta/addurl.js
r862 r874 41 41 42 42 function QueueItem(url, num, desc, hash) { 43 if (!(url instanceof DTA_URL) || !DTA_AddingFunctions.isLinkOpenable(url)) {44 throw new Components.Exception('invalid url');45 }46 43 this.url = url; 47 44 this.numIstance = num; … … 116 113 117 114 function BatchGenerator(link) { 118 if (!(link instanceof DTA_URL)) {119 throw new Components.Exception("invalid argument. Type not DTA_URL");120 }121 115 this.url = link.url; 122 116 var url = this.url; … … 275 269 // JS does not preserve types between windows (as each window gets an own sandbox) 276 270 // This hack makes our URL a DTA_URL again ;) 277 address._realURL = new DTA_URL(a.url.url, a.url.charset);271 address._realURL = a.url; 278 272 address.readOnly = true; 279 273 $('batcheslabel').style.display = 'none'; trunk/chrome/content/dta/manager.js
r872 r874 2507 2507 d.hash = null; // to initialize prettyHash 2508 2508 } 2509 try { 2510 d.postData = ContentHandling.getPostDataFor(d.urlManager.url.toURI()); 2511 } 2512 catch (ex) { 2513 Debug.log("No post data for me: " + d.urlManager.url, ex); 2514 // no-op 2509 if (e.url.postData) { 2510 d.postData = e.url.postData; 2511 } 2512 else { 2513 try { 2514 d.postData = ContentHandling.getPostDataFor(d.urlManager.url.toURI()); 2515 } 2516 catch (ex) { 2517 Debug.log("No post data for me: " + d.urlManager.url, ex); 2518 // no-op 2519 } 2515 2520 } 2516 2521 d.state = start ? QUEUED : PAUSED; trunk/chrome/content/integration/elements.js
r826 r874 109 109 if (!DTA_AddingFunctions.isLinkOpenable(src)) { 110 110 try { 111 src = DTA_AddingFunctions.composeURL(doc, src) ;111 src = DTA_AddingFunctions.composeURL(doc, src).spec; 112 112 } 113 113 catch (ex) { … … 355 355 } 356 356 }, 357 findForm: function(turbo) { 358 try { 359 var ctx = this.contextMenu; 360 if (!('form' in ctx.target)) { 361 throw new Components.Exception("No form"); 362 } 363 var form = ctx.target.form; 364 365 var action = DTA_AddingFunctions.composeURL(form.ownerDocument, form.action); 366 if (!DTA_AddingFunctions.isLinkOpenable(action.spec)) { 367 throw new Components.Exception('Unsupported URL'); 368 } 369 action = action.QueryInterface(Components.interfaces.nsIURL); 370 371 var charset = form.ownerDocument.characterSet; 372 if (form.acceptCharset) { 373 charset = form.acceptCharset; 374 } 375 if (charset.match(/utf-?(?:16|32)/i)) { 376 charset = 'utf-8'; 377 } 378 379 var encoder = Components.classes['@mozilla.org/intl/texttosuburi;1'] 380 .getService(Components.interfaces.nsITextToSubURI); 381 382 var values = []; 383 384 for (var i = 0; i < form.elements.length; ++i) { 385 if (form.elements[i].name == '') { 386 continue; 387 } 388 var v = encoder.ConvertAndEscape(charset, form.elements[i].name) + "="; 389 if (form.elements[i].value != '') { 390 v += encoder.ConvertAndEscape(charset, form.elements[i].value); 391 } 392 values.push(v); 393 } 394 values = values.join("&"); 395 396 if (form.method.toLowerCase() == 'post') { 397 var ss = Components.classes['@mozilla.org/io/string-input-stream;1'] 398 .createInstance(Components.interfaces.nsIStringInputStream); 399 ss.setData(values, -1); 400 401 var ms = Components.classes['@mozilla.org/network/mime-input-stream;1'] 402 .createInstance(Components.interfaces.nsIMIMEInputStream); 403 ms.addContentLength = true; 404 ms.addHeader('Content-Type', 'application/x-www-form-urlencoded'); 405 ms.setData(ss); 406 407 var sis = Components.classes['@mozilla.org/scriptableinputstream;1'] 408 .createInstance(Components.interfaces.nsIScriptableInputStream); 409 sis.init(ms); 410 var postData = ''; 411 var avail = 0; 412 while ((avail = sis.available()) != 0) { 413 postData += sis.read(avail); 414 } 415 sis.close(); 416 ms.close(); 417 ss.close(); 418 419 action = new DTA_URL(action.spec, form.ownerDocument.characterSet); 420 action.postData = postData; 421 } 422 else { 423 action.query = values; 424 action.ref = ''; 425 action = new DTA_URL(action.spec, form.ownerDocument.characterSet); 426 } 427 428 429 var ref = DTA_AddingFunctions.getRef(document.commandDispatcher.focusedWindow.document); 430 var desc = this.extractDescription(form); 431 432 if (turbo) { 433 try { 434 DTA_AddingFunctions.saveSingleLink(true, action, ref, desc); 435 return; 436 } 437 catch (ex) { 438 DTA_debug.log('findSingleLink', ex); 439 DTA_alert(this.getString('error'), this.getString('errorinformation')); 440 } 441 } 442 DTA_AddingFunctions.saveSingleLink(false, action, ref, desc); 443 } 444 catch (ex) { 445 DTA_debug.log('findForm', ex); 446 } 447 }, 357 448 358 449 init: function() { … … 365 456 var cont = document.getElementById('dtaCtxSubmenu'); 366 457 367 ['SepBack', 'Pref', 'SepPref', 'TDTA', 'DTA', 'SaveT', 'Save', 'S epFront'].forEach(458 ['SepBack', 'Pref', 'SepPref', 'TDTA', 'DTA', 'SaveT', 'Save', 'SaveFormT', 'SaveForm', 'SepFront'].forEach( 368 459 function(id) { 369 460 this.compact[id] = document.getElementById('dtaCtx' + id); … … 470 561 menu.SaveT.label = this.getString('turbosave' + (ctx.onLink ? 'link' : 'image')); 471 562 } 563 else if ( 564 ctx.target 565 && ctx.target.localName.toLowerCase() == 'input' 566 && ctx.target.hasAttribute('type') 567 && ctx.target.getAttribute('type').toLowerCase() == 'submit' 568 && 'form' in ctx.target 569 ) { 570 if (items[0]) { 571 show.push(menu.SaveForm); 572 } 573 if (items[1]) { 574 show.push(menu.SaveFormT); 575 } 576 } 472 577 // regular 473 if (ctx && (ctx.fake || !(ctx.onLink || ctx.onImage))) {578 else if (ctx && (ctx.fake || !(ctx.onLink || ctx.onImage))) { 474 579 if (items[0]) { 475 580 show.push(menu.DTA); trunk/chrome/content/integration/elements.xul
r851 r874 54 54 <menuitem image="chrome://dta/skin/common/turbo.png" class="menuitem-iconic" id="dtaCtxSaveT" accesskey="o" oncommand="DTA_ContextOverlay.findSingleLink(true);"/> 55 55 <menuitem image="chrome://dta/skin/common/dta.png" class="menuitem-iconic" id="dtaCtxSave" accesskey="n" oncommand="DTA_ContextOverlay.findSingleLink(false);"/> 56 <menuitem image="chrome://dta/skin/common/turbo.png" class="menuitem-iconic" id="dtaCtxSaveFormT" label="&dta-form-save-turbo.label;" accesskey="o" oncommand="DTA_ContextOverlay.findForm(true);"/> 57 <menuitem image="chrome://dta/skin/common/dta.png" class="menuitem-iconic" id="dtaCtxSaveForm" label="&dta-form-save.label;" accesskey="n" oncommand="DTA_ContextOverlay.findForm(false);"/> 56 58 <menuseparator class="thin" id="dtaCtxSepPref"/> 57 59 <menuitem image="chrome://dta/skin/common/prefs.png" class="menuitem-iconic" id="dtaCtxPref" label="&dta-pref.label;" oncommand="DTA_showPreferences();" /> trunk/chrome/locale/en-US/menu.dtd
r497 r874 5 5 <!ENTITY dta-tb-all.label "All tabs"> 6 6 <!ENTITY dta-tb-single.label "Current tab"> 7 <!ENTITY dta-form-save.label "Save form target with DownThemAll!"> 8 <!ENTITY dta-form-save-turbo.label "Start saving form target with dTa OneClick!">
