cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject spec commit: [CB-2600] - added in a function that checks platform
Date Fri, 08 Mar 2013 22:57:48 GMT
Updated Branches:
  refs/heads/cb-2600-fix 723001bfa -> b39646aa6


[CB-2600] - added in a function that checks platform


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/b39646aa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/b39646aa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/b39646aa

Branch: refs/heads/cb-2600-fix
Commit: b39646aa65afcf768206b9c4aaf2f713ff613d38
Parents: 723001b
Author: timkim <timkim@apche.org>
Authored: Fri Mar 8 14:57:38 2013 -0800
Committer: timkim <timkim@apche.org>
Committed: Fri Mar 8 14:57:38 2013 -0800

----------------------------------------------------------------------
 cordova.js |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/b39646aa/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index 18d04a5..0b12d40 100644
--- a/cordova.js
+++ b/cordova.js
@@ -20,7 +20,7 @@
 */
 
 var VERSION='2.5.0';
-var PLAT = /Android/.exec(navigator.userAgent) ? 'android' : /BB10/.exec(navigator.userAgent)
? 'blackberry' : 'ios';
+var PLAT = getPlatform();
 
 var scripts = document.getElementsByTagName('script');
 var currentPath = scripts[scripts.length - 1].src;
@@ -51,3 +51,13 @@ function backHome() {
 	    window.history.go(-1);
 	}
 }
+
+function getPlatform(){
+    if(navigator.userAgent.indexOf("Android") > -1){
+        return 'android';
+    }else if(navigator.userAgent.indexOf("BB10") > -1 || navigator.userAgent.indexOf("PlayBook")
> -1 || navigator.userAgent.indexOf("BlackBerry") > -1) {
+        return 'blackberry';
+    }else if(navigator.userAgent.indexOf("iPhone") > -1 || navigator.userAgent.indexOf("iPod"){
+        return 'ios';
+    }
+}
\ No newline at end of file


Mime
View raw message