From 03574cf6d0f971f9731709606441d875026932e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Wed, 26 Oct 2016 18:05:12 +0800 Subject: [PATCH] MOBILE constant --- botanjs/src/System/Global.js | 12 ++++++++++++ botanjs/src/externs/System.Global.js | 3 +++ 2 files changed, 15 insertions(+) diff --git a/botanjs/src/System/Global.js b/botanjs/src/System/Global.js index 5be52eb..26dd169 100644 --- a/botanjs/src/System/Global.js +++ b/botanjs/src/System/Global.js @@ -12,8 +12,20 @@ var SECURE_HTTP = window.location.href.match( /^https:\/\// ); + var ua = navigator.userAgent; + var MOBILE = Boolean( + ~ua.indexOf( "Android" ) + || ~ua.indexOf( "webOS" ) + || ~ua.indexOf( "iPhone" ) + || ~ua.indexOf( "iPad" ) + || ~ua.indexOf( "iPod" ) + || ~ua.indexOf( "BlackBerry" ) + || ~ua.indexOf( "Windows Phone" ) + ); + ns[ NS_EXPORT ]( EX_READONLY_GETTER, "debug", debug ); ns[ NS_EXPORT ]( EX_CONST, "IE", IE ); ns[ NS_EXPORT ]( EX_CONST, "ALLOWED_ORIGINS", ALLOWED_ORIGINS ); ns[ NS_EXPORT ]( EX_CONST, "SECURE_HTTP", SECURE_HTTP ); + ns[ NS_EXPORT ]( EX_CONST, "MOBILE", MOBILE ); })(); diff --git a/botanjs/src/externs/System.Global.js b/botanjs/src/externs/System.Global.js index 75784c7..98559db 100644 --- a/botanjs/src/externs/System.Global.js +++ b/botanjs/src/externs/System.Global.js @@ -9,3 +9,6 @@ System.Global.IE; /** @type {Boolean} */ System.Global.SECURE_HTTP; + +/** @type {Boolean} */ +System.Global.MOBILE;