forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtab.ts
More file actions
56 lines (46 loc) · 1.17 KB
/
tab.ts
File metadata and controls
56 lines (46 loc) · 1.17 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
import { todayLocalDate } from "../utils/common";
export class Tab {
url: string;
favicon: string;
summaryTime: number = 0;
counter: number = 0
days: TabDay[] = [];
constructor(url: string, favicon: string){
this.url = url;
this.favicon = favicon;
}
incSummaryTime() :void {
this.summaryTime += 1;
const day = this.days.find(x => x.date == todayLocalDate());
if (day === undefined)
this.addNewDay();
else day.incSummaryTime();
}
incCounter() :void {
this.counter +=1;
const day = this.days.find(x => x.date == todayLocalDate());
if (day === undefined)
this.addNewDay();
else day.incCounter()
}
addNewDay() :void {
const newTabDay = new TabDay(todayLocalDate());
this.days.push(newTabDay);
}
}
export class TabDay {
counter: number;
date: string;
summary: number;
constructor(date: string){
this.date = date;
this.counter = 1;
this.summary = 1;
}
incSummaryTime() :void {
this.summary += 1;
}
incCounter() :void {
this.counter += 1;
}
}