| 153 | | dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName) { |
| 154 | | // summary: |
| 155 | | // Registers a function to be triggered after the DOM has finished loading |
| 156 | | // and widgets declared in markup have been instantiated. Images and CSS files |
| 157 | | // may or may not have finished downloading when the specified function is called. |
| 158 | | // (Note that widgets' CSS and HTML code is guaranteed to be downloaded before said |
| 159 | | // widgets are instantiated.) |
| 160 | | // |
| 161 | | // usage: |
| 162 | | // dojo.addOnLoad(functionPointer) |
| 163 | | // dojo.addOnLoad(object, "functionName") |
| 164 | | |
| | 154 | dojo.addOnLoad = function(/*Object?*/obj, /*String|Function*/functionName){ |
| | 155 | // summary: |
| | 156 | // Registers a function to be triggered after the DOM has finished |
| | 157 | // loading and widgets declared in markup have been instantiated. |
| | 158 | // Images and CSS files may or may not have finished downloading when |
| | 159 | // the specified function is called. (Note that widgets' CSS and HTML |
| | 160 | // code is guaranteed to be downloaded before said widgets are |
| | 161 | // instantiated.) |
| | 162 | // |
| | 163 | // usage: |
| | 164 | // dojo.addOnLoad(functionPointer); |
| | 165 | // dojo.addOnLoad(object, "functionName"); |
| 501 | | } |
| 502 | | |
| 503 | | dojo._Url = function(/*dojo._Url||String...*/){ |
| 504 | | // summary: |
| 505 | | // Constructor to create an object representing a URL. |
| 506 | | // It is marked as private, since we might consider removing |
| 507 | | // or simplifying it. |
| 508 | | // description: |
| 509 | | // Each argument is evaluated in order relative to the next until |
| 510 | | // a canonical uri is produced. To get an absolute Uri relative to |
| 511 | | // the current document use: |
| 512 | | // new dojo._Url(document.baseURI, url) |
| 513 | | |
| 514 | | // TODO: support for IPv6, see RFC 2732 |
| 515 | | |
| 516 | | // resolve uri components relative to each other |
| 517 | | var n = null; |
| 518 | | var _a = arguments; |
| 519 | | var uri = _a[0]; |
| 520 | | for(var i = 1; i<_a.length; i++){ |
| 521 | | if(!_a[i]){ continue; } |
| 522 | | |
| 523 | | // Safari doesn't support this.constructor so we have to be explicit |
| 524 | | var relobj = new dojo._Url(_a[i]+""); |
| 525 | | var uriobj = new dojo._Url(uri+""); |
| 526 | | |
| 527 | | if( |
| 528 | | (relobj.path=="") && |
| 529 | | (!relobj.scheme) && |
| 530 | | (!relobj.authority) && |
| 531 | | (!relobj.query) |
| 532 | | ){ |
| 533 | | if(relobj.fragment != null){ |
| 534 | | uriobj.fragment = relobj.fragment; |
| 535 | | } |
| 536 | | relobj = uriobj; |
| 537 | | }else if(relobj.scheme == null){ |
| 538 | | relobj.scheme = uriobj.scheme; |
| 539 | | |
| 540 | | if(relobj.authority == null){ |
| 541 | | relobj.authority = uriobj.authority; |
| 542 | | |
| 543 | | if(relobj.path.charAt(0) != "/"){ |
| 544 | | var path = uriobj.path.substring(0, |
| 545 | | uriobj.path.lastIndexOf("/") + 1) + relobj.path; |
| 546 | | |
| 547 | | var segs = path.split("/"); |
| 548 | | for(var j = 0; j < segs.length; j++){ |
| 549 | | if(segs[j] == "."){ |
| 550 | | if (j == segs.length - 1) { segs[j] = ""; } |
| 551 | | else { segs.splice(j, 1); j--; } |
| 552 | | }else if(j > 0 && !(j == 1 && segs[0] == "") && |
| 553 | | segs[j] == ".." && segs[j-1] != ".."){ |
| 554 | | |
| 555 | | if(j == (segs.length - 1)){ |
| 556 | | segs.splice(j, 1); segs[j - 1] = ""; |
| 557 | | }else{ |
| 558 | | segs.splice(j - 1, 2); j -= 2; |
| | 502 | }; |
| | 503 | |
| | 504 | (function(){ |
| | 505 | |
| | 506 | var ore = new RegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"); |
| | 507 | var ire = new RegExp("^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"); |
| | 508 | |
| | 509 | dojo._Url = function(/*dojo._Url||String...*/){ |
| | 510 | // summary: |
| | 511 | // Constructor to create an object representing a URL. |
| | 512 | // It is marked as private, since we might consider removing |
| | 513 | // or simplifying it. |
| | 514 | // description: |
| | 515 | // Each argument is evaluated in order relative to the next until |
| | 516 | // a canonical uri is produced. To get an absolute Uri relative to |
| | 517 | // the current document use: |
| | 518 | // new dojo._Url(document.baseURI, url) |
| | 519 | |
| | 520 | // TODO: support for IPv6, see RFC 2732 |
| | 521 | |
| | 522 | // resolve uri components relative to each other |
| | 523 | var n = null; |
| | 524 | var _a = arguments; |
| | 525 | var uri = _a[0]; |
| | 526 | for(var i = 1; i<_a.length; i++){ |
| | 527 | if(!_a[i]){ continue; } |
| | 528 | |
| | 529 | // Safari doesn't support this.constructor so we have to be explicit |
| | 530 | var relobj = new dojo._Url(_a[i]+""); |
| | 531 | var uriobj = new dojo._Url(uri+""); |
| | 532 | |
| | 533 | if( |
| | 534 | (relobj.path=="") && |
| | 535 | (!relobj.scheme) && |
| | 536 | (!relobj.authority) && |
| | 537 | (!relobj.query) |
| | 538 | ){ |
| | 539 | if(relobj.fragment != null){ |
| | 540 | uriobj.fragment = relobj.fragment; |
| | 541 | } |
| | 542 | relobj = uriobj; |
| | 543 | }else if(relobj.scheme == null){ |
| | 544 | relobj.scheme = uriobj.scheme; |
| | 545 | |
| | 546 | if(relobj.authority == null){ |
| | 547 | relobj.authority = uriobj.authority; |
| | 548 | |
| | 549 | if(relobj.path.charAt(0) != "/"){ |
| | 550 | var path = uriobj.path.substring(0, |
| | 551 | uriobj.path.lastIndexOf("/") + 1) + relobj.path; |
| | 552 | |
| | 553 | var segs = path.split("/"); |
| | 554 | for(var j = 0; j < segs.length; j++){ |
| | 555 | if(segs[j] == "."){ |
| | 556 | if (j == segs.length - 1) { segs[j] = ""; } |
| | 557 | else { segs.splice(j, 1); j--; } |
| | 558 | }else if(j > 0 && !(j == 1 && segs[0] == "") && |
| | 559 | segs[j] == ".." && segs[j-1] != ".."){ |
| | 560 | |
| | 561 | if(j == (segs.length - 1)){ |
| | 562 | segs.splice(j, 1); segs[j - 1] = ""; |
| | 563 | }else{ |
| | 564 | segs.splice(j - 1, 2); j -= 2; |
| | 565 | } |
| 567 | | uri = ""; |
| 568 | | if(relobj.scheme != null){ |
| 569 | | uri += relobj.scheme + ":"; |
| | 589 | this.uri = uri.toString(); |
| | 590 | |
| | 591 | // break the uri into its main components |
| | 592 | var r = this.uri.match(ore); |
| | 593 | |
| | 594 | this.scheme = r[2] || (r[1] ? "" : null); |
| | 595 | this.authority = r[4] || (r[3] ? "" : null); |
| | 596 | this.path = r[5]; // can never be undefined |
| | 597 | this.query = r[7] || (r[6] ? "" : null); |
| | 598 | this.fragment = r[9] || (r[8] ? "" : null); |
| | 599 | |
| | 600 | if(this.authority != null){ |
| | 601 | // server based naming authority |
| | 602 | r = this.authority.match(ire); |
| | 603 | |
| | 604 | this.user = r[3] || null; |
| | 605 | this.password = r[4] || null; |
| | 606 | this.host = r[5]; |
| | 607 | this.port = r[7] || null; |
| 571 | | if(relobj.authority != null){ |
| 572 | | uri += "//" + relobj.authority; |
| 573 | | } |
| 574 | | uri += relobj.path; |
| 575 | | if(relobj.query != null){ |
| 576 | | uri += "?" + relobj.query; |
| 577 | | } |
| 578 | | if(relobj.fragment != null){ |
| 579 | | uri += "#" + relobj.fragment; |
| 580 | | } |
| 581 | | } |
| 582 | | |
| 583 | | this.uri = uri.toString(); |
| 584 | | |
| 585 | | // break the uri into its main components |
| 586 | | var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$"; |
| 587 | | var r = this.uri.match(new RegExp(regexp)); |
| 588 | | |
| 589 | | this.scheme = r[2] || (r[1] ? "" : null); |
| 590 | | this.authority = r[4] || (r[3] ? "" : null); |
| 591 | | this.path = r[5]; // can never be undefined |
| 592 | | this.query = r[7] || (r[6] ? "" : null); |
| 593 | | this.fragment = r[9] || (r[8] ? "" : null); |
| 594 | | |
| 595 | | if(this.authority != null){ |
| 596 | | // server based naming authority |
| 597 | | regexp = "^((([^:]+:)?([^@]+))@)?([^:]*)(:([0-9]+))?$"; |
| 598 | | r = this.authority.match(new RegExp(regexp)); |
| 599 | | |
| 600 | | this.user = r[3] || null; |
| 601 | | this.password = r[4] || null; |
| 602 | | this.host = r[5]; |
| 603 | | this.port = r[7] || null; |
| 604 | | } |
| 605 | | |
| 606 | | this.toString = function(){ return this.uri; } |
| 607 | | } |
| | 609 | } |
| | 610 | |
| | 611 | dojo._Url.prototype.toString = function(){ return this.uri; }; |
| | 612 | })(); |