You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/02/25 21:59:13 UTC
spec commit: Support loading platform cordova.js files if available
Updated Branches:
refs/heads/cordova_js_platform_build [created] 9ec39e931
Support loading platform cordova.js files if available
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/9ec39e93
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/9ec39e93
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/9ec39e93
Branch: refs/heads/cordova_js_platform_build
Commit: 9ec39e9317b23941c0405841b3eaf5150682680d
Parents: 3905507
Author: Michal Mocny <mm...@gmail.com>
Authored: Mon Feb 25 15:59:04 2013 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Mon Feb 25 15:59:04 2013 -0500
----------------------------------------------------------------------
cordova.js | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/9ec39e93/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index ae29763..439f090 100644
--- a/cordova.js
+++ b/cordova.js
@@ -20,8 +20,25 @@
*/
var VERSION='2.5.0rc1';
+var PLAT = /Android/.exec(navigator.userAgent) ? 'android' : 'ios';
+
var scripts = document.getElementsByTagName('script');
-var cordovaPath = scripts[scripts.length - 1].src.replace('cordova.js', 'cordova-'+VERSION+'.js');
+var currentPath = scripts[scripts.length - 1].src;
+var platformCordovaPath = currentPath.replace("cordova.js", "cordova." + PLAT + ".js");
+var versionCordovaPath = currentPath.replace("cordova.js", "cordova-" + VERSION + ".js");
+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);
+})();
if (!window._doNotWriteCordovaScript) {
document.write('<script type="text/javascript" charset="utf-8" src="' + cordovaPath + '"></script>');