$(function() {
    function showAlbum(album) {
        if ("error" in album) {
            return "<b>Error: " + escapeHtml(album.error) + "</b>";
        } else if (album.tracks.length == 0) {
            return "<b>Album " + escapeHtml(album.album) + " has no tracks!</b>";
        } else {
            var tracks = album.tracks;
            if (tracks[0].artist != null) {
                return escapeHtml(tracks[0].artist + " - " + tracks[0].album);
            } else {
                return escapeHtml(tracks[0].collection + " - " + tracks[0].album);
            }
        }
    }

    function handleAlbum(album) {
        $("#overlay").html(
            '&nbsp;<a href="javascript:;" onclick="$.get(\'/api/play/' + album.index + '\')"><i class="fa fa-5x fa-play"></i></a>').append(
                '&nbsp;<a href="javascript:;" onclick="$.get(\'/api/enqueue/' + album.index + '\')"><i class="fa fa-5x fa-plus"></i></a>');
    }

    function playAlbum(album) {
        handleAlbum(album);
        $.get('/api/play/' + album.index);
    }

    $("img.lazy").click(function() {
    }).mouseenter(function() {
        $("#overlay").appendTo($(this).parent()).fadeIn();//.css("display", "block");
        $.getJSON("/api/album/" + $(this).attr("data-idx"), handleAlbum);
        $("#hover").show();
        $.getJSON("/api/album/" + $(this).attr("data-idx"), function(album) {
            $("#hover").html(showAlbum(album));
        });
    }).lazyload();

    $("#overlay").mouseleave(function() {
        $(this).hide();
        $("#hover").hide();
    });

    function updateNowPlaying() {
        $.getJSON("/api/current", function(np) {
            if ('error' in np) {
                $("#nowplaying").html('<i class="fa fa-stop"></i>');
            } else {
                var song = '<em>' + escapeHtml(getPerformer(np)) + ' - ' + escapeHtml(np.title) + '</em>';
                var statuscls = "fa fa-stop";
                if (np.status == 1) {
                    statuscls = "fa fa-music";
                } else if (np.status == 2) {
                    statuscls = "fa fa-pause";
                }
                $("#nowplaying").html('<i class="' + statuscls + '"></i> ' + song);
                $("progress").val(np.playtime / np.duration * 100);
            }
        });
    }
    updateNowPlaying();
    setInterval(updateNowPlaying, 1000);
});

@@ -1,8 +1,335 @@
+function playAlbum(index) %7B%0A    $.get(%22/api/play/%22 + index, function() %7B%0A        $(%22#overlay%22).html('%3Cdiv style=%22font-size: 32px%22%3EPlaying...%3C/div%3E');%0A    %7D);%0A%7D%0A%0Afunction enqueueAlbum(index) %7B%0A    $.get(%22/api/enqueue/%22 + index, function() %7B%0A        $(%22#overlay%22).html('%3Cdiv style=%22font-size: 32px%22%3EEnqueued!%3C/div%3E');%0A    %7D);%0A%7D%0A%0A
 $(functi
@@ -1027,26 +1027,18 @@
 ck=%22
-$.get(%5C'/api/play/
+playAlbum(
 ' + 
@@ -1044,35 +1044,34 @@
  album.index + '
-%5C'
 )
+;
 %22%3E%3Ci class=%22fa f
@@ -1162,29 +1162,21 @@
 ck=%22
-$.get(%5C'/api/
 enqueue
-/
+Album(
 ' + 
@@ -1194,11 +1194,10 @@
  + '
-%5C'
 )
+;
 %22%3E%3Ci

Clean up play/enqueue and add some visual feedback when enqueueing