<commit_before><commit_msg>Refactoring to separate contests into their own component.<commit_after>import { Component, OnInit } from '@angular/core';

import { Contest } from './contest';
import { ContestService } from './contest.service';

@Component({
    moduleId: module.id,
    selector: 'contests',
    template: `
      <ul>
        <li *ngFor="let contest of contests">
          <input type="checkbox" name="isActive" (change)="toggleContest(contest, $event.target.checked)">
          {{contest.contestType}}
        </li>
      </ul>
    `
})
export class ContestsComponent implements OnInit {
  contests: Contest[];
  contestsSelected: Contest[] = [];

  constructor(private contestService: ContestService) {}

  ngOnInit(): void {
    this.initContests();
  }

  initContests(): void {
    this.contestService.getContests()
      .then(contests => this.contests = contests);
  }

  toggleContest(contest:Contest, isChecked: boolean) {
  console.log("Selection of " + contest.contestType);
  console.log(" len is " + this.contestsSelected.length);
    var idx = -1;
    if ( isChecked ) {
      this.contestsSelected.push(contest);
    } else {
      idx = this.contestsSelected.indexOf(contest);
      if ( idx > -1 ) {
        this.contestsSelected.splice(idx, 1); // remove 1 item
      }
    }
    console.log(" finished len is " + this.contestsSelected.length);
  }
}
{'fraction_non_alphanumeric': 0.14017341040462428, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 3.209726443768997, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, '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': '1971128', 'n_tokens_mistral': 434, 'n_tokens_neox': 419, 'n_words': 93}