From: Andrew Karpow Date: Sun, 20 Sep 2015 14:00:45 +0000 (+0200) Subject: Merge branch 'master' of https://github.com/Nofre/ympd into Nofre-master X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=9f06699d3e2d148500edcd10f5b4cde1605cf100;p=ympd.git Merge branch 'master' of https://github.com/Nofre/ympd into Nofre-master --- 9f06699d3e2d148500edcd10f5b4cde1605cf100 diff --cc htdocs/js/mpd.js index 9724f45,db65cc7..51e8fdc --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@@ -59,17 -61,9 +63,18 @@@ var app = $.sammy(function() pagination = parseInt(this.params['splat'][0]); current_app = 'browse'; $('#breadcrump').removeClass('hide').empty().append("
  • root
  • "); - $('#salamisandwich').find("tr:gt(0)").remove(); + $('#salamisandwich').removeClass('hide').find("tr:gt(0)").remove(); + $('#dirble_panel').addClass('hide'); socket.send('MPD_API_GET_BROWSE,'+pagination+','+(browsepath ? browsepath : "/")); + // Don't add all songs from root + if (browsepath) { + var add_all_songs = $('#add-all-songs'); + add_all_songs.off(); // remove previous binds + add_all_songs.on('click', function() { + socket.send('MPD_API_ADD_TRACK,'+browsepath); + }); + add_all_songs.show(); + } $('#panel-heading').text("Browse database: "+browsepath); var path_array = browsepath.split('/'); @@@ -681,22 -688,158 +740,177 @@@ function songNotify(title, artist, albu }, 3000, notification); } +$(document).keydown(function(e){ + if (e.target.tagName == 'INPUT') { + return; + } + switch (e.which) { + case 37: //left + socket.send('MPD_API_SET_PREV'); + break; + case 39: //right + socket.send('MPD_API_SET_NEXT'); + break; + case 32: //space + clickPlay(); + break; + default: + return; + } + e.preventDefault(); +}); + + function dirble_load_categories() { + + dirble_page = 1; + + $.getJSON( "http://api.dirble.com/v2/categories?token=2e223c9909593b94fc6577361a", function( data ) { + + $('#dirble_loading').addClass('hide'); + + data = data.sort(function(a, b) { + return (a.title > b.title) ? 1 : 0; + }); + + var max = data.length - data.length%2; + + for(i = 0; i < max; i+=2) { + + $('#dirble_left > tbody').append( + ""+data[i].title+"" + ); + + $('#dirble_right > tbody').append( + ""+data[i+1].title+"" + ); + } + + if (max != data.length) { + $('#dirble_left > tbody').append( + ""+data[max].title+"" + ); + } + + $('#dirble_left > tbody > tr > td').on({ + click: function() { + dirble_selected_cat = $(this).text(); + dirble_catid = $(this).attr("catid"); + app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page); + } + }); + + $('#dirble_right > tbody > tr > td').on({ + click: function() { + dirble_selected_cat = $(this).text(); + dirble_catid = $(this).attr("catid"); + app.setLocation("#/dirble/"+dirble_catid+"/"+dirble_page); + } + }); + }); + } + + + function dirble_load_stations() { + + $.getJSON( "http://api.dirble.com/v2/category/"+dirble_catid+"/stations?page="+dirble_page+"&per_page=20&token=2e223c9909593b94fc6577361a", function( data ) { + + $('#dirble_loading').addClass('hide'); + if (data.length == 20) $('#next').removeClass('hide'); + + var max = data.length - data.length%2; + + for(i = 0; i < max; i+=2) { + + $('#dirble_left > tbody').append( + ""+data[i].name+"" + ); + $('#dirble_right > tbody').append( + ""+data[i+1].name+"" + ); + } + + if (max != data.length) { + $('#dirble_left > tbody').append( + ""+data[max].name+"" + ); + } + + $('#dirble_left > tbody > tr > td').on({ + click: function() { + var _this = $(this); + + $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + + socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream); + $('.top-right').notify({ + message:{ + text: _this.text() + " added" + } + }).show(); + }); + }, + mouseenter: function() { + var _this = $(this); + + $(this).last().append( + "" + + "").find('a').click(function(e) { + e.stopPropagation(); + + $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + + socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream); + $('.top-right').notify({ + message:{ + text: _this.text() + " added" + } + }).show(); + }); + }).fadeTo('fast',1); + }, + + mouseleave: function(){ + $(this).last().find("a").stop().remove(); + } + }); + + $('#dirble_right> tbody > tr > td').on({ + click: function() { + var _this = $(this); + + $.getJSON( "http://api.dirble.com/v2/station/"+$(this).attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + + socket.send("MPD_API_ADD_TRACK," + data.streams[0].stream); + $('.top-right').notify({ + message:{ + text: _this.text() + " added" + } + }).show(); + }); + }, + mouseenter: function() { + var _this = $(this); + + $(this).last().append( + "" + + "").find('a').click(function(e) { + e.stopPropagation(); + + $.getJSON( "http://api.dirble.com/v2/station/"+_this.attr("radioid")+"?token=2e223c9909593b94fc6577361a", function( data ) { + + socket.send("MPD_API_ADD_PLAY_TRACK," + data.streams[0].stream); + $('.top-right').notify({ + message:{ + text: _this.text() + " added" + } + }).show(); + }); + }).fadeTo('fast',1); + }, + + mouseleave: function(){ + $(this).last().find("a").stop().remove(); + } + }); + }); -} ++}