<commit_before>define(['jquery', 'inheritance', 'ajaxify', 'ws', 'jquery.ui', 'jquery.nanoscroller', 'moment', 'bind', 'domReady!'],
    function($, inheritance, ajaxify, ws) {

    var Player = Class.extend({
        init: function (queue) {
            if (instance !== null) {
                throw Error('Only one instance of Player allowed!');
            }

            var that = this;

            this.queue = queue;

            this.player = $('#player').get(0);

            if (typeof this.player == 'undefined' || this.player === null) {
                return;
            }

            this.playerControls = $('#player-controls');
            this.playerProgress = $('#player-progress');
            this.trackTime = $('#track-time');
            this.trackDuration = $('#track-duration');
            this.queueDuration = $('#queue-duration');
            this.playButton = $('#play-button');
            this.pauseButton = $('#pause-button');
            this.nextButton = $('#next-button');
            this.stopButton = $('#stop-button');
            this.playerTrack = $('#player-track');

            this.loaded = false;

            // if this is false it's an external player playing.
            this.usPlaying = false;

            // this is true if someone is using the stream
            this.playing = false;

            that.currentTrack = null;

            $(window).bind('beforeunload', function (event) {
                if (!that.player.paused) {
                    return false;
                }
            });

            $(ws).bind('open', function () {
                ws.emit('queue.open');
            });

            ws.on('queue.current_track', function (track) {
                that.setCurrent(track);
            });

            ws.on('queue.current_progress', function (progress) {
                that.setProgress(progress.seconds, progress.seconds_ahead);
            });

            ws.on('queue.reset', function (track, user_agent) {
                that.setCurrent(null);
                that.setProgress(0, 0);
            });

            ws.on('queue.start', function (track, user_agent, format) {
                that.setCurrent(track);

                that.queue.reload();

                that.setPlaying(user_agent, format);

                that.setProgress(0, 0);
            });

            ws.on('queue.end', function (track, user_agent) {
                that.setStopped();
            });

            ws.on('queue.progress', function (progress, track, user_agent, format) {
                if (that.currentTrack === null) {
                    that.currentTrack = track;
                }

                that.setPlaying(user_agent, format);

                that.setProgress(progress.seconds, progress.seconds_ahead);
            });

            ws.on('queue.next.none', function () {
                that.setCurrent(null);
                that.setProgress(0, 0);
                that.queue.reload();
            });

            $(that.player).bind('ended', function (event) {
                that.setProgress(0, 0);
                that.load();

                setTimeout(function () {<commit_msg>don't reset progress on queue.start<commit_after>define(['jquery', 'inheritance', 'ajaxify', 'ws', 'jquery.ui', 'jquery.nanoscroller', 'moment', 'bind', 'domReady!'],
    function($, inheritance, ajaxify, ws) {

    var Player = Class.extend({
        init: function (queue) {
            if (instance !== null) {
                throw Error('Only one instance of Player allowed!');
            }

            var that = this;

            this.queue = queue;

            this.player = $('#player').get(0);

            if (typeof this.player == 'undefined' || this.player === null) {
                return;
            }

            this.playerControls = $('#player-controls');
            this.playerProgress = $('#player-progress');
            this.trackTime = $('#track-time');
            this.trackDuration = $('#track-duration');
            this.queueDuration = $('#queue-duration');
            this.playButton = $('#play-button');
            this.pauseButton = $('#pause-button');
            this.nextButton = $('#next-button');
            this.stopButton = $('#stop-button');
            this.playerTrack = $('#player-track');

            this.loaded = false;

            // if this is false it's an external player playing.
            this.usPlaying = false;

            // this is true if someone is using the stream
            this.playing = false;

            that.currentTrack = null;

            $(window).bind('beforeunload', function (event) {
                if (!that.player.paused) {
                    return false;
                }
            });

            $(ws).bind('open', function () {
                ws.emit('queue.open');
            });

            ws.on('queue.current_track', function (track) {
                that.setCurrent(track);
            });

            ws.on('queue.current_progress', function (progress) {
                that.setProgress(progress.seconds, progress.seconds_ahead);
            });

            ws.on('queue.reset', function (track, user_agent) {
                that.setCurrent(null);
                that.setProgress(0, 0);
            });

            ws.on('queue.start', function (track, user_agent, format) {
                that.setCurrent(track);

                that.queue.reload();

                that.setPlaying(user_agent, format);
            });

            ws.on('queue.end', function (track, user_agent) {
                that.setStopped();
            });

            ws.on('queue.progress', function (progress, track, user_agent, format) {
                if (that.currentTrack === null) {
                    that.currentTrack = track;
                }

                that.setPlaying(user_agent, format);

                that.setProgress(progress.seconds, progress.seconds_ahead);
            });

            ws.on('queue.next.none', function () {
                that.setCurrent(null);
                that.setProgress(0, 0);
                that.queue.reload();
            });

            $(that.player).bind('ended', function (event) {
                that.setProgress(0, 0);
                that.load();

                setTimeout(function () {
{'fraction_non_alphanumeric': 0.14294720252167062, 'fraction_numerical': 0.00252167060677699, 'mean_word_length': 1.5102848101265822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6487400', 'n_tokens_mistral': 1685, 'n_tokens_neox': 1538, 'n_words': 320}