cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [23/50] [abbrv] git commit: Consolidated minor code diffs, these will be refactored shortly into one class used by both wp7+wp8
Date Fri, 01 Nov 2013 01:27:18 GMT
Consolidated minor code diffs, these will be refactored shortly into one class used by both
wp7+wp8


Project: http://git-wip-us.apache.org/repos/asf/cordova-wp8/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-wp8/commit/465eed51
Tree: http://git-wip-us.apache.org/repos/asf/cordova-wp8/tree/465eed51
Diff: http://git-wip-us.apache.org/repos/asf/cordova-wp8/diff/465eed51

Branch: refs/heads/2.9.x
Commit: 465eed51ba2a6f503255079eadd46d91ed7f2a00
Parents: 7294c02
Author: purplecabbage <purplecabbage@gmail.com>
Authored: Mon Sep 16 16:55:29 2013 -0700
Committer: purplecabbage <purplecabbage@gmail.com>
Committed: Mon Sep 16 16:55:29 2013 -0700

----------------------------------------------------------------------
 wp7/template/cordovalib/XHRHelper.cs | 31 +++++++++++++------------------
 wp8/template/cordovalib/XHRHelper.cs | 10 +++++-----
 2 files changed, 18 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/465eed51/wp7/template/cordovalib/XHRHelper.cs
----------------------------------------------------------------------
diff --git a/wp7/template/cordovalib/XHRHelper.cs b/wp7/template/cordovalib/XHRHelper.cs
index 35b8bd3..d9945f3 100644
--- a/wp7/template/cordovalib/XHRHelper.cs
+++ b/wp7/template/cordovalib/XHRHelper.cs
@@ -30,7 +30,7 @@ namespace WPCordovaClassLib.CordovaLib
     if (!docDomain || docDomain.length === 0) {
 
         var aliasXHR = win.XMLHttpRequest;
-        
+
         var XHRShim = function() {};
         win.XMLHttpRequest = XHRShim;
         XHRShim.noConflict = aliasXHR;
@@ -48,7 +48,7 @@ namespace WPCordovaClassLib.CordovaLib
             withCredentials: false,
             _requestHeaders: null,
             open: function (reqType, uri, isAsync, user, password) {
-                
+
                 if (uri && uri.indexOf('http') === 0) {
                     if (!this.wrappedXHR) {
                         this.wrappedXHR = new aliasXHR();
@@ -120,6 +120,9 @@ namespace WPCordovaClassLib.CordovaLib
                 if (this.onreadystatechange) {
                     this.onreadystatechange();
                 }
+                if (this.readyState == XHRShim.DONE){
+                    this.onload && this.onload();
+                }
             },
             setRequestHeader: function(header, value) {
                 if (this.wrappedXHR) {
@@ -158,31 +161,28 @@ namespace WPCordovaClassLib.CordovaLib
             send: function(data) {
                 if (this.wrappedXHR) {
                     return this.wrappedXHR.send(data);
-                } 
+                }
                 else {
                     this.changeReadyState(XHRShim.OPENED);
                     var alias = this;
-                    var root = window.location.href; 
+
+                    var root = window.location.href.split('#')[0];   // remove hash
                     var basePath = root.substr(0,root.lastIndexOf('/')) + '/';
-                    
 
-                    var resolvedUrl = this._url.split('//').join('/');
+                    var resolvedUrl = this._url.split('//').join('/').split('#')[0]; // remove
hash
 
                     var wwwFolderPath = navigator.userAgent.indexOf('MSIE 9.0') > -1 ?
'app/www/' : 'www/';
 
-                    console.log('original resolvedUrl = ' + resolvedUrl);
-
                     if(resolvedUrl.indexOf('/') == 0) {
-                        console.log('removing leading /');
+                        //console.log('removing leading /');
                         resolvedUrl = resolvedUrl.substr(1);
                     }
 
+                    // handle special case where url is of form app/www but we are loaded
just from /www
                     if( resolvedUrl.indexOf('app/www') == 0 ) {
-                        
                         resolvedUrl = window.location.protocol  + wwwFolderPath + resolvedUrl.substr(7);
                     }
                     else if( resolvedUrl.indexOf('www') == 0) {
-
                         resolvedUrl = window.location.protocol  + wwwFolderPath + resolvedUrl.substr(4);
                     }
 
@@ -190,9 +190,6 @@ namespace WPCordovaClassLib.CordovaLib
                         resolvedUrl = basePath + resolvedUrl; // consider it relative
                     }
 
-                    console.log('sanitized resolvedUrl = ' + resolvedUrl);
-
-
                     var funk = function () {
                         window.__onXHRLocalCallback = function (responseCode, responseText)
{
                             alias.status = responseCode;
@@ -204,11 +201,9 @@ namespace WPCordovaClassLib.CordovaLib
                             }
 
                             alias.changeReadyState(XHRShim.DONE);
-                            alias.onload && alias.onload();
-                            
                         }
                         alias.changeReadyState(XHRShim.LOADING);
-                        window.external.Notify('XHRLOCAL/' + resolvedUrl); 
+                        window.external.Notify('XHRLOCAL/' + resolvedUrl);
                     }
                     if (this.isAsync) {
                         setTimeout(funk, 0);
@@ -254,7 +249,7 @@ namespace WPCordovaClassLib.CordovaLib
 
                 if (resource == null)
                 {
-                    // 404 ? 
+                    // 404 ?
                     Browser.InvokeScript("__onXHRLocalCallback", new string[] { "404" });
                     return true;
                 }

http://git-wip-us.apache.org/repos/asf/cordova-wp8/blob/465eed51/wp8/template/cordovalib/XHRHelper.cs
----------------------------------------------------------------------
diff --git a/wp8/template/cordovalib/XHRHelper.cs b/wp8/template/cordovalib/XHRHelper.cs
index 45c31ea..d9945f3 100644
--- a/wp8/template/cordovalib/XHRHelper.cs
+++ b/wp8/template/cordovalib/XHRHelper.cs
@@ -120,6 +120,9 @@ namespace WPCordovaClassLib.CordovaLib
                 if (this.onreadystatechange) {
                     this.onreadystatechange();
                 }
+                if (this.readyState == XHRShim.DONE){
+                    this.onload && this.onload();
+                }
             },
             setRequestHeader: function(header, value) {
                 if (this.wrappedXHR) {
@@ -171,16 +174,15 @@ namespace WPCordovaClassLib.CordovaLib
                     var wwwFolderPath = navigator.userAgent.indexOf('MSIE 9.0') > -1 ?
'app/www/' : 'www/';
 
                     if(resolvedUrl.indexOf('/') == 0) {
-                        console.log('removing leading /');
+                        //console.log('removing leading /');
                         resolvedUrl = resolvedUrl.substr(1);
                     }
 
+                    // handle special case where url is of form app/www but we are loaded
just from /www
                     if( resolvedUrl.indexOf('app/www') == 0 ) {
-
                         resolvedUrl = window.location.protocol  + wwwFolderPath + resolvedUrl.substr(7);
                     }
                     else if( resolvedUrl.indexOf('www') == 0) {
-
                         resolvedUrl = window.location.protocol  + wwwFolderPath + resolvedUrl.substr(4);
                     }
 
@@ -199,8 +201,6 @@ namespace WPCordovaClassLib.CordovaLib
                             }
 
                             alias.changeReadyState(XHRShim.DONE);
-                            alias.onload && alias.onload();
-
                         }
                         alias.changeReadyState(XHRShim.LOADING);
                         window.external.Notify('XHRLOCAL/' + resolvedUrl);


Mime
View raw message