<commit_before>define([
    'libs/bean',
    'libs/bonzo',
    'libs/qwery',
    'utils/loadJSON',
    'utils/scroller',
    'sc'
], function(
    bean,
    bonzo,
    qwery,
    loadJSON,
    scroller
) {
    var sound, defaultTitle;

    return {
        init: function() {
            loadJSON('/soundcloud-keys.json', function(data) {
                SC.initialize({
                    client_id: data.id
                });
            });

            defaultTitle = document.title;
            this.bindEvents();
        },

        bindEvents: function() {
            bean.on(document.body, 'click', '.playlist__entry', function(e) {
                this.playTrack(e.currentTarget.dataset.trackId);
            }.bind(this));
            bean.on(document.body, 'click', '.audio-controls', function(e) {
                this.controlsPlay();
            }.bind(this));
            bean.on(document.body, 'click', '.controls__buttons__skip', function(e) {
                if (bonzo(qwery('.controls')).hasClass('is-default') == false) {
                    this.onSkip();
                }
            }.bind(this));
        },

        controlsPlay: function() {
            id = bonzo(qwery('.post')).attr('data-current-track');

            if (id) {
                this.playTrack(id);
            } else {
                this.playTrack(bonzo(qwery('.playlist__entry')).attr('data-track-id'))
            }
        },

        loadingState: function(target, state) {
            if (state === true) {
                target.addClass("is-loading");
            } else {
                target.removeClass("is-loading");
            }
        },

        scrollToTrack: function(target) {
            scroller.scrollToElement(el, 1000, 'easeInQuad');
        },

        onPlay: function(target) {
            target.addClass('is-playing');
            bonzo(qwery('body')).attr('data-state', 'is-playing');
            this.updateNowPlaying();
            this.setPageTitle();
        },

        onSkip: function() {
            next = bonzo(qwery('.is-playing')).next().attr('data-track-id');
            if (next) {
                this.playTrack(next, true);
            } else {
                first = bonzo(qwery('.playlist__entry')[0]).attr('data-track-id');
                this.playTrack(first);
            }
        },

        onStop: function(target) {
            bonzo(qwery('body')).attr('data-state', 'is-stopped');
            target.removeClass('is-playing');
            this.resetPageTitle();
        },

        getNowPlayingInfo: function() {
            return {
                "id"    : bonzo(qwery('.is-playing')).attr('data-track-id'),
                "color" : bonzo(qwery('.is-playing .playlist__entry__info')).attr('style'),
                "contrast" : bonzo(qwery('.is-playing')).attr('data-track-contrast'),
                "title" : qwery('.is-playing .playlist__entry__title')[0].textContent,
                "artist": qwery('.is-playing .playlist__entry__artist')[0].textContent,
                "permalink" : bonzo(qwery('.is-playing')).attr('data-track-permalink')
            }
        },

        updateNowPlaying: function() {
            track = this.getNowPlayingInfo();

            // Don't update if the track isn't new
            if (bonzo(qwery('.post')).attr('data-current-track') == track['id']) {
                return false;
            }

            bonzo(qwery('.controls--next .controls__buttons__soundcloud a')).attr('href', track['permalink']);
            bonzo(qwery('.is-changable')).attr("style", track['color'].replace('background-', ''));
            bonzo(qwery('.post')).attr('data-current-track', track['id']);
            bonzo(qwery('.controls--next')).removeClass('is-dark is-light is-very-dark is-default').addClass(track['contrast']).attr("style", track['color']);
            bonzo(qwery('.controls--next .controls__buttons .input')).attr('style', track['color']);
            bonzo(qwery('.playlist')).attr("style", track['color'].replace(')', ', 0.2)').replace('rgb', 'rgba'));
            bonzo(qwery('.controls--next .controls__title__track-artist')).text(track['artist']);
            bonzo(qwery('.controls--next .controls__title__track-title')).text(track['title']);
            bonzo(qwery('.controls--active')).removeClass("controls--active").addClass("controls--previous");
            bonzo(qwery('.controls--next')).removeClass("controls--next").addClass("controls--active");
            bonzo(qwery('.controls--previous')).removeClass("controls--previous").addClass("controls--next");
        },

        setPageTitle: function() {
            track = this.getNowPlayingInfo();
            document.title = track.artist + " - \"" + track.title + "\" on " + defaultTitle;
        },

        resetPageTitle: function() {
            document.title = defaultTitle;
        },

        updateProgressBar: function(duration, position) {<commit_msg>actually do that last thing...<commit_after>define([
    'libs/bean',
    'libs/bonzo',
    'libs/qwery',
    'utils/loadJSON',
    'utils/scroller',
    'sc'
], function(
    bean,
    bonzo,
    qwery,
    loadJSON,
    scroller
) {
    var sound, defaultTitle;

    return {
        init: function() {
            loadJSON('/soundcloud-keys.json', function(data) {
                SC.initialize({
                    client_id: data.id
                });
            });

            defaultTitle = document.title;
            this.bindEvents();
        },

        bindEvents: function() {
            bean.on(document.body, 'click', '.playlist__entry', function(e) {
                this.playTrack(e.currentTarget.dataset.trackId);
            }.bind(this));
            bean.on(document.body, 'click', '.audio-controls', function(e) {
                this.controlsPlay();
            }.bind(this));
            bean.on(document.body, 'click', '.controls__buttons__skip', function(e) {
                if (bonzo(qwery('.controls')).hasClass('is-default') == false) {
                    this.onSkip();
                }
            }.bind(this));
        },

        controlsPlay: function() {
            id = bonzo(qwery('.post')).attr('data-current-track');

            if (id) {
                this.playTrack(id);
            } else {
                this.playTrack(bonzo(qwery('.playlist__entry')).attr('data-track-id'))
            }
        },

        loadingState: function(target, state) {
            if (state === true) {
                target.addClass("is-loading");
            } else {
                target.removeClass("is-loading");
            }
        },

        scrollToTrack: function(target) {
            scroller.scrollToElement(el, 1000, 'easeInQuad');
        },

        onPlay: function(target) {
            target.addClass('is-playing');
            bonzo(qwery('body')).attr('data-state', 'is-playing');
            this.updateNowPlaying();
            this.setPageTitle();
        },

        onSkip: function() {
            next = bonzo(qwery('.is-playing')).next().attr('data-track-id');
            if (next) {
                this.playTrack(next, true);
            } else {
                first = bonzo(qwery('.playlist__entry')[0]).attr('data-track-id');
                this.playTrack(first);
            }
        },

        onStop: function(target) {
            bonzo(qwery('body')).attr('data-state', 'is-stopped');
            target.removeClass('is-playing');
            this.resetPageTitle();
        },

        getNowPlayingInfo: function() {
            return {
                "id"    : bonzo(qwery('.is-playing')).attr('data-track-id'),
                "color" : bonzo(qwery('.is-playing .playlist__entry__info')).attr('style'),
                "contrast" : bonzo(qwery('.is-playing')).attr('data-track-contrast'),
                "title" : qwery('.is-playing .playlist__entry__title')[0].textContent,
                "artist": qwery('.is-playing .playlist__entry__artist')[0].textContent,
                "permalink" : bonzo(qwery('.is-playing')).attr('data-track-permalink')
            }
        },

        updateNowPlaying: function() {
            track = this.getNowPlayingInfo();

            // Don't update if the track isn't new
            if (bonzo(qwery('.post')).attr('data-current-track') == track['id']) {
                return false;
            }

            bonzo(qwery('.controls--next .controls__buttons__soundcloud a')).attr('href', track['permalink']);
            bonzo(qwery('.is-changable')).attr("style", track['color'].replace('background-', ''));
            bonzo(qwery('.post')).attr('data-current-track', track['id']);
            bonzo(qwery('.controls--next')).removeClass('is-dark is-light is-very-dark is-default').addClass(track['contrast']).attr("style", track['color']);
            bonzo(qwery('.controls--next .controls__buttons .input')).attr('style', track['color']);
            bonzo(qwery('.playlist')).attr("style", track['color'].replace(')', ', 0.2)').replace('rgb', 'rgba'));
            bonzo(qwery('.controls--next .controls__title__track-artist')).text(track['artist']);
            bonzo(qwery('.controls--next .controls__title__track-title')).text(track['title']);
            bonzo(qwery('.controls--next .progress-bar__current')).attr('style', 'width: 0%;');
            bonzo(qwery('.controls--active')).removeClass("controls--active").addClass("controls--previous");
            bonzo(qwery('.controls--next')).removeClass("controls--next").addClass("controls--active");
            bonzo(qwery('.controls--previous')).removeClass("controls--previous").addClass("controls--next");
        },

        setPageTitle: function() {
            track = this.getNowPlayingInfo();
            document.title = track.artist + " - \"" + track.title + "\" on " + defaultTitle;
        },

        resetPageTitle: function() {
            document.title = defaultTitle;
        },

        updateProgressBar: function(duration, position) {
{'fraction_non_alphanumeric': 0.17594721583524942, 'fraction_numerical': 0.0018994301709487154, 'mean_word_length': 1.9738406658739596, 'pattern_counts': {'":': 2, '<': 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': '4604428', 'n_tokens_mistral': 2913, 'n_tokens_neox': 2827, 'n_words': 360}