incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/4] git commit: updated phonegap.js to include XHR updates
Date Wed, 25 Jan 2012 21:47:48 GMT
Updated Branches:
  refs/heads/master 1254b239e -> d78fafbb9


updated phonegap.js to include XHR updates


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/d78fafbb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/d78fafbb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/d78fafbb

Branch: refs/heads/master
Commit: d78fafbb9a6eaeb23170ffc456e6678aa739b8ed
Parents: 164b6c8
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Wed Jan 25 13:24:26 2012 -0800
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Wed Jan 25 13:24:26 2012 -0800

----------------------------------------------------------------------
 framework/js/BuildJSConcat.js       |    2 +-
 framework/js/phonegap-1.3.0-core.js |  236 ++-
 framework/js/phonegap-1.3.0.js      |  362 ++-
 framework/js/phonegap-1.4.0-core.js | 2579 ++++++++++++++++++++
 framework/js/phonegap-1.4.0.js      | 3794 ++++++++++++++++++++++++++++++
 5 files changed, 6770 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d78fafbb/framework/js/BuildJSConcat.js
----------------------------------------------------------------------
diff --git a/framework/js/BuildJSConcat.js b/framework/js/BuildJSConcat.js
index 2efa1be..c8943e3 100644
--- a/framework/js/BuildJSConcat.js
+++ b/framework/js/BuildJSConcat.js
@@ -1,6 +1,6 @@
 // JSConcat
 
-var versionStr = "1.3.0";
+var versionStr = "1.4.0";
 var allSourceFiles = [
 	"disclaimer.txt",
 	"phonegap.js.base",

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d78fafbb/framework/js/phonegap-1.3.0-core.js
----------------------------------------------------------------------
diff --git a/framework/js/phonegap-1.3.0-core.js b/framework/js/phonegap-1.3.0-core.js
index 0c76250..e22fd86 100644
--- a/framework/js/phonegap-1.3.0-core.js
+++ b/framework/js/phonegap-1.3.0-core.js
@@ -718,14 +718,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("device")) {
 PhoneGap.addResource("device");
@@ -794,7 +799,20 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
     });
 }
 
-
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
 // this is a WP7 Only implementation of the Storage API for use in webpages loaded from the
local file system
 // inside phonegap application.
 // there is a native implementation which is backing this and providing the persistance of
values.
@@ -1002,14 +1020,19 @@ if(!window.localStorage)
 })();};
 
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("file")) {
 PhoneGap.addResource("file");
@@ -2044,14 +2067,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function () {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("filetransfer")) {
 PhoneGap.addResource("filetransfer");
@@ -2141,14 +2169,19 @@ var FileUploadOptions = function(fileKey, fileName, mimeType, params)
{
 };
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("network")) {
 PhoneGap.addResource("network");
@@ -2208,6 +2241,7 @@ Connection.CELL_2G = "2g";
 Connection.CELL_3G = "3g";
 Connection.CELL_4G = "4g";
 Connection.NONE = "none";
+Connection.CELL = "cellular";
 
 /**
  * Get connection info
@@ -2230,14 +2264,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2011, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("notification")) {
 PhoneGap.addResource("notification");
@@ -2359,12 +2398,27 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 });
 }
 
-/**
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+                          
+/**
  * @author purplecabbage
  */
                           
 (function(win,doc){
 
+
     doc.addEventListener("DOMContentLoaded",function()
     {
     	var docDomain = null;
@@ -2384,26 +2438,34 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 		
 			win.XMLHttpRequest = function(){};
 		
-			var UNSENT = 0;
-			var OPENED = 1;
-			var HEADERS_RECEIVED = 2;
-			var LOADING = 3;
-			var DONE = 4;
+			win.XMLHttpRequest.UNSENT = 0;
+			win.XMLHttpRequest.OPENED = 1;
+			win.XMLHttpRequest.HEADERS_RECEIVED = 2;
+			win.XMLHttpRequest.LOADING = 3;
+			win.XMLHttpRequest.DONE = 4;
 	          
 			win.XMLHttpRequest.prototype =
 			{
+                UNSENT:0,
+                OPENED:1,
+                HEADERS_RECEIVED:2,
+                LOADING:3,
+                DONE:4,
+
 				isAsync:false,
 				onreadystatechange:null,
-				readyState:UNSENT,
+				readyState:0,
+                _url:"",
 				open:function(reqType,uri,isAsync,user,password)
 				{
-					//console.log("XMLHttpRequest.open " + uri);
+					console.log("XMLHttpRequest.open " + uri);
 					if(uri && uri.indexOf("http") == 0)
 					{
 						if(!this.wrappedXHR)
 						{
-							//console.log("using wrapped XHR");
 							this.wrappedXHR = new aliasXHR();
+                            var self = this;
+
 							Object.defineProperty( this, "status", { get: function() {
 								return this.wrappedXHR.status;										
 							}});
@@ -2413,32 +2475,40 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 							Object.defineProperty( this, "statusText", { get: function() {
 								return this.wrappedXHR.statusText;										
 							}});
-							Object.defineProperty( this, "responseXML", { get: function() {
+
+                            Object.defineProperty( this, "responseXML", { get: function()
{
 								return this.wrappedXHR.responseXML;										
-							}});
-							
-							this.getResponseHeader = function() {
-								return this.wrappedXHR.getResponseHeader.apply(this.wrappedXHR,arguments);
+							}});    
+                        
+							this.getResponseHeader = function(header) {
+								return this.wrappedXHR.getResponseHeader(header);
 							};
 							this.getAllResponseHeaders = function() {
-								return this.wrappedXHR.getAllResponseHeaders.apply(this.wrappedXHR,arguments);
+								return this.wrappedXHR.getAllResponseHeaders();
 							};
 							
-							this.wrappedXHR.onreadystatechange = this.onreadystatechange;
+							this.wrappedXHR.onreadystatechange = function()
+                            {
+                                self.changeReadyState(self.wrappedXHR.readyState);
+                            };
 						}
 						return this.wrappedXHR.open(reqType,uri,isAsync,user,password);
 					}
 					else
 					{
+                        // x-wmapp1://app/www/page2.html
                         // need to work some magic on the actual url/filepath
-		                var lastFileSlash = uri.lastIndexOf("\\");
-		                var newUrl =  "app/" + uri.substr(lastFileSlash + 1);
+		                var newUrl =  uri;
+                        if(newUrl.indexOf(":/") > -1)
+                        {
+                            newUrl = newUrl.split(":/")[1];
+                        }
+
 		                if(newUrl.lastIndexOf("/") === newUrl.length - 1)
 		                {
-		                    newUrl += "index.html"; // default page is index.html, when call is
to a dir/
+		                    newUrl += "index.html"; // default page is index.html, when call is
to a dir/ ( why not ...? )
 		                }
-						navigator.fileMgr.readAsText(newUrl,"UTF-8",this.onResult.bind(this),this.onError.bind(this));
-		                this.changeReadyState(OPENED);
+                        this._url = newUrl;
 					}
 				},
 				statusText:"",
@@ -2450,41 +2520,55 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 						this.onreadystatechange();	
 					}
 				},
-				getResponseHeader:function()
+				getResponseHeader:function(header)
 				{
-					return "";
+                    return this.wrappedXHR ?  this.wrappedXHR.getResponseHeader(header) :
"";
 				},
 				getAllResponseHeaders:function()
 				{
-					return "";
+					return this.wrappedXHR ?  this.wrappedXHR.getAllResponseHeaders() : "";
 				},
 				responseText:"",
-				responseXML:function()
-				{
-					return new Document(this.responseText);
-				},
+				responseXML:"",
 				onResult:function(res)
 				{
 					this.status = 200;
 					this.responseText = res;
-					this.changeReadyState(DONE);
+
+                    Object.defineProperty( this, "responseXML", { get: function() {
+                        var parser = new DOMParser();
+						return parser.parseFromString(this.responseText,"text/xml");										
+					}}); 
+					this.changeReadyState(this.DONE);
 				},
 				onError:function(err)
 				{
-					//console.log("Received Error from FileAPI :: " + err);
+					console.log("Wrapped XHR received Error from FileAPI :: " + err);
 					this.status = 404;
-					this.changeReadyState(DONE);
+					this.changeReadyState(this.DONE);
 				},
+
+                abort:function()
+                {
+					if(this.wrappedXHR)
+					{
+						return this.wrappedXHR.abort();
+					}
+                },
 				
 				send:function(data)
 				{
 					if(this.wrappedXHR)
 					{
-						return this.wrappedXHR.send.apply(this.wrappedXHR,arguments);
+						return this.wrappedXHR.send(data);
 					}
+                    else
+                    {
+                        this.changeReadyState(this.OPENED);
+                        navigator.fileMgr.readAsText(this._url,"UTF-8",this.onResult.bind(this),this.onError.bind(this));
+                    }
 				},
-				status:404,
-				responseText:"empty"
+				status:404
 			};		  
 	    } // if doc domain 
 
@@ -2493,5 +2577,3 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 		  
 })(window,document);
 
-          
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d78fafbb/framework/js/phonegap-1.3.0.js
----------------------------------------------------------------------
diff --git a/framework/js/phonegap-1.3.0.js b/framework/js/phonegap-1.3.0.js
index 70876df..9a997bb 100644
--- a/framework/js/phonegap-1.3.0.js
+++ b/framework/js/phonegap-1.3.0.js
@@ -656,14 +656,19 @@ PhoneGap.fireEvent = function(_targ,evtName)
 }
 	
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2011, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("accelerometer")) 
 {
@@ -801,14 +806,19 @@ function()
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("camera")) {
 PhoneGap.addResource("camera");
@@ -948,14 +958,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("capture")) {
 PhoneGap.addResource("capture");
@@ -1150,14 +1165,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function () {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("compass")) {
 PhoneGap.addResource("compass");
@@ -1300,14 +1320,19 @@ function()
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("contact")) {
 PhoneGap.addResource("contact");
@@ -1675,14 +1700,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("device")) {
 PhoneGap.addResource("device");
@@ -1751,7 +1781,20 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
     });
 }
 
-
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+
 // this is a WP7 Only implementation of the Storage API for use in webpages loaded from the
local file system
 // inside phonegap application.
 // there is a native implementation which is backing this and providing the persistance of
values.
@@ -1959,14 +2002,19 @@ if(!window.localStorage)
 })();};
 
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("file")) {
 PhoneGap.addResource("file");
@@ -3001,14 +3049,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function () {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("filetransfer")) {
 PhoneGap.addResource("filetransfer");
@@ -3098,14 +3151,19 @@ var FileUploadOptions = function(fileKey, fileName, mimeType, params)
{
 };
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("media")) {
 PhoneGap.addResource("media");
@@ -3326,14 +3384,19 @@ PhoneGapMediaonStatus = function (args) {
 
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("network")) {
 PhoneGap.addResource("network");
@@ -3393,6 +3456,7 @@ Connection.CELL_2G = "2g";
 Connection.CELL_3G = "3g";
 Connection.CELL_4G = "4g";
 Connection.NONE = "none";
+Connection.CELL = "cellular";
 
 /**
  * Get connection info
@@ -3415,14 +3479,19 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 });
 }
 
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- *
- * Copyright (c) 2005-2011, Nitobi Software Inc.
- * Copyright (c) 2010-2011, IBM Corporation
- * Copyright (c) 2011, Microsoft Corporation
- */
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
 
 if (!PhoneGap.hasResource("notification")) {
 PhoneGap.addResource("notification");
@@ -3544,12 +3613,27 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 });
 }
 
-/**
+/*  
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+*/
+                          
+/**
  * @author purplecabbage
  */
                           
 (function(win,doc){
 
+
     doc.addEventListener("DOMContentLoaded",function()
     {
     	var docDomain = null;
@@ -3569,26 +3653,34 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 		
 			win.XMLHttpRequest = function(){};
 		
-			var UNSENT = 0;
-			var OPENED = 1;
-			var HEADERS_RECEIVED = 2;
-			var LOADING = 3;
-			var DONE = 4;
+			win.XMLHttpRequest.UNSENT = 0;
+			win.XMLHttpRequest.OPENED = 1;
+			win.XMLHttpRequest.HEADERS_RECEIVED = 2;
+			win.XMLHttpRequest.LOADING = 3;
+			win.XMLHttpRequest.DONE = 4;
 	          
 			win.XMLHttpRequest.prototype =
 			{
+                UNSENT:0,
+                OPENED:1,
+                HEADERS_RECEIVED:2,
+                LOADING:3,
+                DONE:4,
+
 				isAsync:false,
 				onreadystatechange:null,
-				readyState:UNSENT,
+				readyState:0,
+                _url:"",
 				open:function(reqType,uri,isAsync,user,password)
 				{
-					//console.log("XMLHttpRequest.open " + uri);
+					console.log("XMLHttpRequest.open " + uri);
 					if(uri && uri.indexOf("http") == 0)
 					{
 						if(!this.wrappedXHR)
 						{
-							//console.log("using wrapped XHR");
 							this.wrappedXHR = new aliasXHR();
+                            var self = this;
+
 							Object.defineProperty( this, "status", { get: function() {
 								return this.wrappedXHR.status;										
 							}});
@@ -3598,32 +3690,40 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 							Object.defineProperty( this, "statusText", { get: function() {
 								return this.wrappedXHR.statusText;										
 							}});
-							Object.defineProperty( this, "responseXML", { get: function() {
+
+                            Object.defineProperty( this, "responseXML", { get: function()
{
 								return this.wrappedXHR.responseXML;										
-							}});
-							
-							this.getResponseHeader = function() {
-								return this.wrappedXHR.getResponseHeader.apply(this.wrappedXHR,arguments);
+							}});    
+                        
+							this.getResponseHeader = function(header) {
+								return this.wrappedXHR.getResponseHeader(header);
 							};
 							this.getAllResponseHeaders = function() {
-								return this.wrappedXHR.getAllResponseHeaders.apply(this.wrappedXHR,arguments);
+								return this.wrappedXHR.getAllResponseHeaders();
 							};
 							
-							this.wrappedXHR.onreadystatechange = this.onreadystatechange;
+							this.wrappedXHR.onreadystatechange = function()
+                            {
+                                self.changeReadyState(self.wrappedXHR.readyState);
+                            };
 						}
 						return this.wrappedXHR.open(reqType,uri,isAsync,user,password);
 					}
 					else
 					{
+                        // x-wmapp1://app/www/page2.html
                         // need to work some magic on the actual url/filepath
-		                var lastFileSlash = uri.lastIndexOf("\\");
-		                var newUrl =  "app/" + uri.substr(lastFileSlash + 1);
+		                var newUrl =  uri;
+                        if(newUrl.indexOf(":/") > -1)
+                        {
+                            newUrl = newUrl.split(":/")[1];
+                        }
+
 		                if(newUrl.lastIndexOf("/") === newUrl.length - 1)
 		                {
-		                    newUrl += "index.html"; // default page is index.html, when call is
to a dir/
+		                    newUrl += "index.html"; // default page is index.html, when call is
to a dir/ ( why not ...? )
 		                }
-						navigator.fileMgr.readAsText(newUrl,"UTF-8",this.onResult.bind(this),this.onError.bind(this));
-		                this.changeReadyState(OPENED);
+                        this._url = newUrl;
 					}
 				},
 				statusText:"",
@@ -3635,41 +3735,55 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 						this.onreadystatechange();	
 					}
 				},
-				getResponseHeader:function()
+				getResponseHeader:function(header)
 				{
-					return "";
+                    return this.wrappedXHR ?  this.wrappedXHR.getResponseHeader(header) :
"";
 				},
 				getAllResponseHeaders:function()
 				{
-					return "";
+					return this.wrappedXHR ?  this.wrappedXHR.getAllResponseHeaders() : "";
 				},
 				responseText:"",
-				responseXML:function()
-				{
-					return new Document(this.responseText);
-				},
+				responseXML:"",
 				onResult:function(res)
 				{
 					this.status = 200;
 					this.responseText = res;
-					this.changeReadyState(DONE);
+
+                    Object.defineProperty( this, "responseXML", { get: function() {
+                        var parser = new DOMParser();
+						return parser.parseFromString(this.responseText,"text/xml");										
+					}}); 
+					this.changeReadyState(this.DONE);
 				},
 				onError:function(err)
 				{
-					//console.log("Received Error from FileAPI :: " + err);
+					console.log("Wrapped XHR received Error from FileAPI :: " + err);
 					this.status = 404;
-					this.changeReadyState(DONE);
+					this.changeReadyState(this.DONE);
 				},
+
+                abort:function()
+                {
+					if(this.wrappedXHR)
+					{
+						return this.wrappedXHR.abort();
+					}
+                },
 				
 				send:function(data)
 				{
 					if(this.wrappedXHR)
 					{
-						return this.wrappedXHR.send.apply(this.wrappedXHR,arguments);
+						return this.wrappedXHR.send(data);
 					}
+                    else
+                    {
+                        this.changeReadyState(this.OPENED);
+                        navigator.fileMgr.readAsText(this._url,"UTF-8",this.onResult.bind(this),this.onError.bind(this));
+                    }
 				},
-				status:404,
-				responseText:"empty"
+				status:404
 			};		  
 	    } // if doc domain 
 
@@ -3678,5 +3792,3 @@ PhoneGap.onPhoneGapInit.subscribeOnce(function() {
 		  
 })(window,document);
 
-          
-


Mime
View raw message