From cb82afaf56c25b9547520bbe32eaf8b631655c7f Mon Sep 17 00:00:00 2001 From: vivek blaze Date: Thu, 18 Jun 2020 21:43:01 +0530 Subject: [PATCH] countdown timer --- src/app/view/home/home-worksapce.component.ts | 62 +++++++++++++++++-- src/environments/environment.ts | 7 ++- 2 files changed, 60 insertions(+), 9 deletions(-) diff --git a/src/app/view/home/home-worksapce.component.ts b/src/app/view/home/home-worksapce.component.ts index b0c169b..8db39ad 100644 --- a/src/app/view/home/home-worksapce.component.ts +++ b/src/app/view/home/home-worksapce.component.ts @@ -4,18 +4,31 @@ import { Utils } from 'src/app/shared/utils'; import { Router } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { ActivatedRoute } from '@angular/router'; +import { environment } from 'src/environments/environment'; +import { ChartService } from 'src/app/shared/services/chart.service'; @Component({ selector: 'epic-explorer-home-worksapce', template: ` -
+
-
-
+
+ -
+
+ + +
+
+
+

+ Countdown to Halving {{countDownDate}} Blocks to go {{demo}}

+
+
+
+
{ + this.chartService + .apiGetRequest("", "/blockchain_block/latesblockdetails") + .subscribe( + res => { + if (res["status"] == 200) { + this.countDownDate = environment.TARGETBLOCK - res.response.block_height; + resolve(); + } + }, + error => {} + ); +}); + + var d1 = new Date (); + + let x = setInterval(() => { + var d2 = new Date ( d1 ); + d2.setMinutes ( d1.getMinutes() + this.countDownDate ); + let now = new Date().getTime(); + let distance = d2.getTime() - now; + let days = Math.floor(distance / (1000 * 60 * 60 * 24)); + let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); + let seconds = Math.floor((distance % (1000 * 60)) / 1000); + + this.demo = days + ' days ' + hours + ' hours ' + minutes + ' mins ' + seconds + ' sec'; + + if (distance < 0) { + clearInterval(x); + this.demo = 'Expired...'; + } + }, 1000); + } viewchartenable() { this.viewchartvar = false; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 4696f83..428a85f 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,9 +4,10 @@ export const environment = { production: false, - domain: 'https://explorer.epic.tech/', - apiUrl: 'https://explorer.epic.tech/epic_explorer/v1', - EMAIL : 'contact@epic.tech' + domain: 'https://explorer3.epic.tech/', + apiUrl: 'https://explorer3.epic.tech/epic_explorer/v1', + EMAIL : 'contact@epic.tech', + TARGETBLOCK: 480960 }; /*