Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support loading platform cordova.js files if available

  • Loading branch information...
commit 9ec39e9317b23941c0405841b3eaf5150682680d 1 parent 3905507
Michal Mocny mmocny authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 cordova.js
19 cordova.js
View
@@ -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>');
Please sign in to comment.
Something went wrong with that request. Please try again.