From 09fed4d0f0941e93b849e8f70775cbf7981300c3 Mon Sep 17 00:00:00 2001 From: "Robert J. Newmark" <newmark@L3Jane.local> Date: Sat, 24 Sep 2011 23:48:42 +0100 Subject: [PATCH] added Lyrics, fixed wikipedia, fixed lastfm, removed google --- server/djrandom/frontend/static/js/djr.min.js | 5 ++- .../djrandom/frontend/static/js/djr/Makefile | 2 +- .../djrandom/frontend/static/js/djr/player.js | 39 ++++++++++++------- server/djrandom/frontend/templates/index.html | 18 +++++---- 4 files changed, 40 insertions(+), 24 deletions(-) diff --git a/server/djrandom/frontend/static/js/djr.min.js b/server/djrandom/frontend/static/js/djr.min.js index bae285b..c120923 100644 --- a/server/djrandom/frontend/static/js/djr.min.js +++ b/server/djrandom/frontend/static/js/djr.min.js @@ -17,5 +17,6 @@ b);d.removeChunk(b)});e.find(".chunk_inner .song").hover(function(){$(this).find djr.Player.prototype.play=function(a){djr.debug("play "+a);this.cur_song&&(this.old_songs.push(this.cur_song),this.old_songs.length>5&&this.old_songs.shift());this.cur_song=a;$(".song").removeClass("playing");$("#song_"+a).addClass("playing");this.player.jPlayer("setMedia",{mp3:"/dl/"+a}).jPlayer("play");var b=$("#song_"+a+" .artist").text(),c=$("#song_"+a+" .album").text();$("#jp_playlist_1").html($("#song_"+a+" .title").text()+"<br>"+b+"<br><small>"+c+"</small>");b="/album_image/"+escape(b)+"/"+ escape(c);$("#albumart_fs").attr("src",b);$("#albumart_fs").fullBg();$("#albumart_fs").show();this.backend.nowPlaying(a,this.old_songs)};djr.Player.prototype.nextSong=function(){this.play(this.playlist.getNextSong(this.cur_song))};djr.Player.prototype.streamCurrentPlaylist=function(){};djr.state={backend:null,player:null}; djr.init=function(){djr.state.backend=new djr.Backend;djr.state.player=new djr.Player(djr.state.backend,"#djr_player");$("#playlistClearBtn").click(function(){djr.state.player.clearPlaylist()});$("#playlistStreamBtn").click(function(){djr.state.player.streamCurrentPlaylist()});$("#playlistExtendBtn").click(function(){djr.state.player.extendCurrentPlaylist()});$("#playlistLast25").click(function(){djr.state.player.lastPlaylist(25)});$("#playlistRandom").click(function(){djr.state.player.randomPlaylist(25)}); -$("#playlistMost").click(function(){djr.state.player.mostPlayedPlaylist(25)});$("#wikibtn").click(function(){var a=$("#song_"+djr.state.player.cur_song+" .title").text();$("#wikipedia").display=="none"?a!=""&&(a=a.split(" ").join("+"),$("#wikipedia").attr("src","/ext?url="+escape("http://en.wikipedia.org/wiki/Special:Search?search="+a+"&go=Go")),window.frames.wikipedia.location.reload(),$("#wikipedia").show()):$("#wikipedia").attr("display","none")});$("#googlebtn").click(function(){var a=$("#song_"+ -djr.state.player.cur_song+" .title").text();$("#google").display=="none"?a!=""&&(a=a.split(" ").join("+"),$("#google").attr("src","/ext?url="+escape("http://www.google.ie/#hl=en&q="+a)),window.frames.google.location.reload(),$("#google").show()):$("#google").attr("display","none")});$("#albumart_fs").load(function(){$(this).fullBg();$(this).show()})};djr.player=function(){return djr.state.player};djr.debug=function(a){$("#debug").append(a+"<br>")}; +$("#playlistMost").click(function(){djr.state.player.mostPlayedPlaylist(25)});$("#wikibtn").click(function(){var a=$("#song_"+djr.state.player.cur_song+" .artist").text();$("#wikipedia").is(":visible")==!1?a!=""&&(a=a.split(" ").join("+"),$("#wikipedia").show("slow"),$("#wikipedia").attr("src","http://en.m.wikipedia.org/w/index.php?search="+a)):$("#wikipedia").hide("slow")});$("#lastfmbtn").click(function(){var a=$("#song_"+djr.state.player.cur_song+" .title").text();$("#lastfm").is(":visible")== +!1?a!=""&&(a=a.split(" ").join("+"),$("#lastfm").show("slow"),$("#lastfm").attr("src","http://m.last.fm/search?q="+a)):$("#lastfm").hide("slow")});$("#lyricsbtn").click(function(){var a=$("#song_"+djr.state.player.cur_song+" .title").text();$("#lyrics").is(":visible")==!1?a!=""&&(a=a.split(" ").join("+"),$("#lyrics").show("slow"),$("#lyrics").attr("src","http://lyrics.wikia.com/index.php?search="+a+"&fulltext=0")):$("#lyrics").hide("slow")});$("#albumart_fs").load(function(){$(this).fullBg();$(this).show()})}; +djr.player=function(){return djr.state.player};djr.debug=function(a){$("#debug").append(a+"<br>")}; diff --git a/server/djrandom/frontend/static/js/djr/Makefile b/server/djrandom/frontend/static/js/djr/Makefile index 7d483db..094d725 100644 --- a/server/djrandom/frontend/static/js/djr/Makefile +++ b/server/djrandom/frontend/static/js/djr/Makefile @@ -1,5 +1,5 @@ -JSCOMPILER_JAR = /usr/lib/jscompiler/compiler.jar +JSCOMPILER_JAR = /usr/bin/compiler.jar JSCOMPILER = java -jar $(JSCOMPILER_JAR) SOURCES = \ diff --git a/server/djrandom/frontend/static/js/djr/player.js b/server/djrandom/frontend/static/js/djr/player.js index ccd057a..7723031 100644 --- a/server/djrandom/frontend/static/js/djr/player.js +++ b/server/djrandom/frontend/static/js/djr/player.js @@ -311,35 +311,46 @@ djr.init = function () { }); $('#wikibtn').click(function () { + var stitle = $('#song_' + djr.state.player.cur_song + ' .artist').text(); + if ( $('#wikipedia').is(':visible') == false ) { + if ( stitle != "" ) { + stitle = stitle.split(' ').join('+'); + $('#wikipedia').show('slow'); + //$('#wikipedia').attr("src", "/ext?url=" + escape("http://en.wikipedia.org/wiki/Special:Search?search=" + stitle + "&go=Go")); + $('#wikipedia').attr("src", "http://en.m.wikipedia.org/w/index.php?search=" + stitle); + } + } else { + $('#wikipedia').hide('slow') + } + }); + $('#lastfmbtn').click(function () { var stitle = $('#song_' + djr.state.player.cur_song + ' .title').text(); - if ( $('#wikipedia').display == 'none' ) { + if ( $('#lastfm').is(':visible') == false ) { if ( stitle != "" ) { stitle = stitle.split(' ').join('+'); - $('#wikipedia').attr("src", "/ext?url=" - + escape("http://en.wikipedia.org/wiki/Special:Search?search=" - + stitle + "&go=Go")); - window.frames["wikipedia"].location.reload(); - $('#wikipedia').show(); + $('#lastfm').show('slow'); + //$('#lastfm').attr("src", "/ext?url=" + escape("http://www.lastfm.com/#&q=" + stitle)); + $('#lastfm').attr("src", "http://m.last.fm/search?q=" + stitle ); } } else { - $('#wikipedia').attr('display', 'none' ); + $('#lastfm').hide('slow') } }); - $('#googlebtn').click(function () { + $('#lyricsbtn').click(function () { var stitle = $('#song_' + djr.state.player.cur_song + ' .title').text(); - if ( $('#google').display == 'none' ) { + if ( $('#lyrics').is(':visible') == false ) { if ( stitle != "" ) { stitle = stitle.split(' ').join('+'); - $('#google').attr("src", "/ext?url=" - + escape("http://www.google.ie/#hl=en&q=" + stitle)); - window.frames["google"].location.reload(); - $('#google').show(); + $('#lyrics').show('slow'); + //$('#lyrics').attr("src", "/ext?url=" + escape("http://www.lyrics.com/#&q=" + stitle)); + $('#lyrics').attr("src", "http://lyrics.wikia.com/index.php?search=" + stitle + "&fulltext=0" ); } } else { - $('#google').attr('display', 'none' ); + $('#lyrics').hide('slow') } }); + // Set the album art image to auto-fullscreen on load. $('#albumart_fs').load(function() { $(this).fullBg(); diff --git a/server/djrandom/frontend/templates/index.html b/server/djrandom/frontend/templates/index.html index 1f03627..0f30516 100644 --- a/server/djrandom/frontend/templates/index.html +++ b/server/djrandom/frontend/templates/index.html @@ -73,20 +73,24 @@ DJ:Random <li></li> </ul> </div> - <div id="jp_info" class="jp_info" > - <div id="wikiDiv" class="song" > - <a id="wikibtn">Wikipedia Info</a> + <div id="lyricsDiv" > + <a id="lyricsbtn">Lyrycs</a> + <iframe id="lyrics" width="100%" height="300" style="display: none" > + <p>Your browser does not support iframes.</p> + </iframe> + </div> + <div id="wikiDiv" > + <a id="wikibtn">Wikipedia Author</a> <iframe id="wikipedia" width="100%" height="300" style="display: none" > <p>Your browser does not support iframes.</p> </iframe> </div> - <div id="googleDiv" class="song" > - <a id="googlebtn">Google Info</a> - <iframe id="google" width="100%" height="300" style="display: none" > + <div id="lastfmDiv" > + <a id="lastfmbtn">LastFM Song Info</a> + <iframe id="lastfm" width="100%" height="300" style="display: none" > <p>Your browser does not support iframes.</p> </iframe> </div> - </div> </div> </div> </div> -- GitLab