<commit_before>$(function(){

    $(document).height($(window).height());

    // SC api key
    var client_id = '5371eb9743a8c619876d4e967d558f82';

    var numCols = 2;
    var numRows = 3;

    var iframeWidth = $("#grid").width() / numCols - 5;
    var iframeHeight = $("#grid").height() / numRows - 5;

    var widgets = [];

    // initialize the soundcloud app
    SC.initialize({
        client_id: client_id
    });


    // when page first loads, search for this
    addTracks("party");

    // build the grid of iframes
    var builGrid = function() {

        var grid = $("#grid");
        for (var i = 0; i < numCols; i++) {
            for (var j = 0; j < numRows; j++) {
                var iframe = $('<iframe/>').attr('id', 'widget'+i+j);
                iframe.attr('frameborder', '0');
                iframe.width(iframeWidth);
                iframe.height(iframeHeight);
                grid.append(iframe);
            }
        }
    }

    // main function that handles searching
    $('#searchterm').keypress(function(event) {

        if (event.which == 13) {
            event.preventDefault();

            var q = $("#searchterm").val();

            addTracks(q);
        }

    });

    // searches and plays a track
    function addTracks(q) {
        SC.get('/tracks', { q: q, limit: 10 }, function(tracks) {
            loadTracks(tracks);
        });
    }

    function loadTracks(tracks) {
        var iframes = $("iframe");

        for (var i = 0; i < iframes.length; i++) {
            var $iframe = iframes[i];
            console.log($iframe);
            $iframe.src = 'http://w.soundcloud.com/player/?url=https://soundcloud.com/partyomo/partynextdoor-west-district';
            var widget = SC.Widget($iframe);
            widget.setVolume(0);
            widgets.push(widget);

            console.log(tracks[i]);

            widget.load(tracks[i].uri, {
                auto_play: true,
                buying: false,
                sharing: false,
                show_playcount: false,
                show_comments: false,
                single_active: false
            });
        }
    }

    // takes a track from SoundCloud and plays it.
    function playTrack(track) {
        // ga('send', 'event', 'play', 'songPla');
        cleanUpSpace();
        console.log(track);
        // update the iframe source
        SC.get(track.uri, {}, function(sound, error) {
          $('#widget').attr('src', sound.stream_url + '?client_id=' + client_id);
        });
        audioElem.play();
    }

    // toggle play and paused state of audio player
    var toggle = function() {
        widget.toggle();
    }

    // play the next song in queue and remove the track that
    // is to be played.
    var next = function() {
        if (all_tracks.length != 0) {
            var track = all_tracks.splice(0, 1)[0];
            playTrack(track);
        } else {
            cleanUpSpace();
            $('#error').append('No more songs. Try searching.');
            $('#searchterm').focus();
        }
    }

    var volumeUp = function() {
        widget.getVolume(function(volume) {
            widget.setVolume(Math.min(100, volume + 5));
        });
    }

    var volumeDown = function() {
        widget.getVolume(function(volume) {
            widget.setVolume(Math.max(0, volume - 5));
        });
    }

    var cleanUpSpace = function() {
        $('#widget').empty();
        $('#error').empty();
    }

    // Run stuff
    builGrid();

});

<commit_msg>mute and unmute works kind of<commit_after>$(function(){

    $(document).height($(window).height());

    // SC api key
    var client_id = '5371eb9743a8c619876d4e967d558f82';

    var numCols = 2;
    var numRows = 3;

    var iframeWidth = $("#grid").width() / numCols - 5;
    var iframeHeight = $("#grid").height() / numRows - 5;

    var widgets = [];

    // initialize the soundcloud app
    SC.initialize({
        client_id: client_id
    });


    // when page first loads, search for this
    addTracks("party");

    // build the grid of iframes
    var builGrid = function() {

        var grid = $("#grid");
        for (var i = 0; i < numRows; i++) {
            for (var j = 0; j < numCols; j++) {
                var iframe = $('<iframe/>').attr('id', 'widget'+i+j);
                iframe.attr('frameborder', '0');
                iframe.width(iframeWidth);
                iframe.height(iframeHeight);
                grid.append(iframe);
            }
        }
    }

    // main function that handles searching
    $('#searchterm').keypress(function(event) {

        if (event.which == 13) {
            event.preventDefault();

            var q = $("#searchterm").val();

            addTracks(q);
        }

    });

    // searches and plays a track
    function addTracks(q) {
        SC.get('/tracks', { q: q, limit: 10 }, function(tracks) {
            loadTracks(tracks);
        });
    }

    function loadTracks(tracks) {
        var iframes = $("iframe");

        for (var i = 0; i < iframes.length; i++) {
            var $iframe = iframes[i];
            $iframe.src = 'http://w.soundcloud.com/player/?url=https://soundcloud.com/partyomo/partynextdoor-west-district';
            var widget = SC.Widget($iframe);
            
            bindIt(widget);

            widgets.push(widget);

            widget.load(tracks[i].uri, {
                auto_play: true,
                buying: false,
                sharing: false,
                show_playcount: false,
                show_comments: false,
                single_active: false
            });
        }
    }

    function bindIt(widget) {
        widget.bind(SC.Widget.Events.READY, function() {
            console.log("setting volume to 0");
            widget.setVolume(0);
        });
    }

    $("#grid").mouseover(function(data) {
        var row = Math.floor(data.clientY / iframeHeight) - 1;
        var col = Math.floor(data.clientX / iframeWidth);

        console.log(row + ", " + col);

        widgets[row*numCols+col].setVolume(100);

        muteEverythingElse(row, col);
    });

    function muteEverythingElse(row, col) {
        var iframes = $("iframe");

        for (var i=0; i < iframes.length; i++) {
            if (i != row*numCols+col) {
                widgets[i].setVolume(0);
            }
        }
    }

    // Run stuff
    builGrid();

});


{'fraction_non_alphanumeric': 0.14997656616153726, 'fraction_numerical': 0.01421652866739572, 'mean_word_length': 1.6989881956155144, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3530231', 'n_tokens_mistral': 2054, 'n_tokens_neox': 1863, 'n_words': 422}