<commit_before>/*
DOM.js
author: morgl
*/

function onTrackShow(evt){
    var trackCount = Player.getTrackCount();
    Player.addTracks(evt.tracks);
    var trackLen = evt.tracks.length;
    for(var i = 0; i < trackLen; i++){
        var track = evt.tracks[i];
        var itemContainer = $( "<div>", { class: "col-xs-12 col-sm-6 col-md-3  placeholders"} );
        var miniatureContainer = $( '<div>', { class : 'miniature' } ).appendTo(itemContainer);
        if ( track.artwork_url ) {
            $( '<img />', { src : track.artwork_url.replace('large','t200x200') } ).appendTo(miniatureContainer);
        }
        $( '<span>', { 'data-trackindex': trackCount + i, class : 'miniature-play play glyphicon glyphicon-play' }     ).appendTo(miniatureContainer);
        itemContainer.appendTo('#content-target').hide().fadeIn(600);
    }
    if(evt.finish){
        unloading();
        if (trackCount == 0){
            show_nothing_found();
        }
    }
};

$( "#content-target" ).on( "click", ".play, .pause", function() {
    var $this = $(this);
    $this.toggleClass("play glyphicon-play pause glyphicon-pause");
    if(!Player.isPlaying){
        loading();
        if(!Player.play($this.data('trackindex')))
            unloading();
    }
    else {
        var myIndex = $(this).data('trackindex');
        if(Player.currentIndex == myIndex)
            Player.pause();
        else{
            loading();
            if(!Player.play(myIndex))
                unloading();
        }
    }
});

$( '#player-control-play' ).click(function(){
    if(!Player.isPlaying){
        loading();
        if(Player.play())
            unloading();
    }
    else
        Player.pause();
});

$( '#player-control-backward' ).click(function(){
    loading();
    if(Player.backward())
        unloading();
});

$( '#player-control-forward' ).click(function(){
    loading();
    if(Player.forward())
        unloading();
});

function formSubmit(){
    var mode = $('#cboModeSelector').val();
    var tags = $('#txtTags').val();
    var window = $('#cboWindowSelector').val();
    $('#content-target').html('');
    Player.clearTracks();
    loading();
    SoundBuzz.getBuzz(mode, tags, window, onTrackShow);
    return false;
};

function loading(){
    $('#overlay').addClass('loading');
    $('#overlay').append( $( '<div>', { id : 'loading' } ) );
};

function unloading(){
    $('#overlay').removeClass('loading');
    $('#loading').remove();
};


function show_nothing_found(){
    $('#player-control-play').find('.glyphicon').removeClass('glyphicon-pause').addClass('glyphicon-play');
    $('#content-target').html('');
    $( '<img />', { src   : 'img/badass.png',
                    alt   : 'not found',
                    class : 'placeholders' } ).appendTo('#content-target');
    $( '<p>', { class : 'badass',
                text  : 'Watch out, we got a badass over here' } ).appendTo('#content-target');
    $( '<p>', { class : 'nothing',
                text  : 'Nothing matches your demands, your highness...'} ).appendTo('#content-target');
}

Player.togglePlayCallback = function(playerInfo){

    if(playerInfo.isPlaying)
        unloading();

    var headerPlay = $('#player-control-play').find('.glyphicon');
    var miniaturePlay = $('.miniature-play[data-trackindex='+playerInfo.trackIndex+']');
    $('.miniature-play.pause').toggleClass('play glyphicon-play pause glyphicon-pause');
    if((playerInfo.isPlaying && headerPlay.hasClass('glyphicon-play')) ||
      (!playerInfo.isPlaying && headerPlay.hasClass('glyphicon-pause'))){
        headerPlay.toggleClass('glyphicon-play glyphicon-pause');
    }
    miniaturePlay.toggleClass('play glyphicon-play pause glyphicon-pause');
}
<commit_msg>dom modifications<commit_after>/*
DOM.js
author: morgl
*/

function onTrackShow(evt){
    var trackCount = Player.getTrackCount();
    Player.addTracks(evt.tracks);
    var trackLen = evt.tracks.length;
    for(var i = 0; i < trackLen; i++){
        var track = evt.tracks[i];
        var itemContainer = $( "<div>", { class: "col-xs-12 col-sm-6 col-md-3  placeholders"} );
        var miniatureContainer = $( '<div>', { class : 'miniature' } ).appendTo(itemContainer);
        if ( track.artwork_url ) {
            $( '<img />', { src : track.artwork_url.replace('large','t200x200') } ).appendTo(miniatureContainer);
        }
        $( '<span>', { 'data-trackindex': trackCount + i, class : 'miniature-play play glyphicon glyphicon-play' }     ).appendTo(miniatureContainer);
        itemContainer.appendTo('#content-target').hide().fadeIn(600);
    }
    if(evt.finish){
        unloading();
        if (trackCount == 0){
            show_nothing_found();
        }
    }
};

$( "#content-target" ).on( "click", ".play, .pause", function() {
    var $this = $(this);
    $this.toggleClass("play glyphicon-play pause glyphicon-pause");
    if(!Player.isPlaying){
        loading();
        if(!Player.play($this.data('trackindex')))
            unloading();
    }
    else {
        var myIndex = $(this).data('trackindex');
        if(Player.currentIndex == myIndex)
            Player.pause();
        else{
            loading();
            if(!Player.play(myIndex))
                unloading();
        }
    }
});

$( '#player-control-play' ).click(function(){
    if(!Player.isPlaying){
        loading();
        if(Player.play())
            unloading();
    }
    else
        Player.pause();
});

$( '#player-control-backward' ).click(function(){
    loading();
    if(Player.backward())
        unloading();
});

$( '#player-control-forward' ).click(function(){
    loading();
    if(Player.forward())
        unloading();
});

function formSubmit(){
    var mode = $('#cboModeSelector').val();
    var tags = $('#txtTags').val();
    var window = $('#cboWindowSelector').val();
    $('#content-target').empty();
    Player.clearTracks();
    loading();
    SoundBuzz.getBuzz(mode, tags, window, onTrackShow);
    return false;
};

function loading(){
    $('#overlay').addClass('loading');
    $('#overlay').append( $( '<div>', { id : 'loading' } ) );
};

function unloading(){
    $('#overlay').removeClass('loading');
    $('#loading').remove();
};

function show_nothing_found(){
    $('#player-control-play').find('.glyphicon').removeClass('glyphicon-pause').addClass('glyphicon-play');
    $('#content-target').empty();
    $( '<img />', { src   : 'img/badass.png',
                    alt   : 'not found',
                    class : 'placeholders' } ).appendTo('#content-target');
    $( '<p>', { class : 'badass',
                text  : 'Watch out, we got a badass over here' } ).appendTo('#content-target');
    $( '<p>', { class : 'nothing',
                text  : 'Nothing matches your demands, your highness...'} ).appendTo('#content-target');
}

Player.togglePlayCallback = function(playerInfo){

    if(playerInfo.isPlaying)
        unloading();

    var headerPlay = $('#player-control-play').find('.glyphicon');
    var miniaturePlay = $('.miniature-play[data-trackindex='+playerInfo.trackIndex+']');
    $('.miniature-play.pause').toggleClass('play glyphicon-play pause glyphicon-pause');
    if((playerInfo.isPlaying && headerPlay.hasClass('glyphicon-play')) ||
      (!playerInfo.isPlaying && headerPlay.hasClass('glyphicon-pause'))){
        headerPlay.toggleClass('glyphicon-play glyphicon-pause');
    }
    miniaturePlay.toggleClass('play glyphicon-play pause glyphicon-pause');
}

{'fraction_non_alphanumeric': 0.18911174785100288, 'fraction_numerical': 0.003907267517582704, 'mean_word_length': 2.5452446906740533, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '2031453', 'n_tokens_mistral': 2342, 'n_tokens_neox': 2244, 'n_words': 395}