Changeset 1044
- Timestamp:
- 2008-08-13 03:33:35 (5 months ago)
- Files:
-
- trunk/chrome/content/common/overlayFunctions.js (modified) (7 diffs)
- trunk/chrome/content/dta/manager.js (modified) (2 diffs)
- trunk/chrome/content/integration/elements.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/chrome/content/common/overlayFunctions.js
r1030 r1044 39 39 /** 40 40 * include other chrome js files 41 * @param uri Relative URI to the dta content path 42 * @param many Optional. If set, then include that file more than once 41 * 42 * @param uri 43 * Relative URI to the dta content path 44 * @param many 45 * Optional. If set, then include that file more than once 43 46 */ 44 47 var DTA_include = function() { … … 117 120 118 121 function DTA_URL(url, preference) { 119 this.url = url;120 122 this.preference = preference ? preference : 100; 121 }; 122 DTA_URL.prototype = { 123 get url() { 124 return this._url; 125 }, 126 set url(nv) { 127 delete this.hash; 128 129 if (nv instanceof Components.interfaces.nsIURI) { 130 nv = nv.QueryInterface(Components.interfaces.nsIURL); 131 } 132 if (!(nv instanceof Components.interfaces.nsIURL)) { 123 124 try { 125 if (url instanceof Components.interfaces.nsIURI) { 126 url = url.QueryInterface(Components.interfaces.nsIURL); 127 } 128 if (!(url instanceof Components.interfaces.nsIURL)) { 133 129 throw new Components.Exception("you must pass an nsIURL"); 134 130 } 135 131 136 this._url = nv.clone();137 132 this._url = url.clone(); 133 138 134 let hash = DTA_getLinkPrintHash(this._url); 139 135 this._url.ref = ''; … … 142 138 } 143 139 this._usable = DTA_URLhelpers.decodeCharset(this._url.spec, this._url.originCharset); 140 } 141 catch (ex) { 142 DTA_debug.log("failed to set URL", ex); 143 throw ex; 144 } 145 }; 146 DTA_URL.prototype = { 147 get url() { 148 return this._url; 144 149 }, 145 150 get usable() { … … 512 517 513 518 /** 514 * Checks if a provided strip has the correct hash format 515 * Supported are: md5, sha1, sha256, sha384, sha512 516 * @param hash Hash to check 519 * Checks if a provided strip has the correct hash format Supported are: md5, 520 * sha1, sha256, sha384, sha512 521 * 522 * @param hash 523 * Hash to check 517 524 * @return hash type or null 518 525 */ … … 550 557 /** 551 558 * Get a link-fingerprint hash from an url (or just the hash component) 552 * @param url. Either String or nsIURI 559 * 560 * @param url. 561 * Either String or nsIURI 553 562 * @return Valid hash string or null 554 563 */ … … 571 580 /** 572 581 * Get a link-fingerprint metalink from an url (or just the hash component 573 * @param url. Either String or nsIURI 574 * @param charset. Optional. Charset of the orgin link and link to be created 582 * 583 * @param url. 584 * Either String or nsIURI 585 * @param charset. 586 * Optional. Charset of the orgin link and link to be created 575 587 * @return Valid hash string or null 576 588 */ … … 597 609 598 610 /** 599 * Tiny helper to "convert" given object into a weak observer. Object must still implement .observe() 611 * Tiny helper to "convert" given object into a weak observer. Object must still 612 * implement .observe() 613 * 600 614 * @author Nils 601 * @param obj Object to convert 615 * @param obj 616 * Object to convert 602 617 */ 603 618 function DTA_makeObserver(obj) { trunk/chrome/content/dta/manager.js
r1043 r1044 627 627 } 628 628 }, 629 replace: function(url, newurl) { 630 this._urls = this._urls.map(function(u) u.url.spec == url.url.spec ? newurl : u); 631 }, 629 632 markBad: function um_markBad(url) { 630 633 if (this._urls.length > 1) { 631 this._urls = this._urls.filter(function(u) { return u != url; });634 this._urls = this._urls.filter(function(u) u != url); 632 635 } 633 636 else if (this._urls[0] == url) { … … 2167 2170 try { 2168 2171 this._chan == newChannel; 2169 this.url.url = newChannel.URI; 2172 let newurl = new DTA_URL(newChannel.URI.QueryInterface(Ci.nsIURL), this.url.preference); 2173 this.d.urlManager.replace(this.url, newurl); 2174 this.url = newurl; 2170 2175 this.d.fileName = this.url.usable.getUsableFileName(); 2171 2176 } trunk/chrome/content/integration/elements.js
r1030 r1044 38 38 39 39 var DTA_Prompts = {}; 40 Components.utils.import('resource://dta/prompts.jsm', DTA_Prompts); 40 Components.utils.import('resource://dta/prompts.jsm', DTA_Prompts); 41 41 42 42 // DTA context overlay … … 65 65 } 66 66 67 varref = DTA_AddingFunctions.getRef(doc);67 let ref = DTA_AddingFunctions.getRef(doc); 68 68 69 69 for (var i = 0; i < lnks.length; ++i) {
