<commit_before>const PLAYER_PLAY = 0;
const PLAYER_PAUSE = 1;

function Player()
{
    this.state = undefined;
    this.api = undefined;
}

/**
 * Initialize the player
 */
Player.prototype.initialize = function()
{
    $(":range").rangeinput({
        min:  simulation.minTime,
        max:  simulation.maxTime,
        step: simulation.step
    });

    var _player = this;
    this.api = $(':range').data('rangeinput');

    // (Play|Pause) button
    $('#play-btn').click(function() {
        _player.changeState();

        return false;
    });

    // Backward button
    $('#backward-btn').click(function () {
        _player.backward();

        return false;
    });

    // >| Button
    $('#forward-btn').click(function () {
        _player.forward();

        return false;
    });

    $(":range").change(function(event, value) {
	_player.move(value);
    });

    this.backward();
}

/**
 * Backward button
 */
Player.prototype.backward = function()
{
    this.pause();
    this.move(simulation.minTime);
}

/**
 * Forward button
 */
Player.prototype.forward = function()
{
    this.pause();
    this.move(simulation.maxTime);
}

Player.prototype.setInformations = function(values)
{
    $("#label-time").html(values['time']+' sec');
    $('#label-accepted-flows').html(values['flows_accepted']);
    $('#label-rejected-flows').html(values['flows_rejected']);
}

Player.prototype.play = function()
{
    if (this.state == PLAYER_PLAY) {
        return;
    }

    this.state = PLAYER_PLAY;
    $('#play-btn > img').attr({src: '/images/pause.png'});
}

Player.prototype.pause = function()
{
    if (this.state == PLAYER_PAUSE) {
        return;
    }

    this.state = PLAYER_PAUSE;
    $('#play-btn > img').attr({src: '/images/play.png'});
}

Player.prototype.move = function(time)
{
    if (time in simulation.informations) {
        this.setInformations(simulation.informations[time]);
    } else {
        console.log('Unable to find informations for the time ' + time);
    }

    this.api.setValue(time);
}

Player.prototype.changeState = function()
{
    if (this.state == PLAYER_PAUSE) {
        this.play();
    } else {
        this.pause();
    }
}

var player = new Player();<commit_msg>added docs<commit_after>const PLAYER_PLAY = 0;
const PLAYER_PAUSE = 1;

function Player()
{
    this.state = undefined;
    this.api = undefined;
}

/**
 * Initialize the player
 */
Player.prototype.initialize = function()
{
    $(":range").rangeinput({
        min:  simulation.minTime,
        max:  simulation.maxTime,
        step: simulation.step
    });

    var _player = this;
    this.api = $(':range').data('rangeinput');

    // (Play|Pause) button
    $('#play-btn').click(function() {
        _player.changeState();

        return false;
    });

    // Backward button
    $('#backward-btn').click(function () {
        _player.backward();

        return false;
    });

    // >| Button
    $('#forward-btn').click(function () {
        _player.forward();

        return false;
    });

    $(":range").change(function(event, value) {
	_player.move(value);
    });

    this.backward();
}

/**
 * Backward button
 */
Player.prototype.backward = function()
{
    this.pause();
    this.move(simulation.minTime);
}

/**
 * Forward button
 */
Player.prototype.forward = function()
{
    this.pause();
    this.move(simulation.maxTime);
}

Player.prototype.setInformations = function(values)
{
    $("#label-time").html(values['time']+' sec');
    $('#label-accepted-flows').html(values['flows_accepted']);
    $('#label-rejected-flows').html(values['flows_rejected']);
}

Player.prototype.play = function()
{
    if (this.state == PLAYER_PLAY) {
        return;
    }

    this.state = PLAYER_PLAY;
    $('#play-btn > img').attr({src: '/images/pause.png'});
}

Player.prototype.pause = function()
{
    if (this.state == PLAYER_PAUSE) {
        return;
    }

    this.state = PLAYER_PAUSE;
    $('#play-btn > img').attr({src: '/images/play.png'});
}

/**
 * Moves the player to the specified time
 */
Player.prototype.move = function(time)
{
    if (time in simulation.informations) {
        this.setInformations(simulation.informations[time]);
    } else {
        console.log('Unable to find informations for the time ' + time);
    }

    this.api.setValue(time);
}

/**
 * Change the state of the player.
 * If the player is paused then the player is turned on
 * And vice versa
 */
Player.prototype.changeState = function()
{
    if (this.state == PLAYER_PAUSE) {
        this.play();
    } else {
        this.pause();
    }
}

/**
 * Returns the position of the player
 */
Player.prototype.getPosition = function()
{
    return this.api.getValue();
}

var player = new Player();
{'fraction_non_alphanumeric': 0.17582184517497348, 'fraction_numerical': 0.000848356309650053, 'mean_word_length': 2.739888977002379, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 9, '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': '6666777', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1522, 'n_words': 275}