mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(platforms): allow overriding platform in querystring
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
(function(window, document, ionic) {
|
||||
|
||||
function getParameterByName(name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(location.search);
|
||||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
var IOS = 'ios';
|
||||
var ANDROID = 'android';
|
||||
var WINDOWS_PHONE = 'windowsphone';
|
||||
@@ -206,8 +213,12 @@
|
||||
* @private
|
||||
*/
|
||||
setPlatform: function(n) {
|
||||
var override;
|
||||
|
||||
if (typeof n != 'undefined' && n !== null && n.length) {
|
||||
platformName = n.toLowerCase();
|
||||
} else if(override = getParameterByName('ionicplatform')) {
|
||||
platformName = override;
|
||||
} else if (this.ua.indexOf('Android') > 0) {
|
||||
platformName = ANDROID;
|
||||
} else if (this.ua.indexOf('iPhone') > -1 || this.ua.indexOf('iPad') > -1 || this.ua.indexOf('iPod') > -1) {
|
||||
|
||||
Reference in New Issue
Block a user