-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
42 lines (39 loc) · 1.29 KB
/
index.ts
File metadata and controls
42 lines (39 loc) · 1.29 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
class ITM {
private containing: any;
private browser: boolean = false;
constructor() {
//code goes here
}
/**
* [browserDetect - This method is to know when the user is using Internet Explorer]
*/
private browserDetect() {
if ((navigator.userAgent.indexOf('Trident/7.0') > 0) ||
(/MSIE 10/i.test(navigator.userAgent)) ||
(/MSIE 9/i.test(navigator.userAgent) ||
/rv:11.0/i.test(navigator.userAgent))) {
this.browser = true;
}
}
/**
* [includesToMatch - Depending on the browser, this method compares your variables using the include or the match Javascript function,
* enabling it to work with the last breakthrough tecnologies of ES]
*/
public includesToMatch(variableToCompare: string, containing: Array<string>) {
let variableToMatch: string;
this.browserDetect()
this.containing = containing;
if (this.browser) {
for (let i = 0; i < containing.length; i++) {
if (variableToCompare.match(containing[i])) {
return true;
}
}
} else {
if (this.containing.includes(variableToCompare)) {
return true;
}
}
return false;
}
}