<commit_before>define(['jquery', 'underscore', 'vendor/sc-player', 'vendor/handlebars', 'hbs!templates/player'], function($, _, scPlayer, Handlebars, template) {
    var staticUrl = '//widget.dev/sdk/';

    function rerender(container, parameters) {
        parameters = JSON.parse(JSON.stringify(parameters));
        parameters.staticUrl = staticUrl;

        if(parameters.nowPlaying) {
            for(var i = 0; i < parameters.tracks.length; i++) {
                if(parameters.tracks[i].title === parameters.nowPlaying.title) {
                    parameters.tracks[i].playing = true;
                }
            }
        }

        container.html(template(parameters));
    }

    return function(urls, dom, options) {
        // Default parameters go here.
        var parameters = {
        };

        // Parameters for the SoundCloud player.
        var playerParameters = {
            consumerKey: '<KEY>',
            debug: false,
            preload: true,
            toggle_pause: true
        }

        // Setup the parameters object with the given arguments.
        if(arguments.length === 1 && typeof arguments[0] === 'object') {
            _.extend(parameters, arguments[0]);
        } else {
            parameters.urls = urls;
            parameters.dom = dom;

            delete options.urls;
            delete options.dom;

            _.extend(parameters, options);
        }

        var dom = parameters.dom;
        var urls = parameters.urls;

        var container = $(dom);

        if(container) {
            rerender(container, {
                tracks: []
            });
        } else {
            console.error('ToneDen Player: the container specified does not exist.');
            return;
        }

        var playerInstance = new scPlayer(urls, playerParameters);
        var titleArea = container.find('.title');

        // Set up listeners.
        container.on('click', '.controls', function(e) {
            e.preventDefault();
            var target = $(e.target);

			if(target.hasClass('play')) {
                playerInstance.pause();
            } else if(target.hasClass('next')) {
                playerInstance.next();
            } else if(target.hasClass('prev')) {
                playerInstance.prev();
            }
        });

        container.on('click', '.track-info', function(e) {
            var row = $(this);
            var cls = row.attr('class');
            var index = Number(row.attr('data-index'));

            if(cls.indexOf('playing') === -1) {
                playerInstance.goto(index);
            }
        });

        // Hook into SC player events.
        playerInstance.on('scplayer.play', function(e) {
            container.find('.play').attr('src', staticUrl + 'img/pause.svg');
        });

        playerInstance.on('scplayer.pause', function(e) {
            var paused = playerInstance.sound().paused;
            var src;
            
            if(paused) {
                src = staticUrl + 'img/play.png';
            } else {
                src = staticUrl + 'img/pause.svg';
            }

            container.find('.play').attr('src', src);
        });

        playerInstance.on('scplayer.stop', function(e) {
            container.find('.play').attr('src', staticUrl + 'img/play.png');
        });

        playerInstance.on('scplayer.track.whileloading', function(e, percent){
            container.find('.buffer').css('width', percent + '%');
        });

        playerInstance.on('scplayer.track.whileplaying', function(e, percent){
            container.find('.played').css('width', percent + '%');
        });

        playerInstance.on('scplayer.playlist.preloaded', function(e) {
            playerInstance.tracks(function(tracks) {
                console.log(tracks);
                rerender(container, {
                    nowPlaying: playerInstance.track(),
                    tracks: tracks
                });
            });
        });

        playerInstance.on('scplayer.changing_track', function(e, trackIndex) {
            container.find('.played').css('width', '0%');
            container.find('.buffer').css('width', '0%');

            playerInstance.tracks(function(tracks) {
                rerender(container, {
                    nowPlaying: playerInstance.track(),
                    tracks: tracks
                });
            });
        });

        return playerInstance;
    };
});
<commit_msg>Small changes.<commit_after>define(['jquery', 'underscore', 'vendor/sc-player', 'vendor/handlebars', 'hbs!templates/player'], function($, _, scPlayer, Handlebars, template) {
    var staticUrl = '//widget.dev/sdk/';

    function rerender(container, parameters) {
        parameters = JSON.parse(JSON.stringify(parameters));
        parameters.staticUrl = staticUrl;

        if(parameters.nowPlaying) {
            for(var i = 0; i < parameters.tracks.length; i++) {
                if(parameters.tracks[i].title === parameters.nowPlaying.title) {
                    parameters.tracks[i].playing = true;
                }
            }
        }

        container.html(template(parameters));
    }

    return function(urls, dom, options) {
        // Default parameters go here.
        var parameters = {
        };

        // Parameters for the SoundCloud player.
        var playerParameters = {
            consumerKey: '<KEY>',
            debug: false,
            preload: true,
            toggle_pause: true
        }

        // Setup the parameters object with the given arguments.
        if(arguments.length === 1 && typeof arguments[0] === 'object') {
            _.extend(parameters, arguments[0]);
        } else {
            parameters.urls = urls;
            parameters.dom = dom;

            delete options.urls;
            delete options.dom;

            _.extend(parameters, options);
        }

        var dom = parameters.dom;
        var urls = parameters.urls;

        var container = $(dom);

        if(container) {
            rerender(container, {
                tracks: []
            });
        } else {
            console.error('ToneDen Player: the container specified does not exist.');
            return;
        }

        var playerInstance = new scPlayer(urls, playerParameters);
        var titleArea = container.find('.title');

        // Set up listeners.
        container.on('click', '.controls', function(e) {
            e.preventDefault();
            var target = $(e.target);

            if(target.hasClass('play')) {
                playerInstance.pause();
            } else if(target.hasClass('next')) {
                playerInstance.next();
            } else if(target.hasClass('prev')) {
                playerInstance.prev();
            }
        });

        container.on('click', '.track-info', function(e) {
            var row = $(this);
            var cls = row.attr('class');
            var index = Number(row.attr('data-index'));

            if(cls.indexOf('playing') === -1) {
                playerInstance.goto(index);
            }
        });

        // Hook into SC player events.
        playerInstance.on('scplayer.play', function(e) {
            container.find('.play').attr('src', staticUrl + 'img/pause.svg');
        });

        playerInstance.on('scplayer.pause', function(e) {
            var paused = playerInstance.sound().paused;
            var src;

            if(paused) {
                src = staticUrl + 'img/play.png';
            } else {
                src = staticUrl + 'img/pause.svg';
            }

            container.find('.play').attr('src', src);
        });

        playerInstance.on('scplayer.stop', function(e) {
            container.find('.play').attr('src', staticUrl + 'img/play.png');
        });

        playerInstance.on('scplayer.track.whileloading', function(e, percent){
            container.find('.buffer').css('width', percent + '%');
        });

        playerInstance.on('scplayer.track.whileplaying', function(e, percent){
            container.find('.played').css('width', percent + '%');
        });

        playerInstance.on('scplayer.playlist.preloaded', function(e) {
            playerInstance.tracks(function(tracks) {
                console.log(tracks);
                rerender(container, {
                    nowPlaying: playerInstance.track(),
                    tracks: tracks
                });
            });
        });

        playerInstance.on('scplayer.changing_track', function(e, trackIndex) {
            container.find('.played').css('width', '0%');
            container.find('.buffer').css('width', '0%');

            playerInstance.tracks(function(tracks) {
                rerender(container, {
                    nowPlaying: playerInstance.track(),
                    tracks: tracks
                });
            });
        });

        return playerInstance;
    };
});

{'fraction_non_alphanumeric': 0.141175151379233, 'fraction_numerical': 0.0015698587127158557, 'mean_word_length': 1.6560452650387134, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '2683897', 'n_tokens_mistral': 2347, 'n_tokens_neox': 2221, 'n_words': 423}