add a button to love tracks on last.fm using mpdas

This commit is contained in:
SuperBFG7 2017-03-18 13:32:17 +01:00
parent 07c6df23bc
commit 152defeaaa
2 changed files with 15 additions and 0 deletions

View File

@ -55,6 +55,11 @@
<span class="glyphicon glyphicon-forward"></span> <span class="glyphicon glyphicon-forward"></span>
</button> </button>
</div> </div>
<div class="btn-group">
<button id="btnlove" type="button" class="btn btn-default" onclick="clickLove();">
<span class="glyphicon glyphicon-heart"></span>
</button>
</div>
<div class="btn-group"> <div class="btn-group">
<div class="btn btn-toolbar btn-default"> <div class="btn btn-toolbar btn-default">
<span id="volume-icon" class="glyphicon glyphicon-volume-up"></span> <span id="volume-icon" class="glyphicon glyphicon-volume-up"></span>

View File

@ -466,6 +466,8 @@ function webSocketConnect() {
$('#album').text(""); $('#album').text("");
$('#artist').text(""); $('#artist').text("");
$('#btnlove').removeClass("active");
$('#currenttrack').text(" " + obj.data.title); $('#currenttrack').text(" " + obj.data.title);
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>"; var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
@ -598,6 +600,14 @@ function basename(path) {
return path.split('/').reverse()[0]; return path.split('/').reverse()[0];
} }
function clickLove() {
socket.send("MPD_API_SEND_MESSAGE,mpdas," + ($('#btnlove').hasClass('active') ? "unlove" : "love"));
if ( $('#btnlove').hasClass('active') )
$('#btnlove').removeClass("active");
else
$('#btnlove').addClass("active");
}
$('#btnrandom').on('click', function (e) { $('#btnrandom').on('click', function (e) {
socket.send("MPD_API_TOGGLE_RANDOM," + ($(this).hasClass('active') ? 0 : 1)); socket.send("MPD_API_TOGGLE_RANDOM," + ($(this).hasClass('active') ? 0 : 1));