<commit_before>// Main Client Side Playa file

var socket = io.connect('/');


function listenQueueUpdates() {
    socket.on('queue', function (data) {
	   $("#queue").empty();
	   var items = [];
        $.each(data, function(i, item) {
            items.push('<li>' + item.artist_name + ' - ' + item.name + '  <a href=\'#\' onclick="return removeItemFromQueue(\'' + item.queue_id + '\')">Remove</a>' + '</li>');
        });
        $('#queue').append(items.join(''));
    });
}

function listenNowPlayingUpdates() {
    socket.on('nowPlaying', function (data) {
    	var status;
    	if(data.paused) {
    		status = 'Paused';
    	} else if (data.song == undefined) {
    		status = 'Stopped';
    	} else {
    		status = 'Playing';
    	}
    	console.log('Status: ' + status);
    	// Now update the now playing div
    	$("#nowPlaying").empty();
    	var items = [];
    	items.push('<p>Status: ' + status + '</p>');
    	if(data.song != undefined) {
    		items.push('<p>' + data.song.artist_name + ' - ' + data.song.name + '  <a href=\'#\' onclick="return addSongToQueue(\'' + data.song.id + '\')">Requeue</a></p>');
    	}
        $('#nowPlaying').append(items.join(''));
    });
}

function  notifyUserOnNewQueuedSongs() {

    socket.on('songQueued', function (song) {
        var image = (!song.album_art_sml) ? '/images/album.png' : song.album_art_sml;
        $.gritter.add({
                title: 'Song added to queue',
                text: song.artist_name + ' - ' + song.name,
                image: image,
                sticky: false,
                time: ''
            });
    });

    socket.on('albumQueue', function (album) {
         var image = (!album.song.album_art_sml) ? '/images/album.png' : album.song.album_art_sml;
        $.gritter.add({
                title: 'Album added to queue',
                text: album.song.artist_name + ' - ' + album.song.album_name + ' - ' + album.count + ' songs',
                image: image,
                sticky: false,
                time: ''
            });
    });
}

function removeItemFromQueue(queue_id) {
	$.ajax({
        url: "/queue/remove/" + queue_id,
        type: "post",
        // callback handler that will be called on success<commit_msg>Fix bug with last commit<commit_after>// Main Client Side Playa file

var socket = io.connect('/');


function listenQueueUpdates() {
    socket.on('queue', function (data) {
	   $("#queue").empty();
	   var items = [];
        $.each(data, function(i, item) {
            items.push('<li>' + item.artist_name + ' - ' + item.name + '  <a href=\'#\' onclick="return removeItemFromQueue(\'' + item.queue_id + '\')">Remove</a>' + '</li>');
        });
        $('#queue').append(items.join(''));
    });
}

function listenNowPlayingUpdates() {
    socket.on('nowPlaying', function (data) {
    	var status;
    	if(data.paused) {
    		status = 'Paused';
    	} else if (data.song == undefined) {
    		status = 'Stopped';
    	} else {
    		status = 'Playing';
    	}
    	console.log('Status: ' + status);
    	// Now update the now playing div
    	$("#nowPlaying").empty();
    	var items = [];
    	items.push('<p>Status: ' + status + '</p>');
    	if(data.song != undefined) {
    		items.push('<p>' + data.song.artist_name + ' - ' + data.song.name + '  <a href=\'#\' onclick="return addSongToQueue(\'' + data.song.id + '\')">Requeue</a></p>');
    	}
        $('#nowPlaying').append(items.join(''));
    });
}

function  notifyUserOnNewQueuedSongs() {

    socket.on('songQueued', function (song) {
        var image = (!song.album_art_sml) ? '/images/album.png' : song.album_art_sml;
        $.gritter.add({
                title: 'Song added to queue',
                text: song.artist_name + ' - ' + song.name,
                image: image,
                sticky: false,
                time: ''
            });
    });

    socket.on('albumQueued', function (album) {
         var image = (!album.song.album_art_sml) ? '/images/album.png' : album.song.album_art_sml;
        $.gritter.add({
                title: 'Album added to queue',
                text: album.song.artist_name + ' - ' + album.song.album_name + ' - ' + album.count + ' songs',
                image: image,
                sticky: false,
                time: ''
            });
    });
}

function removeItemFromQueue(queue_id) {
	$.ajax({
        url: "/queue/remove/" + queue_id,
        type: "post",
        // callback handler that will be called on success
{'fraction_non_alphanumeric': 0.18571428571428572, 'fraction_numerical': 0.0, 'mean_word_length': 2.05453306066803, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3073010', 'n_tokens_mistral': 1504, 'n_tokens_neox': 1433, 'n_words': 283}