Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/client/lib/mdetect.js
1154 views
1
/* *******************************************
2
// Copyright 2010-2015, Anthony Hand
3
//
4
// BETA NOTICE
5
// Previous versions of the JavaScript code for MobileESP were 'regular'
6
// JavaScript. The strength of it was that it was really easy to code and use.
7
// Unfortunately, regular JavaScript means that all variables and functions
8
// are in the global namespace. There can be collisions with other code libraries
9
// which may have similar variable or function names. Collisions cause bugs as each
10
// library changes a variable's definition or functionality unexpectedly.
11
// As a result, we thought it wise to switch to an "object oriented" style of code.
12
// This 'literal notation' technique keeps all MobileESP variables and functions fully self-contained.
13
// It avoids potential for collisions with other JavaScript libraries.
14
// This technique allows the developer continued access to any desired function or property.
15
//
16
// Please send feedback to project founder Anthony Hand: [email protected]
17
//
18
//
19
// File version 2015.05.13 (May 13, 2015)
20
// Updates:
21
// - Moved MobileESP to GitHub. https://github.com/ahand/mobileesp
22
// - Opera Mobile/Mini browser has the same UA string on multiple platforms and doesn't differentiate phone vs. tablet.
23
// - Removed DetectOperaAndroidPhone(). This method is no longer reliable.
24
// - Removed DetectOperaAndroidTablet(). This method is no longer reliable.
25
// - Added support for Windows Phone 10: variable and DetectWindowsPhone10()
26
// - Updated DetectWindowsPhone() to include WP10.
27
// - Added support for Firefox OS.
28
// - A variable plus DetectFirefoxOS(), DetectFirefoxOSPhone(), DetectFirefoxOSTablet()
29
// - NOTE: Firefox doesn't add UA tokens to definitively identify Firefox OS vs. their browsers on other mobile platforms.
30
// - Added support for Sailfish OS. Not enough info to add a tablet detection method at this time.
31
// - A variable plus DetectSailfish(), DetectSailfishPhone()
32
// - Added support for Ubuntu Mobile OS.
33
// - DetectUbuntu(), DetectUbuntuPhone(), DetectUbuntuTablet()
34
// - Added support for 2 smart TV OSes. They lack browsers but do have WebViews for use by HTML apps.
35
// - One variable for Samsung Tizen TVs, plus DetectTizenTV()
36
// - One variable for LG WebOS TVs, plus DetectWebOSTV()
37
// - Updated DetectTizen(). Now tests for “mobile” to disambiguate from Samsung Smart TVs
38
// - Removed variables for obsolete devices: deviceHtcFlyer, deviceXoom.
39
// - Updated DetectAndroid(). No longer has a special test case for the HTC Flyer tablet.
40
// - Updated DetectAndroidPhone().
41
// - Updated internal detection code for Android.
42
// - No longer has a special test case for the HTC Flyer tablet.
43
// - Checks against DetectOperaMobile() on Android and reports here if relevant.
44
// - Updated DetectAndroidTablet().
45
// - No longer has a special test case for the HTC Flyer tablet.
46
// - Checks against DetectOperaMobile() on Android to exclude it from here.
47
// - DetectMeego(): Changed definition for this method. Now detects any Meego OS device, not just phones.
48
// - DetectMeegoPhone(): NEW. For Meego phones. Ought to detect Opera browsers on Meego, as well.
49
// - DetectTierIphone(): Added support for phones running Sailfish, Ubuntu and Firefox Mobile.
50
// - DetectTierTablet(): Added support for tablets running Ubuntu and Firefox Mobile.
51
// - DetectSmartphone(): Added support for Meego phones.
52
// - Reorganized DetectMobileQuick(). Moved the following to DetectMobileLong():
53
// - DetectDangerHiptop(), DetectMaemoTablet(), DetectSonyMylo(), DetectArchos()
54
//
55
//
56
//
57
// LICENSE INFORMATION
58
// Licensed under the Apache License, Version 2.0 (the "License");
59
// you may not use this file except in compliance with the License.
60
// You may obtain a copy of the License at
61
// http://www.apache.org/licenses/LICENSE-2.0
62
// Unless required by applicable law or agreed to in writing,
63
// software distributed under the License is distributed on an
64
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
65
// either express or implied. See the License for the specific
66
// language governing permissions and limitations under the License.
67
//
68
//
69
// ABOUT THIS PROJECT
70
// Project Owner: Anthony Hand
71
// Email: [email protected]
72
// Web Site: http://www.mobileesp.com
73
// Source Files: https://github.com/ahand/mobileesp
74
//
75
// Versions of this code are available for:
76
// PHP, JavaScript, Java, ASP.NET (C#), Ruby and others
77
//
78
//
79
// WARNING:
80
// These JavaScript-based device detection features may ONLY work
81
// for the newest generation of smartphones, such as the iPhone,
82
// Android and Palm WebOS devices.
83
// These device detection features may NOT work for older smartphones
84
// which had poor support for JavaScript, including
85
// older BlackBerry, PalmOS, and Windows Mobile devices.
86
// Additionally, because JavaScript support is extremely poor among
87
// 'feature phones', these features may not work at all on such devices.
88
// For better results, consider using a server-based version of this code,
89
// such as Java, APS.NET, PHP, or Ruby.
90
//
91
// *******************************************
92
*/
93
94
95
var MobileEsp = {
96
97
//GLOBALLY USEFUL VARIABLES
98
//Note: These values are set automatically during the Init function.
99
//Stores whether we're currently initializing the most popular functions.
100
initCompleted : false,
101
isWebkit : false, //Stores the result of DetectWebkit()
102
isMobilePhone : false, //Stores the result of DetectMobileQuick()
103
isIphone : false, //Stores the result of DetectIphone()
104
isAndroid : false, //Stores the result of DetectAndroid()
105
isAndroidPhone : false, //Stores the result of DetectAndroidPhone()
106
isTierTablet : false, //Stores the result of DetectTierTablet()
107
isTierIphone : false, //Stores the result of DetectTierIphone()
108
isTierRichCss : false, //Stores the result of DetectTierRichCss()
109
isTierGenericMobile : false, //Stores the result of DetectTierOtherPhones()
110
111
//INTERNALLY USED DETECTION STRING VARIABLES
112
engineWebKit : 'webkit',
113
deviceIphone : 'iphone',
114
deviceIpod : 'ipod',
115
deviceIpad : 'ipad',
116
deviceMacPpc : 'macintosh', //Used for disambiguation
117
118
deviceAndroid : 'android',
119
deviceGoogleTV : 'googletv',
120
121
deviceWinPhone7 : 'windows phone os 7',
122
deviceWinPhone8 : 'windows phone 8',
123
deviceWinPhone10 : 'windows phone 10',
124
deviceWinMob : 'windows ce',
125
deviceWindows : 'windows',
126
deviceIeMob : 'iemobile',
127
devicePpc : 'ppc', //Stands for PocketPC
128
enginePie : 'wm5 pie', //An old Windows Mobile
129
130
deviceBB : 'blackberry',
131
deviceBB10 : 'bb10', //For the new BB 10 OS
132
vndRIM : 'vnd.rim', //Detectable when BB devices emulate IE or Firefox
133
deviceBBStorm : 'blackberry95', //Storm 1 and 2
134
deviceBBBold : 'blackberry97', //Bold 97x0 (non-touch)
135
deviceBBBoldTouch : 'blackberry 99', //Bold 99x0 (touchscreen)
136
deviceBBTour : 'blackberry96', //Tour
137
deviceBBCurve : 'blackberry89', //Curve 2
138
deviceBBCurveTouch : 'blackberry 938', //Curve Touch 9380
139
deviceBBTorch : 'blackberry 98', //Torch
140
deviceBBPlaybook : 'playbook', //PlayBook tablet
141
142
deviceSymbian : 'symbian',
143
deviceSymbos : 'symbos', //Opera 10 on Symbian
144
deviceS60 : 'series60',
145
deviceS70 : 'series70',
146
deviceS80 : 'series80',
147
deviceS90 : 'series90',
148
149
devicePalm : 'palm',
150
deviceWebOS : 'webos', //For Palm devices
151
deviceWebOStv : 'web0s', //For LG TVs
152
deviceWebOShp : 'hpwos', //For HP's line of WebOS devices
153
154
deviceNuvifone : 'nuvifone', //Garmin Nuvifone
155
deviceBada : 'bada', //Samsung's Bada OS
156
deviceTizen : 'tizen', //Tizen OS
157
deviceMeego : 'meego', //Meego OS
158
deviceSailfish : 'sailfish', //Sailfish OS
159
deviceUbuntu : 'ubuntu', //Ubuntu Mobile OS
160
161
deviceKindle : 'kindle', //Amazon eInk Kindle
162
engineSilk : 'silk-accelerated', //Amazon's accelerated Silk browser for Kindle Fire
163
164
engineBlazer : 'blazer', //Old Palm browser
165
engineXiino : 'xiino',
166
167
//Initialize variables for mobile-specific content.
168
vndwap : 'vnd.wap',
169
wml : 'wml',
170
171
//Initialize variables for random devices and mobile browsers.
172
//Some of these may not support JavaScript
173
deviceTablet : 'tablet',
174
deviceBrew : 'brew',
175
deviceDanger : 'danger',
176
deviceHiptop : 'hiptop',
177
devicePlaystation : 'playstation',
178
devicePlaystationVita : 'vita',
179
deviceNintendoDs : 'nitro',
180
deviceNintendo : 'nintendo',
181
deviceWii : 'wii',
182
deviceXbox : 'xbox',
183
deviceArchos : 'archos',
184
185
engineFirefox : 'firefox', //For Firefox OS
186
engineOpera : 'opera', //Popular browser
187
engineNetfront : 'netfront', //Common embedded OS browser
188
engineUpBrowser : 'up.browser', //common on some phones
189
deviceMidp : 'midp', //a mobile Java technology
190
uplink : 'up.link',
191
engineTelecaQ : 'teleca q', //a modern feature phone browser
192
engineObigo : 'obigo', //W 10 is a modern feature phone browser
193
194
devicePda : 'pda',
195
mini : 'mini', //Some mobile browsers put 'mini' in their names
196
mobile : 'mobile', //Some mobile browsers put 'mobile' in their user agent strings
197
mobi : 'mobi', //Some mobile browsers put 'mobi' in their user agent strings
198
199
//Smart TV strings
200
smartTV1 : 'smart-tv', //Samsung Tizen smart TVs
201
smartTV2 : 'smarttv', //LG WebOS smart TVs
202
203
//Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets.
204
maemo : 'maemo',
205
linux : 'linux',
206
mylocom2 : 'sony/com', // for Sony Mylo 1 and 2
207
208
//In some UserAgents, the only clue is the manufacturer
209
manuSonyEricsson : 'sonyericsson',
210
manuericsson : 'ericsson',
211
manuSamsung1 : 'sec-sgh',
212
manuSony : 'sony',
213
manuHtc : 'htc', //Popular Android and WinMo manufacturer
214
215
//In some UserAgents, the only clue is the operator
216
svcDocomo : 'docomo',
217
svcKddi : 'kddi',
218
svcVodafone : 'vodafone',
219
220
//Disambiguation strings.
221
disUpdate : 'update', //pda vs. update
222
223
//Holds the User Agent string value.
224
uagent : '',
225
226
//Initializes key MobileEsp variables
227
InitDeviceScan : function() {
228
this.initCompleted = false;
229
230
if (navigator && navigator.userAgent)
231
this.uagent = navigator.userAgent.toLowerCase();
232
233
//Save these properties to speed processing
234
this.isWebkit = this.DetectWebkit();
235
this.isIphone = this.DetectIphone();
236
this.isAndroid = this.DetectAndroid();
237
this.isAndroidPhone = this.DetectAndroidPhone();
238
239
//Generally, these tiers are the most useful for web development
240
this.isMobilePhone = this.DetectMobileQuick();
241
this.isTierIphone = this.DetectTierIphone();
242
this.isTierTablet = this.DetectTierTablet();
243
244
//Optional: Comment these out if you NEVER use them
245
this.isTierRichCss = this.DetectTierRichCss();
246
this.isTierGenericMobile = this.DetectTierOtherPhones();
247
248
this.initCompleted = true;
249
},
250
251
252
//APPLE IOS
253
254
//**************************
255
// Detects if the current device is an iPhone.
256
DetectIphone : function() {
257
if (this.initCompleted || this.isIphone)
258
return this.isIphone;
259
260
if (this.uagent.search(this.deviceIphone) > -1)
261
{
262
//The iPad and iPod Touch say they're an iPhone! So let's disambiguate.
263
if (this.DetectIpad() || this.DetectIpod())
264
return false;
265
//Yay! It's an iPhone!
266
else
267
return true;
268
}
269
else
270
return false;
271
},
272
273
//**************************
274
// Detects if the current device is an iPod Touch.
275
DetectIpod : function() {
276
if (this.uagent.search(this.deviceIpod) > -1)
277
return true;
278
else
279
return false;
280
},
281
282
//**************************
283
// Detects if the current device is an iPhone or iPod Touch.
284
DetectIphoneOrIpod : function() {
285
//We repeat the searches here because some iPods
286
// may report themselves as an iPhone, which is ok.
287
if (this.DetectIphone() || this.DetectIpod())
288
return true;
289
else
290
return false;
291
},
292
293
//**************************
294
// Detects if the current device is an iPad tablet.
295
DetectIpad : function() {
296
if (this.uagent.search(this.deviceIpad) > -1 && this.DetectWebkit())
297
return true;
298
else
299
return false;
300
},
301
302
//**************************
303
// Detects *any* iOS device: iPhone, iPod Touch, iPad.
304
DetectIos : function() {
305
if (this.DetectIphoneOrIpod() || this.DetectIpad())
306
return true;
307
else
308
return false;
309
},
310
311
312
//ANDROID
313
314
//**************************
315
// Detects *any* Android OS-based device: phone, tablet, and multi-media player.
316
// Also detects Google TV.
317
DetectAndroid : function() {
318
if (this.initCompleted || this.isAndroid)
319
return this.isAndroid;
320
321
if ((this.uagent.search(this.deviceAndroid) > -1) || this.DetectGoogleTV())
322
return true;
323
324
return false;
325
},
326
327
//**************************
328
// Detects if the current device is a (small-ish) Android OS-based device
329
// used for calling and/or multi-media (like a Samsung Galaxy Player).
330
// Google says these devices will have 'Android' AND 'mobile' in user agent.
331
// Ignores tablets (Honeycomb and later).
332
DetectAndroidPhone : function() {
333
if (this.initCompleted || this.isAndroidPhone)
334
return this.isAndroidPhone;
335
336
//First, let's make sure we're on an Android device.
337
if (!this.DetectAndroid())
338
return false;
339
340
//If it's Android and has 'mobile' in it, Google says it's a phone.
341
if (this.uagent.search(this.mobile) > -1)
342
return true;
343
344
//Special check for Android phones with Opera Mobile. They should report here.
345
if (this.DetectOperaMobile())
346
return true;
347
348
return false;
349
},
350
351
//**************************
352
// Detects if the current device is a (self-reported) Android tablet.
353
// Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
354
DetectAndroidTablet : function() {
355
//First, let's make sure we're on an Android device.
356
if (!this.DetectAndroid())
357
return false;
358
359
//Special check for Opera Android Phones. They should NOT report here.
360
if (this.DetectOperaMobile())
361
return false;
362
363
//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.
364
if (this.uagent.search(this.mobile) > -1)
365
return false;
366
else
367
return true;
368
},
369
370
//**************************
371
// Detects if the current device is an Android OS-based device and
372
// the browser is based on WebKit.
373
DetectAndroidWebKit : function() {
374
if (this.DetectAndroid() && this.DetectWebkit())
375
return true;
376
else
377
return false;
378
},
379
380
//**************************
381
// Detects if the current device is a GoogleTV.
382
DetectGoogleTV : function() {
383
if (this.uagent.search(this.deviceGoogleTV) > -1)
384
return true;
385
else
386
return false;
387
},
388
389
//**************************
390
// Detects if the current browser is based on WebKit.
391
DetectWebkit : function() {
392
if (this.initCompleted || this.isWebkit)
393
return this.isWebkit;
394
395
if (this.uagent.search(this.engineWebKit) > -1)
396
return true;
397
else
398
return false;
399
},
400
401
402
//WINDOWS MOBILE AND PHONE
403
404
// Detects if the current browser is a
405
// Windows Phone 7, 8, or 10 device.
406
DetectWindowsPhone : function() {
407
if (this.DetectWindowsPhone7() ||
408
this.DetectWindowsPhone8() ||
409
this.DetectWindowsPhone10())
410
return true;
411
else
412
return false;
413
},
414
415
//**************************
416
// Detects a Windows Phone 7 device (in mobile browsing mode).
417
DetectWindowsPhone7 : function() {
418
if (this.uagent.search(this.deviceWinPhone7) > -1)
419
return true;
420
else
421
return false;
422
},
423
424
//**************************
425
// Detects a Windows Phone 8 device (in mobile browsing mode).
426
DetectWindowsPhone8 : function() {
427
if (this.uagent.search(this.deviceWinPhone8) > -1)
428
return true;
429
else
430
return false;
431
},
432
433
//**************************
434
// Detects a Windows Phone 10 device (in mobile browsing mode).
435
DetectWindowsPhone10 : function() {
436
if (this.uagent.search(this.deviceWinPhone10) > -1)
437
return true;
438
else
439
return false;
440
},
441
442
//**************************
443
// Detects if the current browser is a Windows Mobile device.
444
// Excludes Windows Phone 7 and later devices.
445
// Focuses on Windows Mobile 6.xx and earlier.
446
DetectWindowsMobile : function() {
447
if (this.DetectWindowsPhone())
448
return false;
449
450
//Most devices use 'Windows CE', but some report 'iemobile'
451
// and some older ones report as 'PIE' for Pocket IE.
452
if (this.uagent.search(this.deviceWinMob) > -1 ||
453
this.uagent.search(this.deviceIeMob) > -1 ||
454
this.uagent.search(this.enginePie) > -1)
455
return true;
456
//Test for Windows Mobile PPC but not old Macintosh PowerPC.
457
if ((this.uagent.search(this.devicePpc) > -1) &&
458
!(this.uagent.search(this.deviceMacPpc) > -1))
459
return true;
460
//Test for Windwos Mobile-based HTC devices.
461
if (this.uagent.search(this.manuHtc) > -1 &&
462
this.uagent.search(this.deviceWindows) > -1)
463
return true;
464
else
465
return false;
466
},
467
468
469
//BLACKBERRY
470
471
//**************************
472
// Detects if the current browser is a BlackBerry of some sort.
473
// Includes BB10 OS, but excludes the PlayBook.
474
DetectBlackBerry : function() {
475
if ((this.uagent.search(this.deviceBB) > -1) ||
476
(this.uagent.search(this.vndRIM) > -1))
477
return true;
478
if (this.DetectBlackBerry10Phone())
479
return true;
480
else
481
return false;
482
},
483
484
//**************************
485
// Detects if the current browser is a BlackBerry 10 OS phone.
486
// Excludes tablets.
487
DetectBlackBerry10Phone : function() {
488
if ((this.uagent.search(this.deviceBB10) > -1) &&
489
(this.uagent.search(this.mobile) > -1))
490
return true;
491
else
492
return false;
493
},
494
495
//**************************
496
// Detects if the current browser is on a BlackBerry tablet device.
497
// Example: PlayBook
498
DetectBlackBerryTablet : function() {
499
if (this.uagent.search(this.deviceBBPlaybook) > -1)
500
return true;
501
else
502
return false;
503
},
504
505
//**************************
506
// Detects if the current browser is a BlackBerry device AND uses a
507
// WebKit-based browser. These are signatures for the new BlackBerry OS 6.
508
// Examples: Torch. Includes the Playbook.
509
DetectBlackBerryWebKit : function() {
510
if (this.DetectBlackBerry() &&
511
this.uagent.search(this.engineWebKit) > -1)
512
return true;
513
else
514
return false;
515
},
516
517
//**************************
518
// Detects if the current browser is a BlackBerry Touch
519
// device, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
520
DetectBlackBerryTouch : function() {
521
if (this.DetectBlackBerry() &&
522
((this.uagent.search(this.deviceBBStorm) > -1) ||
523
(this.uagent.search(this.deviceBBTorch) > -1) ||
524
(this.uagent.search(this.deviceBBBoldTouch) > -1) ||
525
(this.uagent.search(this.deviceBBCurveTouch) > -1) ))
526
return true;
527
else
528
return false;
529
},
530
531
//**************************
532
// Detects if the current browser is a BlackBerry OS 5 device AND
533
// has a more capable recent browser. Excludes the Playbook.
534
// Examples, Storm, Bold, Tour, Curve2
535
// Excludes the new BlackBerry OS 6 and 7 browser!!
536
DetectBlackBerryHigh : function() {
537
//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser
538
if (this.DetectBlackBerryWebKit())
539
return false;
540
if ((this.DetectBlackBerry()) &&
541
(this.DetectBlackBerryTouch() ||
542
this.uagent.search(this.deviceBBBold) > -1 ||
543
this.uagent.search(this.deviceBBTour) > -1 ||
544
this.uagent.search(this.deviceBBCurve) > -1))
545
return true;
546
else
547
return false;
548
},
549
550
//**************************
551
// Detects if the current browser is a BlackBerry device AND
552
// has an older, less capable browser.
553
// Examples: Pearl, 8800, Curve1.
554
DetectBlackBerryLow : function() {
555
if (this.DetectBlackBerry())
556
{
557
//Assume that if it's not in the High tier or has WebKit, then it's Low.
558
if (this.DetectBlackBerryHigh() || this.DetectBlackBerryWebKit())
559
return false;
560
else
561
return true;
562
}
563
else
564
return false;
565
},
566
567
568
//SYMBIAN
569
570
//**************************
571
// Detects if the current browser is the Nokia S60 Open Source Browser.
572
DetectS60OssBrowser : function() {
573
if (this.DetectWebkit())
574
{
575
if ((this.uagent.search(this.deviceS60) > -1 ||
576
this.uagent.search(this.deviceSymbian) > -1))
577
return true;
578
else
579
return false;
580
}
581
else
582
return false;
583
},
584
585
//**************************
586
// Detects if the current device is any Symbian OS-based device,
587
// including older S60, Series 70, Series 80, Series 90, and UIQ,
588
// or other browsers running on these devices.
589
DetectSymbianOS : function() {
590
if (this.uagent.search(this.deviceSymbian) > -1 ||
591
this.uagent.search(this.deviceS60) > -1 ||
592
((this.uagent.search(this.deviceSymbos) > -1) &&
593
(this.DetectOperaMobile)) || //Opera 10
594
this.uagent.search(this.deviceS70) > -1 ||
595
this.uagent.search(this.deviceS80) > -1 ||
596
this.uagent.search(this.deviceS90) > -1)
597
return true;
598
else
599
return false;
600
},
601
602
603
//WEBOS AND PALM
604
605
//**************************
606
// Detects if the current browser is on a PalmOS device.
607
DetectPalmOS : function() {
608
//Make sure it's not WebOS first
609
if (this.DetectPalmWebOS())
610
return false;
611
612
//Most devices nowadays report as 'Palm',
613
// but some older ones reported as Blazer or Xiino.
614
if (this.uagent.search(this.devicePalm) > -1 ||
615
this.uagent.search(this.engineBlazer) > -1 ||
616
this.uagent.search(this.engineXiino) > -1)
617
return true;
618
else
619
return false;
620
},
621
622
//**************************
623
// Detects if the current browser is on a Palm device
624
// running the new WebOS.
625
DetectPalmWebOS : function()
626
{
627
if (this.uagent.search(this.deviceWebOS) > -1)
628
return true;
629
else
630
return false;
631
},
632
633
//**************************
634
// Detects if the current browser is on an HP tablet running WebOS.
635
DetectWebOSTablet : function() {
636
if (this.uagent.search(this.deviceWebOShp) > -1 &&
637
this.uagent.search(this.deviceTablet) > -1)
638
return true;
639
else
640
return false;
641
},
642
643
//**************************
644
// Detects if the current browser is on a WebOS smart TV.
645
DetectWebOSTV : function() {
646
if (this.uagent.search(this.deviceWebOStv) > -1 &&
647
this.uagent.search(this.smartTV2) > -1)
648
return true;
649
else
650
return false;
651
},
652
653
654
//OPERA
655
656
//**************************
657
// Detects if the current browser is Opera Mobile or Mini.
658
// Note: Older embedded Opera on mobile devices didn't follow these naming conventions.
659
// Like Archos media players, they will probably show up in DetectMobileQuick or -Long instead.
660
DetectOperaMobile : function() {
661
if ((this.uagent.search(this.engineOpera) > -1) &&
662
((this.uagent.search(this.mini) > -1 ||
663
this.uagent.search(this.mobi) > -1)))
664
return true;
665
else
666
return false;
667
},
668
669
670
//MISCELLANEOUS DEVICES
671
672
//**************************
673
// Detects if the current device is an Amazon Kindle (eInk devices only).
674
// Note: For the Kindle Fire, use the normal Android methods.
675
DetectKindle : function() {
676
if (this.uagent.search(this.deviceKindle) > -1 &&
677
!this.DetectAndroid())
678
return true;
679
else
680
return false;
681
},
682
683
//**************************
684
// Detects if the current Amazon device has turned on the Silk accelerated browsing feature.
685
// Note: Typically used by the the Kindle Fire.
686
DetectAmazonSilk : function() {
687
if (this.uagent.search(this.engineSilk) > -1)
688
return true;
689
else
690
return false;
691
},
692
693
//**************************
694
// Detects if the current browser is a
695
// Garmin Nuvifone.
696
DetectGarminNuvifone : function() {
697
if (this.uagent.search(this.deviceNuvifone) > -1)
698
return true;
699
else
700
return false;
701
},
702
703
//**************************
704
// Detects a device running the Bada OS from Samsung.
705
DetectBada : function() {
706
if (this.uagent.search(this.deviceBada) > -1)
707
return true;
708
else
709
return false;
710
},
711
712
//**************************
713
// Detects a device running the Tizen smartphone OS.
714
DetectTizen : function() {
715
if (this.uagent.search(this.deviceTizen) > -1 &&
716
this.uagent.search(this.mobile) > -1)
717
return true;
718
else
719
return false;
720
},
721
722
//**************************
723
// Detects if the current browser is on a Tizen smart TV.
724
DetectTizenTV : function() {
725
if (this.uagent.search(this.deviceTizen) > -1 &&
726
this.uagent.search(this.smartTV1) > -1)
727
return true;
728
else
729
return false;
730
},
731
732
//**************************
733
// Detects a device running the Meego OS.
734
DetectMeego : function() {
735
if (this.uagent.search(this.deviceMeego) > -1)
736
return true;
737
else
738
return false;
739
},
740
741
//**************************
742
// Detects a phone running the Meego OS.
743
DetectMeegoPhone : function() {
744
if (this.uagent.search(this.deviceMeego) > -1 &&
745
this.uagent.search(this.mobi) > -1)
746
return true;
747
else
748
return false;
749
},
750
751
//**************************
752
// Detects a mobile device (probably) running the Firefox OS.
753
DetectFirefoxOS : function() {
754
if (this.DetectFirefoxOSPhone() || this.DetectFirefoxOSTablet())
755
return true;
756
else
757
return false;
758
},
759
760
//**************************
761
// Detects a phone (probably) running the Firefox OS.
762
DetectFirefoxOSPhone : function() {
763
//First, let's make sure we're NOT on another major mobile OS.
764
if (this.DetectIos() ||
765
this.DetectAndroid() ||
766
this.DetectSailfish())
767
return false;
768
769
if ((this.uagent.search(this.engineFirefox) > -1) &&
770
(this.uagent.search(this.mobile) > -1))
771
return true;
772
773
return false;
774
},
775
776
//**************************
777
// Detects a tablet (probably) running the Firefox OS.
778
DetectFirefoxOSTablet : function() {
779
//First, let's make sure we're NOT on another major mobile OS.
780
if (this.DetectIos() ||
781
this.DetectAndroid() ||
782
this.DetectSailfish())
783
return false;
784
785
if ((this.uagent.search(this.engineFirefox) > -1) &&
786
(this.uagent.search(this.deviceTablet) > -1))
787
return true;
788
789
return false;
790
},
791
792
//**************************
793
// Detects a device running the Sailfish OS.
794
DetectSailfish : function() {
795
if (this.uagent.search(this.deviceSailfish) > -1)
796
return true;
797
else
798
return false;
799
},
800
801
//**************************
802
// Detects a phone running the Sailfish OS.
803
DetectSailfishPhone : function() {
804
if (this.DetectSailfish() && (this.uagent.search(this.mobile) > -1))
805
return true;
806
807
return false;
808
},
809
810
811
//**************************
812
// Detects a mobile device running the Ubuntu Mobile OS.
813
DetectUbuntu : function() {
814
if (this.DetectUbuntuPhone() || this.DetectUbuntuTablet())
815
return true;
816
else
817
return false;
818
},
819
820
//**************************
821
// Detects a phone running the Ubuntu Mobile OS.
822
DetectUbuntuPhone : function() {
823
if ((this.uagent.search(this.deviceUbuntu) > -1) &&
824
(this.uagent.search(this.mobile) > -1))
825
return true;
826
827
return false;
828
},
829
830
//**************************
831
// Detects a tablet running the Ubuntu Mobile OS.
832
DetectUbuntuTablet : function() {
833
if ((this.uagent.search(this.deviceUbuntu) > -1) &&
834
(this.uagent.search(this.deviceTablet) > -1))
835
return true;
836
837
return false;
838
},
839
840
//**************************
841
// Detects the Danger Hiptop device.
842
DetectDangerHiptop : function() {
843
if (this.uagent.search(this.deviceDanger) > -1 ||
844
this.uagent.search(this.deviceHiptop) > -1)
845
return true;
846
else
847
return false;
848
},
849
850
//**************************
851
// Detects if the current browser is a Sony Mylo device.
852
DetectSonyMylo : function() {
853
if ((this.uagent.search(this.manuSony) > -1) &&
854
((this.uagent.search(this.qtembedded) > -1) ||
855
(this.uagent.search(this.mylocom2) > -1)))
856
return true;
857
else
858
return false;
859
},
860
861
//**************************
862
// Detects if the current device is on one of
863
// the Maemo-based Nokia Internet Tablets.
864
DetectMaemoTablet : function() {
865
if (this.uagent.search(this.maemo) > -1)
866
return true;
867
//For Nokia N810, must be Linux + Tablet, or else it could be something else.
868
if ((this.uagent.search(this.linux) > -1) &&
869
(this.uagent.search(this.deviceTablet) > -1) &&
870
this.DetectWebOSTablet() &&
871
!this.DetectAndroid())
872
return true;
873
else
874
return false;
875
},
876
877
//**************************
878
// Detects if the current device is an Archos media player/Internet tablet.
879
DetectArchos : function() {
880
if (this.uagent.search(this.deviceArchos) > -1)
881
return true;
882
else
883
return false;
884
},
885
886
//**************************
887
// Detects if the current device is an Internet-capable game console.
888
// Includes many handheld consoles.
889
DetectGameConsole : function() {
890
if (this.DetectSonyPlaystation() ||
891
this.DetectNintendo() ||
892
this.DetectXbox())
893
return true;
894
else
895
return false;
896
},
897
898
//**************************
899
// Detects if the current device is a Sony Playstation.
900
DetectSonyPlaystation : function() {
901
if (this.uagent.search(this.devicePlaystation) > -1)
902
return true;
903
else
904
return false;
905
},
906
907
//**************************
908
// Detects if the current device is a handheld gaming device with
909
// a touchscreen and modern iPhone-class browser. Includes the Playstation Vita.
910
DetectGamingHandheld : function() {
911
if ((this.uagent.search(this.devicePlaystation) > -1) &&
912
(this.uagent.search(this.devicePlaystationVita) > -1))
913
return true;
914
else
915
return false;
916
},
917
918
//**************************
919
// Detects if the current device is a Nintendo game device.
920
DetectNintendo : function() {
921
if (this.uagent.search(this.deviceNintendo) > -1 ||
922
this.uagent.search(this.deviceWii) > -1 ||
923
this.uagent.search(this.deviceNintendoDs) > -1)
924
return true;
925
else
926
return false;
927
},
928
929
//**************************
930
// Detects if the current device is a Microsoft Xbox.
931
DetectXbox : function() {
932
if (this.uagent.search(this.deviceXbox) > -1)
933
return true;
934
else
935
return false;
936
},
937
938
939
//**************************
940
// Detects whether the device is a Brew-powered device.
941
// Note: Limited to older Brew-powered feature phones.
942
// Ignores newer Brew versions like MP. Refer to DetectMobileQuick().
943
DetectBrewDevice : function() {
944
if (this.uagent.search(this.deviceBrew) > -1)
945
return true;
946
else
947
return false;
948
},
949
950
951
// DEVICE CLASSES
952
953
//**************************
954
// Check to see whether the device is *any* 'smartphone'.
955
// Note: It's better to use DetectTierIphone() for modern touchscreen devices.
956
DetectSmartphone : function() {
957
//Exclude duplicates from TierIphone
958
if (this.DetectTierIphone() ||
959
this.DetectS60OssBrowser() ||
960
this.DetectSymbianOS() ||
961
this.DetectWindowsMobile() ||
962
this.DetectBlackBerry() ||
963
this.DetectMeegoPhone() ||
964
this.DetectPalmOS())
965
return true;
966
967
//Otherwise, return false.
968
return false;
969
},
970
971
//**************************
972
// Detects if the current device is a mobile device.
973
// This method catches most of the popular modern devices.
974
// Excludes Apple iPads and other modern tablets.
975
DetectMobileQuick : function() {
976
if (this.initCompleted || this.isMobilePhone)
977
return this.isMobilePhone;
978
979
//Let's exclude tablets.
980
if (this.DetectTierTablet())
981
return false;
982
983
//Most mobile browsing is done on smartphones
984
if (this.DetectSmartphone())
985
return true;
986
987
//Catch-all for many mobile devices
988
if (this.uagent.search(this.mobile) > -1)
989
return true;
990
991
if (this.DetectOperaMobile())
992
return true;
993
994
//We also look for Kindle devices
995
if (this.DetectKindle() ||
996
this.DetectAmazonSilk())
997
return true;
998
999
if (this.uagent.search(this.deviceMidp) > -1 ||
1000
this.DetectBrewDevice())
1001
return true;
1002
1003
if ((this.uagent.search(this.engineObigo) > -1) ||
1004
(this.uagent.search(this.engineNetfront) > -1) ||
1005
(this.uagent.search(this.engineUpBrowser) > -1))
1006
return true;
1007
1008
return false;
1009
},
1010
1011
//**************************
1012
// Detects in a more comprehensive way if the current device is a mobile device.
1013
DetectMobileLong : function() {
1014
if (this.DetectMobileQuick())
1015
return true;
1016
if (this.DetectGameConsole())
1017
return true;
1018
1019
if (this.DetectDangerHiptop() ||
1020
this.DetectMaemoTablet() ||
1021
this.DetectSonyMylo() ||
1022
this.DetectArchos())
1023
return true;
1024
1025
if ((this.uagent.search(this.devicePda) > -1) &&
1026
!(this.uagent.search(this.disUpdate) > -1))
1027
return true;
1028
1029
//Detect for certain very old devices with stupid useragent strings.
1030
if ((this.uagent.search(this.manuSamsung1) > -1) ||
1031
(this.uagent.search(this.manuSonyEricsson) > -1) ||
1032
(this.uagent.search(this.manuericsson) > -1) ||
1033
(this.uagent.search(this.svcDocomo) > -1) ||
1034
(this.uagent.search(this.svcKddi) > -1) ||
1035
(this.uagent.search(this.svcVodafone) > -1))
1036
return true;
1037
1038
return false;
1039
},
1040
1041
//*****************************
1042
// For Mobile Web Site Design
1043
//*****************************
1044
1045
//**************************
1046
// The quick way to detect for a tier of devices.
1047
// This method detects for the new generation of
1048
// HTML 5 capable, larger screen tablets.
1049
// Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc.
1050
DetectTierTablet : function() {
1051
if (this.initCompleted || this.isTierTablet)
1052
return this.isTierTablet;
1053
1054
if (this.DetectIpad() ||
1055
this.DetectAndroidTablet() ||
1056
this.DetectBlackBerryTablet() ||
1057
this.DetectFirefoxOSTablet() ||
1058
this.DetectUbuntuTablet() ||
1059
this.DetectWebOSTablet())
1060
return true;
1061
else
1062
return false;
1063
},
1064
1065
//**************************
1066
// The quick way to detect for a tier of devices.
1067
// This method detects for devices which can
1068
// display iPhone-optimized web content.
1069
// Includes iPhone, iPod Touch, Android, Windows Phone 7 and 8, BB10, WebOS, Playstation Vita, etc.
1070
DetectTierIphone : function() {
1071
if (this.initCompleted || this.isTierIphone)
1072
return this.isTierIphone;
1073
1074
if (this.DetectIphoneOrIpod() ||
1075
this.DetectAndroidPhone() ||
1076
this.DetectWindowsPhone() ||
1077
this.DetectBlackBerry10Phone() ||
1078
this.DetectPalmWebOS() ||
1079
this.DetectBada() ||
1080
this.DetectTizen() ||
1081
this.DetectFirefoxOSPhone() ||
1082
this.DetectSailfishPhone() ||
1083
this.DetectUbuntuPhone() ||
1084
this.DetectGamingHandheld())
1085
return true;
1086
1087
//Note: BB10 phone is in the previous paragraph
1088
if (this.DetectBlackBerryWebKit() && this.DetectBlackBerryTouch())
1089
return true;
1090
1091
else
1092
return false;
1093
},
1094
1095
//**************************
1096
// The quick way to detect for a tier of devices.
1097
// This method detects for devices which are likely to be
1098
// capable of viewing CSS content optimized for the iPhone,
1099
// but may not necessarily support JavaScript.
1100
// Excludes all iPhone Tier devices.
1101
DetectTierRichCss : function() {
1102
if (this.initCompleted || this.isTierRichCss)
1103
return this.isTierRichCss;
1104
1105
//Exclude iPhone and Tablet Tiers and e-Ink Kindle devices
1106
if (this.DetectTierIphone() ||
1107
this.DetectKindle() ||
1108
this.DetectTierTablet())
1109
return false;
1110
1111
//Exclude if not mobile
1112
if (!this.DetectMobileQuick())
1113
return false;
1114
1115
//If it's a mobile webkit browser on any other device, it's probably OK.
1116
if (this.DetectWebkit())
1117
return true;
1118
1119
//The following devices are also explicitly ok.
1120
if (this.DetectS60OssBrowser() ||
1121
this.DetectBlackBerryHigh() ||
1122
this.DetectWindowsMobile() ||
1123
(this.uagent.search(this.engineTelecaQ) > -1))
1124
return true;
1125
1126
else
1127
return false;
1128
},
1129
1130
//**************************
1131
// The quick way to detect for a tier of devices.
1132
// This method detects for all other types of phones,
1133
// but excludes the iPhone and RichCSS Tier devices.
1134
// NOTE: This method probably won't work due to poor
1135
// support for JavaScript among other devices.
1136
DetectTierOtherPhones : function() {
1137
if (this.initCompleted || this.isTierGenericMobile)
1138
return this.isTierGenericMobile;
1139
1140
//Exclude iPhone, Rich CSS and Tablet Tiers
1141
if (this.DetectTierIphone() ||
1142
this.DetectTierRichCss() ||
1143
this.DetectTierTablet())
1144
return false;
1145
1146
//Otherwise, if it's mobile, it's OK
1147
if (this.DetectMobileLong())
1148
return true;
1149
1150
else
1151
return false;
1152
}
1153
1154
};
1155
1156
//Initialize the MobileEsp object
1157
MobileEsp.InitDeviceScan();
1158
1159
1160
1161
1162