forked from MicrosoftDX/Vorlonjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvorlon.tools.ts
77 lines (62 loc) · 2.06 KB
/
vorlon.tools.ts
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
export module VORLON {
export class Tools {
public static GetOperatingSystem(ua: string) {
var currentLowerUA = ua.toLowerCase();
// Windows Phone
if (currentLowerUA.indexOf("windows phone") >= 0) {
return "Windows Phone";
}
// Windows
if (currentLowerUA.indexOf("windows") >= 0) {
return "Windows";
}
// Android
if (currentLowerUA.indexOf("android") >= 0) {
return "Android";
}
// iOS
if (currentLowerUA.indexOf("apple-i") >= 0) {
return "iOS";
}
if (currentLowerUA.indexOf("iphone") >= 0) {
return "iOS";
}
if (currentLowerUA.indexOf("ipad") >= 0) {
return "iOS";
}
// BlackBerry
if (currentLowerUA.indexOf("blackberry") >= 0) {
return "BlackBerry";
}
// BlackBerry
if (currentLowerUA.indexOf("(bb") >= 0) {
return "BlackBerry";
}
// Kindle
if (currentLowerUA.indexOf("kindle") >= 0) {
return "Kindle";
}
// Macintosh
if (currentLowerUA.indexOf("macintosh") >= 0) {
return "Macintosh";
}
// Linux
if (currentLowerUA.indexOf("linux") >= 0) {
return "Linux";
}
// OpenBSD
if (currentLowerUA.indexOf("openbsd") >= 0) {
return "OpenBSD";
}
// Firefox OS
if (currentLowerUA.indexOf("firefox") >= 0) {
return "Firefox OS"; // Web is the plaform
}
// Node.js
if (currentLowerUA.indexOf("node.js") >= 0) {
return "Node.js";
}
return "Unknown operating system";
}
}
}