/* *******************************************1// Copyright 2010-2015, Anthony Hand2//3// BETA NOTICE4// Previous versions of the JavaScript code for MobileESP were 'regular'5// JavaScript. The strength of it was that it was really easy to code and use.6// Unfortunately, regular JavaScript means that all variables and functions7// are in the global namespace. There can be collisions with other code libraries8// which may have similar variable or function names. Collisions cause bugs as each9// library changes a variable's definition or functionality unexpectedly.10// As a result, we thought it wise to switch to an "object oriented" style of code.11// This 'literal notation' technique keeps all MobileESP variables and functions fully self-contained.12// It avoids potential for collisions with other JavaScript libraries.13// This technique allows the developer continued access to any desired function or property.14//15// Please send feedback to project founder Anthony Hand: [email protected]16//17//18// File version 2015.05.13 (May 13, 2015)19// Updates:20// - Moved MobileESP to GitHub. https://github.com/ahand/mobileesp21// - Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet.22// - Removed DetectOperaAndroidPhone(). This method is no longer reliable.23// - Removed DetectOperaAndroidTablet(). This method is no longer reliable.24// - Added support for Windows Phone 10: variable and DetectWindowsPhone10()25// - Updated DetectWindowsPhone() to include WP10.26// - Added support for Firefox OS.27// - A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()28// - NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.29// - Added support for Sailfish OS. Not enough info to add a tablet detection method at this time.30// - A variable plus DetectSailfish(), DetectSailfishPhone()31// - Added support for Ubuntu Mobile OS.32// - DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()33// - Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps.34// - One variable for Samsung Tizen TVs, plus DetectTizenTV()35// - One variable for LG WebOS TVs, plus DetectWebOSTV()36// - Updated DetectTizen(). Now tests for “mobile” to disambiguate from Samsung Smart TVs37// - Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.38// - Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet.39// - Updated DetectAndroidPhone().40// - Updated internal detection code for Android.41// - No longer has a special test case for the HTC Flyer tablet.42// - Checks against DetectOperaMobile() on Android and reports here if relevant.43// - Updated DetectAndroidTablet().44// - No longer has a special test case for the HTC Flyer tablet.45// - Checks against DetectOperaMobile() on Android to exclude it from here.46// - DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones.47// - DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.48// - DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile.49// - DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile.50// - DetectSmartphone(): Added support for Meego phones.51// - Reorganized DetectMobileQuick(). Moved the following to DetectMobileLong():52// - DetectDangerHiptop(), DetectMaemoTablet(), DetectSonyMylo(), DetectArchos()53//54//55//56// LICENSE INFORMATION57// Licensed under the Apache License, Version 2.0 (the "License");58// you may not use this file except in compliance with the License.59// You may obtain a copy of the License at60// http://www.apache.org/licenses/LICENSE-2.061// Unless required by applicable law or agreed to in writing,62// software distributed under the License is distributed on an63// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,64// either express or implied. See the License for the specific65// language governing permissions and limitations under the License.66//67//68// ABOUT THIS PROJECT69// Project Owner: Anthony Hand70// Email: [email protected]71// Web Site: http://www.mobileesp.com72// Source Files: https://github.com/ahand/mobileesp73//74// Versions of this code are available for:75// PHP, JavaScript, Java, ASP.NET (C#), Ruby and others76//77//78// WARNING:79// These JavaScript-based device detection features may ONLY work80// for the newest generation of smartphones, such as the iPhone,81// Android and Palm WebOS devices.82// These device detection features may NOT work for older smartphones83// which had poor support for JavaScript, including84// older BlackBerry, PalmOS, and Windows Mobile devices.85// Additionally, because JavaScript support is extremely poor among86// 'feature phones', these features may not work at all on such devices.87// For better results, consider using a server-based version of this code,88// such as Java, APS.NET, PHP, or Ruby.89//90// *******************************************91*/929394var MobileEsp = {9596//GLOBALLY USEFUL VARIABLES97//Note: These values are set automatically during the Init function.98//Stores whether we're currently initializing the most popular functions.99initCompleted : false,100isWebkit : false, //Stores the result of DetectWebkit()101isMobilePhone : false, //Stores the result of DetectMobileQuick()102isIphone : false, //Stores the result of DetectIphone()103isAndroid : false, //Stores the result of DetectAndroid()104isAndroidPhone : false, //Stores the result of DetectAndroidPhone()105isTierTablet : false, //Stores the result of DetectTierTablet()106isTierIphone : false, //Stores the result of DetectTierIphone()107isTierRichCss : false, //Stores the result of DetectTierRichCss()108isTierGenericMobile : false, //Stores the result of DetectTierOtherPhones()109110//INTERNALLY USED DETECTION STRING VARIABLES111engineWebKit : 'webkit',112deviceIphone : 'iphone',113deviceIpod : 'ipod',114deviceIpad : 'ipad',115deviceMacPpc : 'macintosh', //Used for disambiguation116117deviceAndroid : 'android',118deviceGoogleTV : 'googletv',119120deviceWinPhone7 : 'windows phone os 7',121deviceWinPhone8 : 'windows phone 8',122deviceWinPhone10 : 'windows phone 10',123deviceWinMob : 'windows ce',124deviceWindows : 'windows',125deviceIeMob : 'iemobile',126devicePpc : 'ppc', //Stands for PocketPC127enginePie : 'wm5 pie', //An old Windows Mobile128129deviceBB : 'blackberry',130deviceBB10 : 'bb10', //For the new BB 10 OS131vndRIM : 'vnd.rim', //Detectable when BB devices emulate IE or Firefox132deviceBBStorm : 'blackberry95', //Storm 1 and 2133deviceBBBold : 'blackberry97', //Bold 97x0 (non-touch)134deviceBBBoldTouch : 'blackberry 99', //Bold 99x0 (touchscreen)135deviceBBTour : 'blackberry96', //Tour136deviceBBCurve : 'blackberry89', //Curve 2137deviceBBCurveTouch : 'blackberry 938', //Curve Touch 9380138deviceBBTorch : 'blackberry 98', //Torch139deviceBBPlaybook : 'playbook', //PlayBook tablet140141deviceSymbian : 'symbian',142deviceSymbos : 'symbos', //Opera 10 on Symbian143deviceS60 : 'series60',144deviceS70 : 'series70',145deviceS80 : 'series80',146deviceS90 : 'series90',147148devicePalm : 'palm',149deviceWebOS : 'webos', //For Palm devices150deviceWebOStv : 'web0s', //For LG TVs151deviceWebOShp : 'hpwos', //For HP's line of WebOS devices152153deviceNuvifone : 'nuvifone', //Garmin Nuvifone154deviceBada : 'bada', //Samsung's Bada OS155deviceTizen : 'tizen', //Tizen OS156deviceMeego : 'meego', //Meego OS157deviceSailfish : 'sailfish', //Sailfish OS158deviceUbuntu : 'ubuntu', //Ubuntu Mobile OS159160deviceKindle : 'kindle', //Amazon eInk Kindle161engineSilk : 'silk-accelerated', //Amazon's accelerated Silk browser for Kindle Fire162163engineBlazer : 'blazer', //Old Palm browser164engineXiino : 'xiino',165166//Initialize variables for mobile-specific content.167vndwap : 'vnd.wap',168wml : 'wml',169170//Initialize variables for random devices and mobile browsers.171//Some of these may not support JavaScript172deviceTablet : 'tablet',173deviceBrew : 'brew',174deviceDanger : 'danger',175deviceHiptop : 'hiptop',176devicePlaystation : 'playstation',177devicePlaystationVita : 'vita',178deviceNintendoDs : 'nitro',179deviceNintendo : 'nintendo',180deviceWii : 'wii',181deviceXbox : 'xbox',182deviceArchos : 'archos',183184engineFirefox : 'firefox', //For Firefox OS185engineOpera : 'opera', //Popular browser186engineNetfront : 'netfront', //Common embedded OS browser187engineUpBrowser : 'up.browser', //common on some phones188deviceMidp : 'midp', //a mobile Java technology189uplink : 'up.link',190engineTelecaQ : 'teleca q', //a modern feature phone browser191engineObigo : 'obigo', //W 10 is a modern feature phone browser192193devicePda : 'pda',194mini : 'mini', //Some mobile browsers put 'mini' in their names195mobile : 'mobile', //Some mobile browsers put 'mobile' in their user agent strings196mobi : 'mobi', //Some mobile browsers put 'mobi' in their user agent strings197198//Smart TV strings199smartTV1 : 'smart-tv', //Samsung Tizen smart TVs200smartTV2 : 'smarttv', //LG WebOS smart TVs201202//Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets.203maemo : 'maemo',204linux : 'linux',205mylocom2 : 'sony/com', // for Sony Mylo 1 and 2206207//In some UserAgents, the only clue is the manufacturer208manuSonyEricsson : 'sonyericsson',209manuericsson : 'ericsson',210manuSamsung1 : 'sec-sgh',211manuSony : 'sony',212manuHtc : 'htc', //Popular Android and WinMo manufacturer213214//In some UserAgents, the only clue is the operator215svcDocomo : 'docomo',216svcKddi : 'kddi',217svcVodafone : 'vodafone',218219//Disambiguation strings.220disUpdate : 'update', //pda vs. update221222//Holds the User Agent string value.223uagent : '',224225//Initializes key MobileEsp variables226InitDeviceScan : function() {227this.initCompleted = false;228229if (navigator && navigator.userAgent)230this.uagent = navigator.userAgent.toLowerCase();231232//Save these properties to speed processing233this.isWebkit = this.DetectWebkit();234this.isIphone = this.DetectIphone();235this.isAndroid = this.DetectAndroid();236this.isAndroidPhone = this.DetectAndroidPhone();237238//Generally, these tiers are the most useful for web development239this.isMobilePhone = this.DetectMobileQuick();240this.isTierIphone = this.DetectTierIphone();241this.isTierTablet = this.DetectTierTablet();242243//Optional: Comment these out if you NEVER use them244this.isTierRichCss = this.DetectTierRichCss();245this.isTierGenericMobile = this.DetectTierOtherPhones();246247this.initCompleted = true;248},249250251//APPLE IOS252253//**************************254// Detects if the current device is an iPhone.255DetectIphone : function() {256if (this.initCompleted || this.isIphone)257return this.isIphone;258259if (this.uagent.search(this.deviceIphone) > -1)260{261//The iPad and iPod Touch say they're an iPhone! So let's disambiguate.262if (this.DetectIpad() || this.DetectIpod())263return false;264//Yay! It's an iPhone!265else266return true;267}268else269return false;270},271272//**************************273// Detects if the current device is an iPod Touch.274DetectIpod : function() {275if (this.uagent.search(this.deviceIpod) > -1)276return true;277else278return false;279},280281//**************************282// Detects if the current device is an iPhone or iPod Touch.283DetectIphoneOrIpod : function() {284//We repeat the searches here because some iPods285// may report themselves as an iPhone, which is ok.286if (this.DetectIphone() || this.DetectIpod())287return true;288else289return false;290},291292//**************************293// Detects if the current device is an iPad tablet.294DetectIpad : function() {295if (this.uagent.search(this.deviceIpad) > -1 && this.DetectWebkit())296return true;297else298return false;299},300301//**************************302// Detects *any* iOS device: iPhone, iPod Touch, iPad.303DetectIos : function() {304if (this.DetectIphoneOrIpod() || this.DetectIpad())305return true;306else307return false;308},309310311//ANDROID312313//**************************314// Detects *any* Android OS-based device: phone, tablet, and multi-media player.315// Also detects Google TV.316DetectAndroid : function() {317if (this.initCompleted || this.isAndroid)318return this.isAndroid;319320if ((this.uagent.search(this.deviceAndroid) > -1) || this.DetectGoogleTV())321return true;322323return false;324},325326//**************************327// Detects if the current device is a (small-ish) Android OS-based device328// used for calling and/or multi-media (like a Samsung Galaxy Player).329// Google says these devices will have 'Android' AND 'mobile' in user agent.330// Ignores tablets (Honeycomb and later).331DetectAndroidPhone : function() {332if (this.initCompleted || this.isAndroidPhone)333return this.isAndroidPhone;334335//First, let's make sure we're on an Android device.336if (!this.DetectAndroid())337return false;338339//If it's Android and has 'mobile' in it, Google says it's a phone.340if (this.uagent.search(this.mobile) > -1)341return true;342343//Special check for Android phones with Opera Mobile. They should report here.344if (this.DetectOperaMobile())345return true;346347return false;348},349350//**************************351// Detects if the current device is a (self-reported) Android tablet.352// Google says these devices will have 'Android' and NOT 'mobile' in their user agent.353DetectAndroidTablet : function() {354//First, let's make sure we're on an Android device.355if (!this.DetectAndroid())356return false;357358//Special check for Opera Android Phones. They should NOT report here.359if (this.DetectOperaMobile())360return false;361362//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.363if (this.uagent.search(this.mobile) > -1)364return false;365else366return true;367},368369//**************************370// Detects if the current device is an Android OS-based device and371// the browser is based on WebKit.372DetectAndroidWebKit : function() {373if (this.DetectAndroid() && this.DetectWebkit())374return true;375else376return false;377},378379//**************************380// Detects if the current device is a GoogleTV.381DetectGoogleTV : function() {382if (this.uagent.search(this.deviceGoogleTV) > -1)383return true;384else385return false;386},387388//**************************389// Detects if the current browser is based on WebKit.390DetectWebkit : function() {391if (this.initCompleted || this.isWebkit)392return this.isWebkit;393394if (this.uagent.search(this.engineWebKit) > -1)395return true;396else397return false;398},399400401//WINDOWS MOBILE AND PHONE402403// Detects if the current browser is a404// Windows Phone 7, 8, or 10 device.405DetectWindowsPhone : function() {406if (this.DetectWindowsPhone7() ||407this.DetectWindowsPhone8() ||408this.DetectWindowsPhone10())409return true;410else411return false;412},413414//**************************415// Detects a Windows Phone 7 device (in mobile browsing mode).416DetectWindowsPhone7 : function() {417if (this.uagent.search(this.deviceWinPhone7) > -1)418return true;419else420return false;421},422423//**************************424// Detects a Windows Phone 8 device (in mobile browsing mode).425DetectWindowsPhone8 : function() {426if (this.uagent.search(this.deviceWinPhone8) > -1)427return true;428else429return false;430},431432//**************************433// Detects a Windows Phone 10 device (in mobile browsing mode).434DetectWindowsPhone10 : function() {435if (this.uagent.search(this.deviceWinPhone10) > -1)436return true;437else438return false;439},440441//**************************442// Detects if the current browser is a Windows Mobile device.443// Excludes Windows Phone 7 and later devices.444// Focuses on Windows Mobile 6.xx and earlier.445DetectWindowsMobile : function() {446if (this.DetectWindowsPhone())447return false;448449//Most devices use 'Windows CE', but some report 'iemobile'450// and some older ones report as 'PIE' for Pocket IE.451if (this.uagent.search(this.deviceWinMob) > -1 ||452this.uagent.search(this.deviceIeMob) > -1 ||453this.uagent.search(this.enginePie) > -1)454return true;455//Test for Windows Mobile PPC but not old Macintosh PowerPC.456if ((this.uagent.search(this.devicePpc) > -1) &&457!(this.uagent.search(this.deviceMacPpc) > -1))458return true;459//Test for Windwos Mobile-based HTC devices.460if (this.uagent.search(this.manuHtc) > -1 &&461this.uagent.search(this.deviceWindows) > -1)462return true;463else464return false;465},466467468//BLACKBERRY469470//**************************471// Detects if the current browser is a BlackBerry of some sort.472// Includes BB10 OS, but excludes the PlayBook.473DetectBlackBerry : function() {474if ((this.uagent.search(this.deviceBB) > -1) ||475(this.uagent.search(this.vndRIM) > -1))476return true;477if (this.DetectBlackBerry10Phone())478return true;479else480return false;481},482483//**************************484// Detects if the current browser is a BlackBerry 10 OS phone.485// Excludes tablets.486DetectBlackBerry10Phone : function() {487if ((this.uagent.search(this.deviceBB10) > -1) &&488(this.uagent.search(this.mobile) > -1))489return true;490else491return false;492},493494//**************************495// Detects if the current browser is on a BlackBerry tablet device.496// Example: PlayBook497DetectBlackBerryTablet : function() {498if (this.uagent.search(this.deviceBBPlaybook) > -1)499return true;500else501return false;502},503504//**************************505// Detects if the current browser is a BlackBerry device AND uses a506// WebKit-based browser. These are signatures for the new BlackBerry OS 6.507// Examples: Torch. Includes the Playbook.508DetectBlackBerryWebKit : function() {509if (this.DetectBlackBerry() &&510this.uagent.search(this.engineWebKit) > -1)511return true;512else513return false;514},515516//**************************517// Detects if the current browser is a BlackBerry Touch518// device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.519DetectBlackBerryTouch : function() {520if (this.DetectBlackBerry() &&521((this.uagent.search(this.deviceBBStorm) > -1) ||522(this.uagent.search(this.deviceBBTorch) > -1) ||523(this.uagent.search(this.deviceBBBoldTouch) > -1) ||524(this.uagent.search(this.deviceBBCurveTouch) > -1) ))525return true;526else527return false;528},529530//**************************531// Detects if the current browser is a BlackBerry OS 5 device AND532// has a more capable recent browser. Excludes the Playbook.533// Examples, Storm, Bold, Tour, Curve2534// Excludes the new BlackBerry OS 6 and 7 browser!!535DetectBlackBerryHigh : function() {536//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser537if (this.DetectBlackBerryWebKit())538return false;539if ((this.DetectBlackBerry()) &&540(this.DetectBlackBerryTouch() ||541this.uagent.search(this.deviceBBBold) > -1 ||542this.uagent.search(this.deviceBBTour) > -1 ||543this.uagent.search(this.deviceBBCurve) > -1))544return true;545else546return false;547},548549//**************************550// Detects if the current browser is a BlackBerry device AND551// has an older, less capable browser.552// Examples: Pearl, 8800, Curve1.553DetectBlackBerryLow : function() {554if (this.DetectBlackBerry())555{556//Assume that if it's not in the High tier or has WebKit, then it's Low.557if (this.DetectBlackBerryHigh() || this.DetectBlackBerryWebKit())558return false;559else560return true;561}562else563return false;564},565566567//SYMBIAN568569//**************************570// Detects if the current browser is the Nokia S60 Open Source Browser.571DetectS60OssBrowser : function() {572if (this.DetectWebkit())573{574if ((this.uagent.search(this.deviceS60) > -1 ||575this.uagent.search(this.deviceSymbian) > -1))576return true;577else578return false;579}580else581return false;582},583584//**************************585// Detects if the current device is any Symbian OS-based device,586// including older S60, Series 70, Series 80, Series 90, and UIQ,587// or other browsers running on these devices.588DetectSymbianOS : function() {589if (this.uagent.search(this.deviceSymbian) > -1 ||590this.uagent.search(this.deviceS60) > -1 ||591((this.uagent.search(this.deviceSymbos) > -1) &&592(this.DetectOperaMobile)) || //Opera 10593this.uagent.search(this.deviceS70) > -1 ||594this.uagent.search(this.deviceS80) > -1 ||595this.uagent.search(this.deviceS90) > -1)596return true;597else598return false;599},600601602//WEBOS AND PALM603604//**************************605// Detects if the current browser is on a PalmOS device.606DetectPalmOS : function() {607//Make sure it's not WebOS first608if (this.DetectPalmWebOS())609return false;610611//Most devices nowadays report as 'Palm',612// but some older ones reported as Blazer or Xiino.613if (this.uagent.search(this.devicePalm) > -1 ||614this.uagent.search(this.engineBlazer) > -1 ||615this.uagent.search(this.engineXiino) > -1)616return true;617else618return false;619},620621//**************************622// Detects if the current browser is on a Palm device623// running the new WebOS.624DetectPalmWebOS : function()625{626if (this.uagent.search(this.deviceWebOS) > -1)627return true;628else629return false;630},631632//**************************633// Detects if the current browser is on an HP tablet running WebOS.634DetectWebOSTablet : function() {635if (this.uagent.search(this.deviceWebOShp) > -1 &&636this.uagent.search(this.deviceTablet) > -1)637return true;638else639return false;640},641642//**************************643// Detects if the current browser is on a WebOS smart TV.644DetectWebOSTV : function() {645if (this.uagent.search(this.deviceWebOStv) > -1 &&646this.uagent.search(this.smartTV2) > -1)647return true;648else649return false;650},651652653//OPERA654655//**************************656// Detects if the current browser is Opera Mobile or Mini.657// Note: Older embedded Opera on mobile devices didn't follow these naming conventions.658// Like Archos media players, they will probably show up in DetectMobileQuick or -Long instead.659DetectOperaMobile : function() {660if ((this.uagent.search(this.engineOpera) > -1) &&661((this.uagent.search(this.mini) > -1 ||662this.uagent.search(this.mobi) > -1)))663return true;664else665return false;666},667668669//MISCELLANEOUS DEVICES670671//**************************672// Detects if the current device is an Amazon Kindle (eInk devices only).673// Note: For the Kindle Fire, use the normal Android methods.674DetectKindle : function() {675if (this.uagent.search(this.deviceKindle) > -1 &&676!this.DetectAndroid())677return true;678else679return false;680},681682//**************************683// Detects if the current Amazon device has turned on the Silk accelerated browsing feature.684// Note: Typically used by the the Kindle Fire.685DetectAmazonSilk : function() {686if (this.uagent.search(this.engineSilk) > -1)687return true;688else689return false;690},691692//**************************693// Detects if the current browser is a694// Garmin Nuvifone.695DetectGarminNuvifone : function() {696if (this.uagent.search(this.deviceNuvifone) > -1)697return true;698else699return false;700},701702//**************************703// Detects a device running the Bada OS from Samsung.704DetectBada : function() {705if (this.uagent.search(this.deviceBada) > -1)706return true;707else708return false;709},710711//**************************712// Detects a device running the Tizen smartphone OS.713DetectTizen : function() {714if (this.uagent.search(this.deviceTizen) > -1 &&715this.uagent.search(this.mobile) > -1)716return true;717else718return false;719},720721//**************************722// Detects if the current browser is on a Tizen smart TV.723DetectTizenTV : function() {724if (this.uagent.search(this.deviceTizen) > -1 &&725this.uagent.search(this.smartTV1) > -1)726return true;727else728return false;729},730731//**************************732// Detects a device running the Meego OS.733DetectMeego : function() {734if (this.uagent.search(this.deviceMeego) > -1)735return true;736else737return false;738},739740//**************************741// Detects a phone running the Meego OS.742DetectMeegoPhone : function() {743if (this.uagent.search(this.deviceMeego) > -1 &&744this.uagent.search(this.mobi) > -1)745return true;746else747return false;748},749750//**************************751// Detects a mobile device (probably) running the Firefox OS.752DetectFirefoxOS : function() {753if (this.DetectFirefoxOSPhone() || this.DetectFirefoxOSTablet())754return true;755else756return false;757},758759//**************************760// Detects a phone (probably) running the Firefox OS.761DetectFirefoxOSPhone : function() {762//First, let's make sure we're NOT on another major mobile OS.763if (this.DetectIos() ||764this.DetectAndroid() ||765this.DetectSailfish())766return false;767768if ((this.uagent.search(this.engineFirefox) > -1) &&769(this.uagent.search(this.mobile) > -1))770return true;771772return false;773},774775//**************************776// Detects a tablet (probably) running the Firefox OS.777DetectFirefoxOSTablet : function() {778//First, let's make sure we're NOT on another major mobile OS.779if (this.DetectIos() ||780this.DetectAndroid() ||781this.DetectSailfish())782return false;783784if ((this.uagent.search(this.engineFirefox) > -1) &&785(this.uagent.search(this.deviceTablet) > -1))786return true;787788return false;789},790791//**************************792// Detects a device running the Sailfish OS.793DetectSailfish : function() {794if (this.uagent.search(this.deviceSailfish) > -1)795return true;796else797return false;798},799800//**************************801// Detects a phone running the Sailfish OS.802DetectSailfishPhone : function() {803if (this.DetectSailfish() && (this.uagent.search(this.mobile) > -1))804return true;805806return false;807},808809810//**************************811// Detects a mobile device running the Ubuntu Mobile OS.812DetectUbuntu : function() {813if (this.DetectUbuntuPhone() || this.DetectUbuntuTablet())814return true;815else816return false;817},818819//**************************820// Detects a phone running the Ubuntu Mobile OS.821DetectUbuntuPhone : function() {822if ((this.uagent.search(this.deviceUbuntu) > -1) &&823(this.uagent.search(this.mobile) > -1))824return true;825826return false;827},828829//**************************830// Detects a tablet running the Ubuntu Mobile OS.831DetectUbuntuTablet : function() {832if ((this.uagent.search(this.deviceUbuntu) > -1) &&833(this.uagent.search(this.deviceTablet) > -1))834return true;835836return false;837},838839//**************************840// Detects the Danger Hiptop device.841DetectDangerHiptop : function() {842if (this.uagent.search(this.deviceDanger) > -1 ||843this.uagent.search(this.deviceHiptop) > -1)844return true;845else846return false;847},848849//**************************850// Detects if the current browser is a Sony Mylo device.851DetectSonyMylo : function() {852if ((this.uagent.search(this.manuSony) > -1) &&853((this.uagent.search(this.qtembedded) > -1) ||854(this.uagent.search(this.mylocom2) > -1)))855return true;856else857return false;858},859860//**************************861// Detects if the current device is on one of862// the Maemo-based Nokia Internet Tablets.863DetectMaemoTablet : function() {864if (this.uagent.search(this.maemo) > -1)865return true;866//For Nokia N810, must be Linux + Tablet, or else it could be something else.867if ((this.uagent.search(this.linux) > -1) &&868(this.uagent.search(this.deviceTablet) > -1) &&869this.DetectWebOSTablet() &&870!this.DetectAndroid())871return true;872else873return false;874},875876//**************************877// Detects if the current device is an Archos media player/Internet tablet.878DetectArchos : function() {879if (this.uagent.search(this.deviceArchos) > -1)880return true;881else882return false;883},884885//**************************886// Detects if the current device is an Internet-capable game console.887// Includes many handheld consoles.888DetectGameConsole : function() {889if (this.DetectSonyPlaystation() ||890this.DetectNintendo() ||891this.DetectXbox())892return true;893else894return false;895},896897//**************************898// Detects if the current device is a Sony Playstation.899DetectSonyPlaystation : function() {900if (this.uagent.search(this.devicePlaystation) > -1)901return true;902else903return false;904},905906//**************************907// Detects if the current device is a handheld gaming device with908// a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.909DetectGamingHandheld : function() {910if ((this.uagent.search(this.devicePlaystation) > -1) &&911(this.uagent.search(this.devicePlaystationVita) > -1))912return true;913else914return false;915},916917//**************************918// Detects if the current device is a Nintendo game device.919DetectNintendo : function() {920if (this.uagent.search(this.deviceNintendo) > -1 ||921this.uagent.search(this.deviceWii) > -1 ||922this.uagent.search(this.deviceNintendoDs) > -1)923return true;924else925return false;926},927928//**************************929// Detects if the current device is a Microsoft Xbox.930DetectXbox : function() {931if (this.uagent.search(this.deviceXbox) > -1)932return true;933else934return false;935},936937938//**************************939// Detects whether the device is a Brew-powered device.940// Note: Limited to older Brew-powered feature phones.941// Ignores newer Brew versions like MP. Refer to DetectMobileQuick().942DetectBrewDevice : function() {943if (this.uagent.search(this.deviceBrew) > -1)944return true;945else946return false;947},948949950// DEVICE CLASSES951952//**************************953// Check to see whether the device is *any* 'smartphone'.954// Note: It's better to use DetectTierIphone() for modern touchscreen devices.955DetectSmartphone : function() {956//Exclude duplicates from TierIphone957if (this.DetectTierIphone() ||958this.DetectS60OssBrowser() ||959this.DetectSymbianOS() ||960this.DetectWindowsMobile() ||961this.DetectBlackBerry() ||962this.DetectMeegoPhone() ||963this.DetectPalmOS())964return true;965966//Otherwise, return false.967return false;968},969970//**************************971// Detects if the current device is a mobile device.972// This method catches most of the popular modern devices.973// Excludes Apple iPads and other modern tablets.974DetectMobileQuick : function() {975if (this.initCompleted || this.isMobilePhone)976return this.isMobilePhone;977978//Let's exclude tablets.979if (this.DetectTierTablet())980return false;981982//Most mobile browsing is done on smartphones983if (this.DetectSmartphone())984return true;985986//Catch-all for many mobile devices987if (this.uagent.search(this.mobile) > -1)988return true;989990if (this.DetectOperaMobile())991return true;992993//We also look for Kindle devices994if (this.DetectKindle() ||995this.DetectAmazonSilk())996return true;997998if (this.uagent.search(this.deviceMidp) > -1 ||999this.DetectBrewDevice())1000return true;10011002if ((this.uagent.search(this.engineObigo) > -1) ||1003(this.uagent.search(this.engineNetfront) > -1) ||1004(this.uagent.search(this.engineUpBrowser) > -1))1005return true;10061007return false;1008},10091010//**************************1011// Detects in a more comprehensive way if the current device is a mobile device.1012DetectMobileLong : function() {1013if (this.DetectMobileQuick())1014return true;1015if (this.DetectGameConsole())1016return true;10171018if (this.DetectDangerHiptop() ||1019this.DetectMaemoTablet() ||1020this.DetectSonyMylo() ||1021this.DetectArchos())1022return true;10231024if ((this.uagent.search(this.devicePda) > -1) &&1025!(this.uagent.search(this.disUpdate) > -1))1026return true;10271028//Detect for certain very old devices with stupid useragent strings.1029if ((this.uagent.search(this.manuSamsung1) > -1) ||1030(this.uagent.search(this.manuSonyEricsson) > -1) ||1031(this.uagent.search(this.manuericsson) > -1) ||1032(this.uagent.search(this.svcDocomo) > -1) ||1033(this.uagent.search(this.svcKddi) > -1) ||1034(this.uagent.search(this.svcVodafone) > -1))1035return true;10361037return false;1038},10391040//*****************************1041// For Mobile Web Site Design1042//*****************************10431044//**************************1045// The quick way to detect for a tier of devices.1046// This method detects for the new generation of1047// HTML 5 capable, larger screen tablets.1048// Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.1049DetectTierTablet : function() {1050if (this.initCompleted || this.isTierTablet)1051return this.isTierTablet;10521053if (this.DetectIpad() ||1054this.DetectAndroidTablet() ||1055this.DetectBlackBerryTablet() ||1056this.DetectFirefoxOSTablet() ||1057this.DetectUbuntuTablet() ||1058this.DetectWebOSTablet())1059return true;1060else1061return false;1062},10631064//**************************1065// The quick way to detect for a tier of devices.1066// This method detects for devices which can1067// display iPhone-optimized web content.1068// Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.1069DetectTierIphone : function() {1070if (this.initCompleted || this.isTierIphone)1071return this.isTierIphone;10721073if (this.DetectIphoneOrIpod() ||1074this.DetectAndroidPhone() ||1075this.DetectWindowsPhone() ||1076this.DetectBlackBerry10Phone() ||1077this.DetectPalmWebOS() ||1078this.DetectBada() ||1079this.DetectTizen() ||1080this.DetectFirefoxOSPhone() ||1081this.DetectSailfishPhone() ||1082this.DetectUbuntuPhone() ||1083this.DetectGamingHandheld())1084return true;10851086//Note: BB10 phone is in the previous paragraph1087if (this.DetectBlackBerryWebKit() && this.DetectBlackBerryTouch())1088return true;10891090else1091return false;1092},10931094//**************************1095// The quick way to detect for a tier of devices.1096// This method detects for devices which are likely to be1097// capable of viewing CSS content optimized for the iPhone,1098// but may not necessarily support JavaScript.1099// Excludes all iPhone Tier devices.1100DetectTierRichCss : function() {1101if (this.initCompleted || this.isTierRichCss)1102return this.isTierRichCss;11031104//Exclude iPhone and Tablet Tiers and e-Ink Kindle devices1105if (this.DetectTierIphone() ||1106this.DetectKindle() ||1107this.DetectTierTablet())1108return false;11091110//Exclude if not mobile1111if (!this.DetectMobileQuick())1112return false;11131114//If it's a mobile webkit browser on any other device, it's probably OK.1115if (this.DetectWebkit())1116return true;11171118//The following devices are also explicitly ok.1119if (this.DetectS60OssBrowser() ||1120this.DetectBlackBerryHigh() ||1121this.DetectWindowsMobile() ||1122(this.uagent.search(this.engineTelecaQ) > -1))1123return true;11241125else1126return false;1127},11281129//**************************1130// The quick way to detect for a tier of devices.1131// This method detects for all other types of phones,1132// but excludes the iPhone and RichCSS Tier devices.1133// NOTE: This method probably won't work due to poor1134// support for JavaScript among other devices.1135DetectTierOtherPhones : function() {1136if (this.initCompleted || this.isTierGenericMobile)1137return this.isTierGenericMobile;11381139//Exclude iPhone, Rich CSS and Tablet Tiers1140if (this.DetectTierIphone() ||1141this.DetectTierRichCss() ||1142this.DetectTierTablet())1143return false;11441145//Otherwise, if it's mobile, it's OK1146if (this.DetectMobileLong())1147return true;11481149else1150return false;1151}11521153};11541155//Initialize the MobileEsp object1156MobileEsp.InitDeviceScan();115711581159116011611162