You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/11/30 23:06:03 UTC
[2/2] js commit: Local XHR fix for WP8 CB-1813. This is actually
commit: 35d32b75ac6e4901f3309316ea8578faf8fa8869
Local XHR fix for WP8 CB-1813. This is actually commit: 35d32b75ac6e4901f3309316ea8578faf8fa8869
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/c9f310fe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/c9f310fe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/c9f310fe
Branch: refs/heads/master
Commit: c9f310fe95b776b1ef73deb0fc837d8627057e84
Parents: c46b140
Author: purplecabbage <pu...@gmail.com>
Authored: Fri Nov 30 14:03:50 2012 -0800
Committer: purplecabbage <pu...@gmail.com>
Committed: Fri Nov 30 14:03:50 2012 -0800
----------------------------------------------------------------------
lib/windowsphone/plugin/windowsphone/XHRPatch.js | 53 ++++++++++++-----
1 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c9f310fe/lib/windowsphone/plugin/windowsphone/XHRPatch.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/XHRPatch.js b/lib/windowsphone/plugin/windowsphone/XHRPatch.js
index 9c9d62a..27fd21d 100644
--- a/lib/windowsphone/plugin/windowsphone/XHRPatch.js
+++ b/lib/windowsphone/plugin/windowsphone/XHRPatch.js
@@ -133,7 +133,7 @@ if (!docDomain || docDomain.length === 0) {
newUrl = newUrl.split(":/")[1];
}
// prefix relative urls to our physical root
- if(newUrl.indexOf("app/www/") < 0)
+ if(newUrl.indexOf("app/www/") < 0 && this.getContentLocation() == this.contentLocation.ISOLATED_STORAGE)
{
newUrl = "app/www/" + newUrl;
}
@@ -200,26 +200,51 @@ if (!docDomain || docDomain.length === 0) {
alias.onError(evt.code);
};
- var gotFile = function gotFile(file) {
- var reader = new FileReader();
- reader.onloadend = function (evt) {
- alias.onResult.apply(alias,[evt.target.result]);
+ if (alias.getContentLocation() == this.contentLocation.RESOURCES) {
+ var exec = require('cordova/exec');
+ exec(function(result) {
+ alias.onResult.apply(alias, [result]);
+ },
+ fail,
+ "File", "readResourceAsText", [alias._url]
+ );
+ }
+ else {
+ var gotFile = function gotFile(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ alias.onResult.apply(alias,[evt.target.result]);
+ };
+ reader.readAsText(file);
};
- reader.readAsText(file);
- };
- var gotEntry = function gotEntry(entry) {
- entry.file(gotFile, fail);
- };
+ var gotEntry = function gotEntry(entry) {
+ entry.file(gotFile, fail);
+ };
- var gotFS = function gotFS(fs) {
- fs.root.getFile(alias._url, null, gotEntry, fail);
- };
+ var gotFS = function gotFS(fs) {
+ fs.root.getFile(alias._url, null, gotEntry, fail);
+ };
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+ }
+ }
+ },
+ getContentLocation: function () {
+ if (window.contentLocation === undefined) {
+ window.contentLocation = (navigator.userAgent.toUpperCase().indexOf('MSIE 10') > -1) ?
+ this.contentLocation.RESOURCES : this.contentLocation.ISOLATED_STORAGE;
}
+
+ return window.contentLocation;
},
+
+ contentLocation:{
+ ISOLATED_STORAGE: 0,
+ RESOURCES: 1
+ },
+
status: 404
};
} // if doc domain