| 56 | | send: function(facade){ |
| | 56 | |
| | 57 | send: function(/*Object*/facade){ |
| | 58 | //summary: starts the xdomain request using the provided facade. |
| | 59 | //This method first does some init work, then delegates to _realSend. |
| | 60 | |
| | 61 | var url = this.xipClientUrl; |
| | 62 | //Make sure we are not dealing with javascript urls, just to be safe. |
| | 63 | if(url.split(":")[0].match(/javascript/i) || facade._ifpServerUrl.split(":")[0].match(/javascript/i)){ |
| | 64 | return; |
| | 65 | } |
| | 66 | |
| | 67 | //Make xip_client a full URL. |
| | 68 | var colonIndex = url.indexOf(":"); |
| | 69 | var slashIndex = url.indexOf("/"); |
| | 70 | if(colonIndex == -1 || slashIndex < colonIndex){ |
| | 71 | //No colon or we are starting with a / before a colon, so we need to make a full URL. |
| | 72 | var loc = window.location.href; |
| | 73 | if(slashIndex == 0){ |
| | 74 | //Have a full path, just need the domain. |
| | 75 | url = loc.substring(0, loc.indexOf("/", 9)) + url; //Using 9 to get past http(s):// |
| | 76 | }else{ |
| | 77 | url = loc.substring(0, (loc.lastIndexOf("/") + 1)) + url; |
| | 78 | } |
| | 79 | } |
| | 80 | this.fullXipClientUrl = url; |
| | 81 | |
| | 82 | //Set up an HTML5 messaging listener if postMessage exists. |
| | 83 | //As of this writing, this is only useful to get Opera 9.25+ to work. |
| | 84 | if(typeof document.postMessage != "undefined"){ |
| | 85 | document.addEventListener("message", dojo.hitch(this, this.fragmentReceivedEvent), false); |
| | 86 | } |
| | 87 | |
| | 88 | //Now that we did first time init, always use the realSend method. |
| | 89 | this.send = this._realSend; |
| | 90 | return this._realSend(facade); //Object |
| | 91 | }, |
| | 92 | |
| | 93 | _realSend: function(facade){ |
| | 94 | //summary: starts the actual xdomain request using the provided facade. |
| 59 | | var url = this.xipClientUrl; |
| 60 | | |
| 61 | | //Make sure we are not dealing with javascript urls, just to be safe. |
| 62 | | if(!url.split(":")[0].match(/javascript/i) && !facade._ifpServerUrl.split(":")[0].match(/javascript/i)){ |
| 63 | | //Make xip_client a full URL. |
| 64 | | var colonIndex = url.indexOf(":"); |
| 65 | | var slashIndex = url.indexOf("/"); |
| 66 | | if(colonIndex == -1 || slashIndex < colonIndex){ |
| 67 | | //No colon or we are starting with a / before a colon, so we need to make a full URL. |
| 68 | | var loc = window.location.href; |
| 69 | | if(slashIndex == 0){ |
| 70 | | //Have a full path, just need the domain. |
| 71 | | url = loc.substring(0, loc.indexOf("/", 9)) + url; //Using 9 to get past http(s):// |
| 72 | | }else{ |
| 73 | | url = loc.substring(0, (loc.lastIndexOf("/") + 1)) + url; |
| 74 | | } |
| 75 | | } |
| 76 | | |
| 77 | | var frameUrl = facade._ifpServerUrl + "#0:init:id=" + stateId + "&client=" |
| 78 | | + encodeURIComponent(url) + "&callback=" + encodeURIComponent(this._callbackName); |
| 79 | | |
| 80 | | this._state[stateId] = { |
| 81 | | facade: facade, |
| 82 | | stateId: stateId, |
| 83 | | clientFrame: dojo.io.iframe.create(stateId, "", frameUrl), |
| 84 | | isSending: false, |
| 85 | | serverUrl: facade._ifpServerUrl, |
| 86 | | requestData: null, |
| 87 | | responseMessage: "", |
| 88 | | requestParts: [], |
| 89 | | idCounter: 1, |
| 90 | | partIndex: 0, |
| 91 | | serverWindow: null |
| 92 | | }; |
| 93 | | |
| 94 | | return stateId; |
| 95 | | } |
| | 97 | |
| | 98 | var frameUrl = facade._ifpServerUrl + "#0:init:id=" + stateId + "&client=" |
| | 99 | + encodeURIComponent(this.fullXipClientUrl) + "&callback=" + encodeURIComponent(this._callbackName); |
| | 100 | |
| | 101 | this._state[stateId] = { |
| | 102 | facade: facade, |
| | 103 | stateId: stateId, |
| | 104 | clientFrame: dojo.io.iframe.create(stateId, "", frameUrl), |
| | 105 | isSending: false, |
| | 106 | serverUrl: facade._ifpServerUrl, |
| | 107 | requestData: null, |
| | 108 | responseMessage: "", |
| | 109 | requestParts: [], |
| | 110 | idCounter: 1, |
| | 111 | partIndex: 0, |
| | 112 | serverWindow: null |
| | 113 | }; |
| | 114 | |
| | 115 | return stateId; //Object |