diff --git a/server/djrandom/frontend/static/js/djr/player.js b/server/djrandom/frontend/static/js/djr/player.js index f90fdda718f48ded9742c54dd037c1447097c5c0..534b445a66d554d4c375c099afc54d999411cb7d 100644 --- a/server/djrandom/frontend/static/js/djr/player.js +++ b/server/djrandom/frontend/static/js/djr/player.js @@ -192,6 +192,17 @@ djr.Player.prototype.autoExtendCurrentPlaylist = function(callback) { }); }; +// Extend the current playlist with the results of a MoreLikeThis +// search based on a single selected song. +djr.Player.prototype.moreLikeThis = function(sha1) { + var player = this; + var songs = [sha1]; + + this.backend.moreLikeThese(songs, function(results) { + player.createChunk(results, 'like that'); + }); +}; + djr.Player.prototype.createChunk = function(songs, chunk_title) { // Create the new chunk, with unique songs. var chunk = this.playlist.createUniqueChunk(songs, chunk_title); @@ -263,6 +274,10 @@ djr.Player.prototype.setChunkHtml = function(chunk, chunk_id, songs_html) { var sha1 = $(this).parent().parent().attr('id').substr(5); player.removeSong(sha1); }); + chunk_div.find('.chunk_inner .ctlbox .ctl_love').click(function() { + var sha1 = $(this).parent().parent().attr('id').substr(5); + player.moreLikeThis(sha1); + }); }; // Start playing a specific song. diff --git a/server/djrandom/frontend/templates/_macros.html b/server/djrandom/frontend/templates/_macros.html index 1c25e24ed85c51e3482619c22824cbc0ff19c5c4..3557ad5a8cf461de64954bdc5b37a25fa0b8a421 100644 --- a/server/djrandom/frontend/templates/_macros.html +++ b/server/djrandom/frontend/templates/_macros.html @@ -1,6 +1,7 @@ {% macro render_song(mp3) -%} <div class="song" id="song_{{ mp3.sha1 }}"> <div class="ctlbox" style="display:none;"> + <a id="song_{{ mp3.sha1 }}_mlt" class="ctl_btn ctl_love"></a> <a id="song_{{ mp3.sha1 }}_remove" class="ctl_btn ctl_remove"></a> </div> <a id="play_{{ mp3.sha1 }}" class="song_a">