<commit_before>import { Component, OnInit, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { MdDialog } from '@angular/material';

import { KATA_PLAYER_ANIMATIONS } from './kata-player.animation';
import { LeaveChallengeComponent } from './../dialogs/leave-challenge/leave-challenge.component';
import { KataService, TestExecutorService } from './../core';

import 'codemirror/mode/javascript/javascript';

@Component({
    selector: 'kata-player',
    templateUrl: './kata-player.component.html',
    styleUrls: ['./kata-player.component.scss'],
    animations: KATA_PLAYER_ANIMATIONS
})
export class KataPlayerComponent implements OnInit, OnChanges {

    kataState: string = 'reading';
    leftPaneWidth: number;
    resizingModeEnabled: boolean;
    bodyFunction: string;
    config: any;
    timeSpent: number;
    testResult: Array<String>;
    testResultOutput: string;
    counterDownObs: Subscription;
    attemps: number;

    tests: any;
    numberOfPassedTests: number;
    numberOfTests: number;

    @Input() title: string;
    @Input() explanation: string;
    @Input() examples: Array<string>;
    @Input() inputs: Array<string>;
    @Input() outputs: Array<string>;
    @Input() code: string;
    @Input('next-button') nextButton: boolean;
    @Output() success = new EventEmitter();
    @Output() fail = new EventEmitter();
    @Output() next = new EventEmitter();

    constructor(private kataSrv: KataService, private testExecutorSrv: TestExecutorService, public dialog: MdDialog) {
        this.kataState = 'reading';
    }

    ngOnInit() {
        this.tests = {};
        this.numberOfPassedTests = 0;
        this.numberOfTests = 0;

        this.attemps = 0;
        this.leftPaneWidth = 50;
        this.resizingModeEnabled = false;

        this.config = {
            cursorBlinkRate: 200,
            lineNumbers: true,
            mode: { name: "javascript", json: true },
            tabSize: 2,
            theme: 'material'
        };

        this.timeSpent = 0;
        this.counterDownObs = Observable.timer(0, 1000).subscribe((tick) => {
            this.timeSpent++;
        });
    }

    ngOnChanges() {
        this.timeSpent = 0;
        this.bodyFunction = this.code;
    }

    startExercise() {
        this.kataState = 'writing';
    }

    chronoEvent(evt: any) {
        //console.log('event! ', evt);
    }

    onChange(evt: any) {

    }
<commit_msg>Added code change control event-emitter<commit_after>import { Component, OnInit, OnChanges, Input, Output, EventEmitter } from '@angular/core';
import { Observable, Subscription } from 'rxjs';
import { MdDialog } from '@angular/material';

import { KATA_PLAYER_ANIMATIONS } from './kata-player.animation';
import { LeaveChallengeComponent } from './../dialogs/leave-challenge/leave-challenge.component';
import { KataService, TestExecutorService } from './../core';

import 'codemirror/mode/javascript/javascript';

@Component({
    selector: 'kata-player',
    templateUrl: './kata-player.component.html',
    styleUrls: ['./kata-player.component.scss'],
    animations: KATA_PLAYER_ANIMATIONS
})
export class KataPlayerComponent implements OnInit, OnChanges {

    kataState: string = 'reading';
    leftPaneWidth: number;
    resizingModeEnabled: boolean;
    bodyFunction: string;
    config: any;
    timeSpent: number;
    testResult: Array<String>;
    testResultOutput: string;
    counterDownObs: Subscription;
    attemps: number;
    tests: any;
    numberOfPassedTests: number;
    numberOfTests: number;

    @Input() title: string;
    @Input() explanation: string;
    @Input() examples: Array<string>;
    @Input() inputs: Array<string>;
    @Input() outputs: Array<string>;
    @Input() code: string;
    @Input('next-button') nextButton: boolean;
    @Output() success = new EventEmitter();
    @Output() fail = new EventEmitter();
    @Output() next = new EventEmitter();
    @Output() codeUpdated = new EventEmitter();

    constructor(private kataSrv: KataService, private testExecutorSrv: TestExecutorService, public dialog: MdDialog) {
        this.kataState = 'reading';
    }

    ngOnInit() {
        this.tests = {};
        this.numberOfPassedTests = 0;
        this.numberOfTests = 0;

        this.attemps = 0;
        this.leftPaneWidth = 50;
        this.resizingModeEnabled = false;

        this.config = {
            cursorBlinkRate: 200,
            lineNumbers: true,
            mode: { name: "javascript", json: true },
            tabSize: 2,
            theme: 'material'
        };

        this.timeSpent = 0;
        this.counterDownObs = Observable.timer(0, 1000).subscribe((tick) => {
            this.timeSpent++;
        });
    }

    ngOnChanges() {
        this.timeSpent = 0;
        this.bodyFunction = this.code;
    }

    startExercise() {
        this.kataState = 'writing';
    }

    chronoEvent(evt: any) {
        //console.log('event! ', evt);
    }

    onChange(evt: string) {
        this.codeUpdated.emit(evt);
    }

{'fraction_non_alphanumeric': 0.12991892426339727, 'fraction_numerical': 0.006327862368993475, 'mean_word_length': 2.8493150684931505, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1075019', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1507, 'n_words': 339}