diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts deleted file mode 100644 index 0abf337..0000000 --- a/src/app/app-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { FiveoclockComponent } from './fiveoclock/fiveoclock.component'; -import { TimezoneListComponent } from './timezone/components/timezone-list/timezone-list.component'; - -const routes: Routes = [ - { path: '', component: FiveoclockComponent }, -]; - -@NgModule({ - imports: [RouterModule.forRoot(routes)], - exports: [RouterModule] -}) -export class AppRoutingModule { } diff --git a/src/app/app.component.html b/src/app/app.component.html index 90c6b64..f85f4a0 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1,7 @@ - \ No newline at end of file + + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 5916a01..b2f5015 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,9 @@ import { Component } from '@angular/core'; import { NavigationEnd, Router } from '@angular/router'; +import { interval, startWith } from 'rxjs'; +import { GoogleAnalyticsService } from './services/google-analytics.service'; +import { Timezone, GetClosestTimezoneFrom } from './timezone/models/timezone.model'; +import { TimezoneService } from './timezone/services/timezone.service'; declare let gtag: Function; @Component({ @@ -9,13 +13,53 @@ declare let gtag: Function; }) export class AppComponent { - constructor(public router: Router) { - this.router.events.subscribe(event => { - if (event instanceof NavigationEnd) { - gtag('config', 'G-48B6CKS0V6',{ - 'page_path': event.urlAfterRedirects - }); - } + fiveOclocks: Timezone[] = []; + fiveOclock: Timezone | undefined; + + showAll: boolean = false; + + timezones: string[] =[] + + constructor( + private timezoneService: TimezoneService, + private googleAnalyticsService: GoogleAnalyticsService, + private router:Router + ){ + this.router.events.subscribe(event => { + if (event instanceof NavigationEnd) { + gtag('config', 'G-48B6CKS0V6',{ + 'page_path': event.urlAfterRedirects + }); + } + }) + this.timezones = this.timezoneService.getTimezones() + var second = interval(1000).pipe(startWith(0)) + + second.subscribe(()=>{ + this.fiveOclocks = []; + this.timezoneService.getCurrentTimeInTimezones(this.timezones).forEach((timezoneObj)=>{ + if(timezoneObj.time?.hour === 17){ + this.fiveOclocks.push(timezoneObj); + } + }) + this.fiveOclock = GetClosestTimezoneFrom(this.timezoneService.getCurrentTimezone(), this.fiveOclocks) }) + + } + + ngOnInit(): void { } + + toggleView(){ + if(this.showAll){ + this.googleAnalyticsService.emitEvent('select_content', { + 'event_label' : 'timezone_closest', + }) + }else{ + this.googleAnalyticsService.emitEvent('select_content', { + 'event_label' : 'timezone_list', + }) + } + this.showAll = !this.showAll + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 434a145..10c3180 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -4,20 +4,16 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { AppComponent } from './app.component'; import { TimezoneService } from './timezone/services/timezone.service'; -import { AppRoutingModule } from './app-routing.module'; import { TimezoneListComponent } from './timezone/components/timezone-list/timezone-list.component'; -import { FiveoclockComponent } from './fiveoclock/fiveoclock.component'; import { GoogleAnalyticsService } from './services/google-analytics.service'; @NgModule({ declarations: [ AppComponent, TimezoneListComponent, - FiveoclockComponent ], imports: [ BrowserModule, BrowserAnimationsModule, - AppRoutingModule ], providers: [ TimezoneService, diff --git a/src/app/fiveoclock/fiveoclock.component.html b/src/app/fiveoclock/fiveoclock.component.html deleted file mode 100644 index f85f4a0..0000000 --- a/src/app/fiveoclock/fiveoclock.component.html +++ /dev/null @@ -1,7 +0,0 @@ - - diff --git a/src/app/fiveoclock/fiveoclock.component.scss b/src/app/fiveoclock/fiveoclock.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/fiveoclock/fiveoclock.component.spec.ts b/src/app/fiveoclock/fiveoclock.component.spec.ts deleted file mode 100644 index 9b75fdf..0000000 --- a/src/app/fiveoclock/fiveoclock.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { FiveoclockComponent } from './fiveoclock.component'; - -describe('FiveoclockComponent', () => { - let component: FiveoclockComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ FiveoclockComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(FiveoclockComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/fiveoclock/fiveoclock.component.ts b/src/app/fiveoclock/fiveoclock.component.ts deleted file mode 100644 index f8826bb..0000000 --- a/src/app/fiveoclock/fiveoclock.component.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { interval, startWith } from 'rxjs'; -import { GoogleAnalyticsService } from '../services/google-analytics.service'; -import { GetClosestTimezoneFrom, Timezone, TimezoneCompare, TimezoneList } from '../timezone/models/timezone.model'; -import { TimezoneService } from '../timezone/services/timezone.service'; - -@Component({ - selector: 'app-fiveoclock', - templateUrl: './fiveoclock.component.html', - styleUrls: ['./fiveoclock.component.scss'] -}) -export class FiveoclockComponent implements OnInit { - - fiveOclocks: Timezone[] = []; - fiveOclock: Timezone | undefined; - - showAll: boolean = false; - - timezones: string[] =[] - - constructor( - private timezoneService: TimezoneService, - private googleAnalyticsService: GoogleAnalyticsService - ){ - this.timezones = this.timezoneService.getTimezones() - var second = interval(1000).pipe(startWith(0)) - - second.subscribe(()=>{ - this.fiveOclocks = []; - this.timezoneService.getCurrentTimeInTimezones(this.timezones).forEach((timezoneObj)=>{ - if(timezoneObj.time?.hour === 17){ - this.fiveOclocks.push(timezoneObj); - } - }) - this.fiveOclock = GetClosestTimezoneFrom(this.timezoneService.getCurrentTimezone(), this.fiveOclocks) - }) - - } - - ngOnInit(): void { } - - toggleView(){ - if(this.showAll){ - this.googleAnalyticsService.emitEvent('select_content', { - 'event_label' : 'timezone_closest', - }) - }else{ - this.googleAnalyticsService.emitEvent('select_content', { - 'event_label' : 'timezone_list', - }) - } - this.showAll = !this.showAll - - } - -} diff --git a/src/favicon.ico b/src/favicon.ico new file mode 100644 index 0000000..8818f96 Binary files /dev/null and b/src/favicon.ico differ diff --git a/src/index.html b/src/index.html index d6ada37..feb08b4 100644 --- a/src/index.html +++ b/src/index.html @@ -6,7 +6,7 @@ itsfiveoclockwhere - + ng serv