forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.ts
More file actions
24 lines (20 loc) · 634 Bytes
/
common.ts
File metadata and controls
24 lines (20 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
export function isEmpty(obj: any): boolean {
for (const prop in obj) {
if (obj.hasOwnProperty(prop)) return false;
}
return JSON.stringify(obj) === JSON.stringify({});
}
export function isDomainEquals(first: string, second: string) {
if (first === second) return true;
else {
var resultUrl = function (url: string) {
if (url.indexOf('www.') > -1) return url.split('www.')[1];
return url;
};
if (resultUrl(first) === resultUrl(second)) return true;
else return false;
}
}
export function getPercentage(time: number, totalTime: number) {
return ((time / totalTime) * 100).toFixed(2);
}