Updated Branches: refs/heads/master 4a6749bde -> e2bd12a60
[CB-2734] added PLAT support for WP7, WP8, Windows8 and allow Windows8 to createElement include cordovaPath. Some minor refactor to remove if/else ladder and ease future platform addition. 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/e2bd12a6 Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/e2bd12a6 Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/e2bd12a6 Branch: refs/heads/master Commit: e2bd12a60537441895730f52cb757e3070b6472c Parents: 4a6749b Author: Jesse MacFadyen <[email protected]> Authored: Tue May 28 11:49:48 2013 -0700 Committer: Jesse MacFadyen <[email protected]> Committed: Tue May 28 11:49:48 2013 -0700 ---------------------------------------------------------------------- cordova-incl.js | 45 +++++++++++++++++++++++++++++---------------- 1 files changed, 29 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/e2bd12a6/cordova-incl.js ---------------------------------------------------------------------- diff --git a/cordova-incl.js b/cordova-incl.js index c624996..a82c590 100644 --- a/cordova-incl.js +++ b/cordova-incl.js @@ -20,15 +20,22 @@ */ var PLAT; -if (/Android/.exec(navigator.userAgent)) { - PLAT = 'android'; -} else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) { - PLAT = 'ios'; -} else if (/(BB10)/.exec(navigator.userAgent)) { - PLAT = 'blackberry10'; -} else if (/(PlayBook)|(BlackBerry)/.exec(navigator.userAgent)) { - PLAT = 'blackberry'; -} +(function getPlatform() { + var platforms = { + android: /Android/, + ios: /(iPad)|(iPhone)|(iPod)/, + blackberry10: /(BB10)/, + blackberry: /(PlayBook)|(BlackBerry)/, + windows8: /MSAppHost/, + windowsphone: /Windows Phone/ + }; + for (var key in platforms) { + if (platforms[key].exec(navigator.userAgent)) { + PLAT = key; + break; + } + } +})(); var scripts = document.getElementsByTagName('script'); var currentPath = scripts[scripts.length - 1].src; @@ -59,14 +66,20 @@ if (PLAT) { } if (!window._doNotWriteCordovaScript) { - document.write('<script type="text/javascript" charset="utf-8" src="' + cordovaPath + '"></script>'); + if (PLAT != "windows8") { + document.write('<script type="text/javascript" charset="utf-8" src="' + cordovaPath + '"></script>'); + } else { + var s = document.createElement('script'); + s.src = cordovaPath; + document.head.appendChild(s); + } } function backHome() { - if (window.device && device.platform && device.platform.toLowerCase() == 'android') { - navigator.app.backHistory(); - } - else { - window.history.go(-1); - } + if (window.device && device.platform && device.platform.toLowerCase() == 'android') { + navigator.app.backHistory(); + } + else { + window.history.go(-1); + } }
