2021-12-19 15:20:21 +09:00
|
|
|
import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core';
|
2021-11-09 22:25:03 -03:00
|
|
|
import { StateService } from 'src/app/services/state.service';
|
|
|
|
import { specialBlocks } from 'src/app/app.constants';
|
2020-02-16 22:15:07 +07:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-start',
|
|
|
|
templateUrl: './start.component.html',
|
2020-08-02 16:00:08 +07:00
|
|
|
styleUrls: ['./start.component.scss'],
|
2020-02-16 22:15:07 +07:00
|
|
|
})
|
2021-11-09 22:25:03 -03:00
|
|
|
export class StartComponent implements OnInit {
|
|
|
|
interval = 60;
|
|
|
|
colors = ['#5E35B1', '#ffffff'];
|
|
|
|
|
2021-11-12 20:24:15 +04:00
|
|
|
countdown = 0;
|
2021-11-09 22:25:03 -03:00
|
|
|
specialEvent = false;
|
|
|
|
eventName = '';
|
2021-12-19 15:20:21 +09:00
|
|
|
mouseDragStartX: number;
|
|
|
|
blockchainScrollLeftInit: number;
|
|
|
|
@ViewChild('blockchainContainer') blockchainContainer: ElementRef;
|
2021-11-09 22:25:03 -03:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private stateService: StateService,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.stateService.blocks$
|
|
|
|
.subscribe((blocks: any) => {
|
2021-11-12 20:24:15 +04:00
|
|
|
if (this.stateService.network !== '') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.countdown = 0;
|
2021-11-09 22:25:03 -03:00
|
|
|
const block = blocks[0];
|
2021-11-12 20:24:15 +04:00
|
|
|
|
|
|
|
for (const sb in specialBlocks) {
|
|
|
|
const height = parseInt(sb, 10);
|
|
|
|
const diff = height - block.height;
|
|
|
|
if (diff > 0 && diff <= 1008) {
|
|
|
|
this.countdown = diff;
|
|
|
|
this.eventName = specialBlocks[sb].labelEvent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (specialBlocks[block.height]) {
|
2021-11-09 22:25:03 -03:00
|
|
|
this.specialEvent = true;
|
2021-11-12 20:24:15 +04:00
|
|
|
this.eventName = specialBlocks[block.height].labelEventCompleted;
|
2021-11-09 22:25:03 -03:00
|
|
|
setTimeout(() => {
|
|
|
|
this.specialEvent = false;
|
|
|
|
}, 60 * 60 * 1000);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-12-19 15:20:21 +09:00
|
|
|
onMouseDown(event: MouseEvent) {
|
|
|
|
this.mouseDragStartX = event.clientX;
|
|
|
|
this.blockchainScrollLeftInit = this.blockchainContainer.nativeElement.scrollLeft;
|
|
|
|
}
|
|
|
|
onDragStart(event: MouseEvent) { // Ignore Firefox annoying default drag behavior
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're catching the whole page event here because we still want to scroll blocks
|
|
|
|
// even if the mouse leave the blockchain blocks container. Same idea for mouseup below.
|
|
|
|
@HostListener('document:mousemove', ['$event'])
|
|
|
|
onMouseMove(event: MouseEvent): void {
|
|
|
|
if (this.mouseDragStartX != null) {
|
|
|
|
this.stateService.setBlockScrollingInProgress(true);
|
|
|
|
this.blockchainContainer.nativeElement.scrollLeft =
|
|
|
|
this.blockchainScrollLeftInit + this.mouseDragStartX - event.clientX
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@HostListener('document:mouseup', [])
|
|
|
|
onMouseUp() {
|
|
|
|
this.mouseDragStartX = null;
|
|
|
|
this.stateService.setBlockScrollingInProgress(false);
|
|
|
|
}
|
2020-02-16 22:15:07 +07:00
|
|
|
}
|