You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2013/03/08 23:29:22 UTC
spec commit: Fixing cordova.js to work when the platform specific
file doesn't exist as well as adding BB10 support
Updated Branches:
refs/heads/cb-2600-fix [created] 723001bfa
Fixing cordova.js to work when the platform specific file doesn't exist as well as adding BB10 support
Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/723001bf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/723001bf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/723001bf
Branch: refs/heads/cb-2600-fix
Commit: 723001bfad968c9cce027b6a04ae4d16f8cac68b
Parents: 49306c9
Author: Jeffrey Heifetz <jh...@rim.com>
Authored: Mon Mar 4 11:22:09 2013 -0500
Committer: Jeffrey Heifetz <jh...@rim.com>
Committed: Mon Mar 4 11:23:50 2013 -0500
----------------------------------------------------------------------
cordova.js | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/723001bf/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index 88aa5ac..18d04a5 100644
--- a/cordova.js
+++ b/cordova.js
@@ -20,7 +20,7 @@
*/
var VERSION='2.5.0';
-var PLAT = /Android/.exec(navigator.userAgent) ? 'android' : 'ios';
+var PLAT = /Android/.exec(navigator.userAgent) ? 'android' : /BB10/.exec(navigator.userAgent) ? 'blackberry' : 'ios';
var scripts = document.getElementsByTagName('script');
var currentPath = scripts[scripts.length - 1].src;
@@ -29,15 +29,14 @@ var versionCordovaPath = currentPath.replace("cordova.js", "cordova-" + VERSION
var cordovaPath;
(function() {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", platformCordovaPath, false);
- xhr.onreadystatechange = function() {
- if (this.readyState != this.DONE) {
- return;
- }
- cordovaPath = (this.responseText.length > 0) ? platformCordovaPath : versionCordovaPath;
- };
- xhr.send(null);
+ try {
+ var xhr = new XMLHttpRequest();
+ xhr.open("HEAD", platformCordovaPath, false);
+ xhr.send();
+ cordovaPath = (xhr.responseText.length > 0) ? platformCordovaPath : versionCordovaPath;
+ } catch (e) {
+ cordovaPath = versionCordovaPath;
+ }
})();
if (!window._doNotWriteCordovaScript) {