File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ import { todayLocalDate } from "../utils/common" ;
2+
3+ export class Tab {
4+ url : string ;
5+ favicon : string ;
6+ summaryTime : number = 0 ;
7+ counter : number = 0
8+ days : TabDay [ ] = [ ] ;
9+
10+ constructor ( url : string , favicon : string ) {
11+ this . url = url ;
12+ this . favicon = favicon ;
13+ }
14+
15+ incSummaryTime ( ) :void {
16+ this . summaryTime += 1 ;
17+
18+ const day = this . days . find ( x => x . date == todayLocalDate ( ) ) ;
19+ if ( day === undefined )
20+ this . addNewDay ( ) ;
21+ else day . incSummaryTime ( ) ;
22+ }
23+
24+ incCounter ( ) :void {
25+ this . counter += 1 ;
26+ const day = this . days . find ( x => x . date == todayLocalDate ( ) ) ;
27+ if ( day === undefined )
28+ this . addNewDay ( ) ;
29+ else day . incCounter ( )
30+ }
31+
32+ addNewDay ( ) :void {
33+ const newTabDay = new TabDay ( todayLocalDate ( ) ) ;
34+ this . days . push ( newTabDay ) ;
35+ }
36+ }
37+
38+ export class TabDay {
39+ counter : number ;
40+ date : string ;
41+ summary : number ;
42+
43+ constructor ( date : string ) {
44+ this . date = date ;
45+ this . counter = 1 ;
46+ this . summary = 1 ;
47+ }
48+
49+ incSummaryTime ( ) :void {
50+ this . summary += 1 ;
51+ }
52+
53+ incCounter ( ) :void {
54+ this . counter += 1 ;
55+ }
56+ }
Original file line number Diff line number Diff line change 1+ export function todayLocalDate ( ) {
2+ return new Date ( ) . toLocaleDateString ( 'en-US' ) ;
3+ }
You can’t perform that action at this time.
0 commit comments