forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBrowser.js
More file actions
122 lines (98 loc) · 3.5 KB
/
Browser.js
File metadata and controls
122 lines (98 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
var OS = require('./OS');
var Browser = {
// @property {boolean} arora - Set to true if running in Arora.
arora: false,
// @property {boolean} chrome - Set to true if running in Chrome.
chrome: false,
// @property {number} chromeVersion - If running in Chrome this will contain the major version number.
chromeVersion: 0,
// @property {boolean} epiphany - Set to true if running in Epiphany.
epiphany: false,
// @property {boolean} firefox - Set to true if running in Firefox.
firefox: false,
// @property {number} firefoxVersion - If running in Firefox this will contain the major version number.
firefoxVersion: 0,
// @property {boolean} mobileSafari - Set to true if running in Mobile Safari.
mobileSafari: false,
// @property {boolean} ie - Set to true if running in Internet Explorer.
ie: false,
// @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Device.trident and Device.tridentVersion.
ieVersion: 0,
// @property {boolean} midori - Set to true if running in Midori.
midori: false,
// @property {boolean} opera - Set to true if running in Opera.
opera: false,
// @property {boolean} safari - Set to true if running in Safari.
safari: false,
// @property {number} safariVersion - If running in Safari this will contain the major version number.
safariVersion: 0,
// @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+)
trident: false,
// @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx}
tridentVersion: 0,
// @property {boolean} edge - Set to true if running in Microsoft Edge browser.
edge: false,
// @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle)
silk: false
};
function init ()
{
var ua = navigator.userAgent;
if ((/Arora/).test(ua))
{
Browser.arora = true;
}
else if (/Edge\/\d+/.test(ua))
{
Browser.edge = true;
}
else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone)
{
Browser.chrome = true;
Browser.chromeVersion = parseInt(RegExp.$1, 10);
}
else if ((/Epiphany/).test(ua))
{
Browser.epiphany = true;
}
else if ((/Firefox\D+(\d+)/).test(ua))
{
Browser.firefox = true;
Browser.firefoxVersion = parseInt(RegExp.$1, 10);
}
else if ((/AppleWebKit/).test(ua) && OS.iOS)
{
Browser.mobileSafari = true;
}
else if ((/MSIE (\d+\.\d+);/).test(ua))
{
Browser.ie = true;
Browser.ieVersion = parseInt(RegExp.$1, 10);
}
else if ((/Midori/).test(ua))
{
Browser.midori = true;
}
else if ((/Opera/).test(ua))
{
Browser.opera = true;
}
else if ((/Safari/).test(ua) && !OS.windowsPhone)
{
Browser.safari = true;
}
else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua))
{
Browser.ie = true;
Browser.trident = true;
Browser.tridentVersion = parseInt(RegExp.$1, 10);
Browser.ieVersion = parseInt(RegExp.$3, 10);
}
// Silk gets its own if clause because its ua also contains 'Safari'
if ((/Silk/).test(ua))
{
Browser.silk = true;
}
return Browser;
}
module.exports = init();