This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 259
/
vorlon.tools.ts
103 lines (83 loc) · 3.05 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
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
export module VORLON {
export class Tools {
public static GetIconSystem(name: string) {
var os = [
{name: ['Windows'], icon: 'windows.png'},
{name: ['iOS', 'Macintosh'], icon: 'apple.png'},
{name: ['Windows Phone'], icon: 'windows_phone.png'},
{name: ['Firefox OS'], icon: 'firefox.png'},
{name: ['Kindle'], icon: 'kindle.png'},
{name: ['Android'], icon: 'android.png'},
{name: ['BlackBerry'], icon: 'bb.png'},
{name: ['Linux'], icon: 'linux.png'},
{name: ['Linux'], icon: 'nodejs.png'},
{name: ['OpenBSD'], icon: 'openbsd.png'},
{name: ['Node.js'], icon: 'nodejs.png'},
];
for (var i = 0, len = os.length; i < len; i++) {
if(os[i].name.indexOf(name) > -1) {
return os[i].icon;
}
}
return 'unknown.png';
}
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";
}
}
}