<commit_before>import { Component, OnInit } from '@angular/core';
import { ClockService } from './clock.service';
import { Globals } from '../../globals';
import { TranslateService } from 'ng2-translate';
import { EndpointService } from '../../components/endpoint/endpoint.service';
import { CountUp } from '../../components/count-up';
import { UserService } from '../../components/user/user.service';
import { Router } from '@angular/router';
import { CharacterService } from '../../components/character/character.service';

@Component({
  selector: 'app-navigation',
  templateUrl: 'navigation.component.html',
  styleUrls: ['navigation.component.scss'],
  providers: [ClockService],
})
export class NavigationComponent implements OnInit {

  hours: string = '00';
  minutes: string = '00';
  status: string = 'Offline';
  time: Object;
  char: number = 1;
  players: number;
  countup: CountUp;
  disable: boolean = true;

  constructor(private clock: ClockService,
              private router: Router,
              private globals: Globals,
              private translate: TranslateService,
              private es: EndpointService,
              private userService: UserService,
              private characterService: CharacterService) {
    this.characterService.characterChange.subscribe(character => {
      if (character) {
        this.char = character.characterId;
        this.disable = false;
      } else {
        this.char = 1;
        this.disable = true;
      }
    });
  }

  ngOnInit(): void {
    this.countup = new CountUp('eve-players', 0, 0);
    this.syncClock();
  }

  private syncClock(): void {
    this.clock.getTime().subscribe(
      (time) => {
        this.updateClock(time);
        setTimeout(() => {
          this.timeKeeper();
        }, 60000 - (time['seconds'] * 1000));
      }
    );
  }

  private timeKeeper(): void {
    this.updateClock(ClockService.tickTime(this.time));
    let eveTime = setInterval(() => {
      this.updateClock(ClockService.tickTime(this.time));
    }, 60000);
    setTimeout(() => {
      clearInterval(eveTime);
      this.syncClock();
    }, 180000);
  }

  private updateClock(time: Object): void {
    this.countup.reset();
    this.hours = time['hours'];
    this.minutes = time['minutes'];
    this.status = time['status'];
    this.time = time;
    setTimeout(() => {
      this.countup.update(time['players']);
    }, 400); // Compensate for pre-bootstrap-container fadeout
  }

  checkAccess(): boolean {
    if (this.disable) {
      return false;
    }
    // return this.char !== 1;
    return true;
  }

  logout(): void {
    this.userService.logoutUser();
  }

  // changeLanguage(lang: string): void {
  //   if (this.translate.currentLang === 'nl') {
  //     switchLanguage('en');
  //   } else {
  //     switchLanguage('nl');
  //   }
  // }
}<commit_msg>Wait for startup to be finished before doing the player-count-animation<commit_after>import { Component, OnInit } from '@angular/core';
import { ClockService } from './clock.service';
import { Globals } from '../../globals';
import { TranslateService } from 'ng2-translate';
import { EndpointService } from '../../components/endpoint/endpoint.service';
import { CountUp } from '../../components/count-up';
import { UserService } from '../../components/user/user.service';
import { Router } from '@angular/router';
import { CharacterService } from '../../components/character/character.service';

@Component({
  selector: 'app-navigation',
  templateUrl: 'navigation.component.html',
  styleUrls: ['navigation.component.scss'],
  providers: [ClockService],
})
export class NavigationComponent implements OnInit {

  hours: string = '00';
  minutes: string = '00';
  status: string = 'Offline';
  time: Object;
  char: number = 1;
  players: number = 0;
  countup: CountUp;
  disable: boolean = true;

  constructor(private clock: ClockService,
              private router: Router,
              private globals: Globals,
              private translate: TranslateService,
              private es: EndpointService,
              private userService: UserService,
              private characterService: CharacterService) {
    this.characterService.characterChange.subscribe(character => {
      if (character) {
        this.char = character.characterId;
        this.disable = false;
      } else {
        this.char = 1;
        this.disable = true;
      }
    });
  }

  ngOnInit(): void {
    this.countup = new CountUp('eve-players', 0, 0);
    this.syncClock();
  }

  private syncClock(): void {
    this.clock.getTime().subscribe(
      (time) => {
        this.updateClock(time);
        setTimeout(() => {
          this.timeKeeper();
        }, 60000 - (time['seconds'] * 1000));
      }
    );
  }

  private timeKeeper(): void {
    this.updateClock(ClockService.tickTime(this.time));
    let eveTime = setInterval(() => {
      this.updateClock(ClockService.tickTime(this.time));
    }, 60000);
    setTimeout(() => {
      clearInterval(eveTime);
      this.syncClock();
    }, 180000);
  }

  private updateClock(time: Object): void {
    this.countup.reset();
    this.hours = time['hours'];
    this.minutes = time['minutes'];
    this.status = time['status'];
    this.time = time;
    if (this.globals.startUp) {
      this.countup.update(time['players']);
    } else {
      this.globals.startUpObservable.subscribe(() => {
        this.countup.update(time['players']);
      })
    }
  }

  checkAccess(): boolean {
    if (this.disable) {
      return false;
    }
    // return this.char !== 1;
    return true;
  }

  logout(): void {
    this.userService.logoutUser();
  }

  // changeLanguage(lang: string): void {
  //   if (this.translate.currentLang === 'nl') {
  //     switchLanguage('en');
  //   } else {
  //     switchLanguage('nl');
  //   }
  // }
}
{'fraction_non_alphanumeric': 0.1549392227358329, 'fraction_numerical': 0.010957027906180448, 'mean_word_length': 2.667294413057125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4226084', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1704, 'n_words': 369}