<commit_before>$(document).ready(function() {
    
    
    $('#search-form').submit(function() {
        $.spotifyTrackSearch($('#search-input').val(), function(data) {
            var html = '';
            var result = $.filterTracksByCountryCode(data.tracks, "SE", 1);
            log(result);
            var data = {
                artist : result[0].artists[0].name ,
                track : result[0].name
            };
            updateList(data);
        });
        return false;
    });
});

 var COMMAND_ADD = "add"
 var COMMAND_NEXT = "next";
 var COMMAND_PLAY = "play";
 var COMMAND_PAUSE = "pause";
 var PRIVATE_CHANNEL = "/playlist";
 var SENSOR_CHANNEL = "/sensor/infotainment"
 var debug = true;
 var playing = false;
 
 /*
  *  Dev tests
  */
 
 function testAddMessage() {
     var testMessage = {
         action : 'add',
         artist : 'Nirvana',
         track : 'About a girl'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testNextMessage() {
     var testMessage = {
         action : 'next'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testPlayMessage() {
     var testMessage = {
         action : 'play'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testPauseMessage() {
     var testMessage = {
         action : 'pause'
     }
     onMessage("/playlist", testMessage);
 }
 
 
 /*
  *  Implementation
  */
 
subscribe(PRIVATE_CHANNEL);
subscribe(SENSOR_CHANNEL);
 
 function subscribe(topic) {
     WebApp.subscribe(topic);        
 }
 
/* function publish(topic, message) {
     WebApp.publish(topic, message);
 }*/

function onMessage(topic, payload) {
	log("onMessage: " + topic + " payload " + JSON.stringify(payload));
     if(topic == PRIVATE_CHANNEL || topic == SENSOR_CHANNEL) {
         handleMessagePayload(payload);
     }
}
 
 function handleMessagePayload(payload) {
	log("handleMessagePayload: " + payload);
     if(payload.action == COMMAND_ADD) {
         updateList(payload);
     } else if (payload.action == COMMAND_NEXT) {
         $('#options-list li:first').slideUp(function() {
             $(this).parent('ul').append($(this)).find('li:last').fadeIn();
             updatePlayingInfo();
         });
     } else if(payload.action == COMMAND_PLAY) {
         playing = true;
         updatePlayingInfo();
         toggleButtons();
     } else if(payload.action == COMMAND_PAUSE) {
         playing = false;
         toggleButtons();
     }
 }
 <commit_msg>Fix: #41 next now dynamic on element not animating<commit_after>$(document).ready(function() {
    
    
    $('#search-form').submit(function() {
        $.spotifyTrackSearch($('#search-input').val(), function(data) {
            var html = '';
            var result = $.filterTracksByCountryCode(data.tracks, "SE", 1);
            log(result);
            var data = {
                artist : result[0].artists[0].name ,
                track : result[0].name
            };
            updateList(data);
        });
        return false;
    });
});

 var COMMAND_ADD = "add"
 var COMMAND_NEXT = "next";
 var COMMAND_PLAY = "play";
 var COMMAND_PAUSE = "pause";
 var PRIVATE_CHANNEL = "/playlist";
 var SENSOR_CHANNEL = "/sensor/infotainment"
 var debug = true;
 var playing = false;
 
 /*
  *  Dev tests
  */
 
 function testAddMessage() {
     var testMessage = {
         action : 'add',
         artist : 'Nirvana',
         track : 'About a girl'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testNextMessage() {
     var testMessage = {
         action : 'next'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testPlayMessage() {
     var testMessage = {
         action : 'play'
     }
     onMessage("/playlist", testMessage);
 }
 
 function testPauseMessage() {
     var testMessage = {
         action : 'pause'
     }
     onMessage("/playlist", testMessage);
 }
 
 
 /*
  *  Implementation
  */
 
subscribe(PRIVATE_CHANNEL);
subscribe(SENSOR_CHANNEL);
 
 function subscribe(topic) {
     WebApp.subscribe(topic);        
 }
 
/* function publish(topic, message) {
     WebApp.publish(topic, message);
 }*/

function onMessage(topic, payload) {
	log("onMessage: " + topic + " payload " + JSON.stringify(payload));
     if(topic == PRIVATE_CHANNEL || topic == SENSOR_CHANNEL) {
         handleMessagePayload(payload);
     }
}
 
 function handleMessagePayload(payload) {
	log("handleMessagePayload: " + payload);
     if(payload.action == COMMAND_ADD) {
         updateList(payload);
     } else if (payload.action == COMMAND_NEXT) {
         var elem = $('#options-list li:first');
         while(elem.is(':animated')) {
             elem = elem.next('li');
         }
         elem.slideUp(function() {
             $(this).parent('ul').append($(this)).find('li:last').fadeIn();
             updatePlayingInfo();
         });
     } else if(payload.action == COMMAND_PLAY) {
         playing = true;
         updatePlayingInfo();
         toggleButtons();
     } else if(payload.action == COMMAND_PAUSE) {
         playing = false;
         toggleButtons();
     }
 }
 
{'fraction_non_alphanumeric': 0.1455795677799607, 'fraction_numerical': 0.0019646365422396855, 'mean_word_length': 2.2781712813908563, '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': '4028543', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1459, 'n_words': 286}