mirror of
https://github.com/SuperBFG7/ympd
synced 2025-03-04 10:38:18 +00:00
Fixed filtering of playlists in browse filesystem view
This commit is contained in:
parent
2a2263c519
commit
e37c678a89
@ -153,11 +153,9 @@ var app = $.sammy(function() {
|
|||||||
add_all_songs.on('click', function() {
|
add_all_songs.on('click', function() {
|
||||||
socket.send('MPD_API_ADD_TRACK,'+browsepath);
|
socket.send('MPD_API_ADD_TRACK,'+browsepath);
|
||||||
});
|
});
|
||||||
add_all_songs.removeAttr('disabled');
|
add_all_songs.removeAttr('disabled').removeClass('disabled');
|
||||||
add_all_songs.removeClass('disabled');
|
|
||||||
} else {
|
} else {
|
||||||
add_all_songs.attr('disabled','disabled');
|
add_all_songs.attr('disabled','disabled').addClass('disabled');
|
||||||
add_all_songs.addClass('disabled');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var path_array = browsepath.split('/');
|
var path_array = browsepath.split('/');
|
||||||
@ -206,9 +204,7 @@ var app = $.sammy(function() {
|
|||||||
socket.send('MPD_API_SEARCH,' + mpdtag + ','+pagination+',' + searchstr);
|
socket.send('MPD_API_SEARCH,' + mpdtag + ','+pagination+',' + searchstr);
|
||||||
} else {
|
} else {
|
||||||
$('#searchList > tbody').empty();
|
$('#searchList > tbody').empty();
|
||||||
var add_all_songs=$('#searchAddAllSongs');
|
$('#searchAddAllSongs').attr('disabled','disabled').addClass('disabled');
|
||||||
add_all_songs.attr('disabled','disabled');
|
|
||||||
add_all_songs.addClass('disabled');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -419,27 +415,24 @@ function webSocketConnect() {
|
|||||||
};
|
};
|
||||||
$('#'+current_app+'List > tbody > tr').on({
|
$('#'+current_app+'List > tbody > tr').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
|
socket.send('MPD_API_ADD_PLAYLIST,' + decodeURI($(this).attr('uri')));
|
||||||
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (nrItems == 0) {
|
if (nrItems == 0) {
|
||||||
$('#'+current_app+'List > tbody').append(
|
$('#'+current_app+'List > tbody').append(
|
||||||
"<tr><td><span class=\"material-icons\">error_outline</span></td>" +
|
'<tr><td><span class="material-icons">error_outline</span></td>' +
|
||||||
"<td colspan=\"3\">No playlists found.</td>" +
|
'<td colspan="3">No playlists found.</td>' +
|
||||||
"<td></td><td></td></tr>"
|
'<td></td><td></td></tr>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'search':
|
case 'search':
|
||||||
$('#panel-heading-search').text(obj.totalEntities + ' Songs found');
|
$('#panel-heading-search').text(obj.totalEntities + ' Songs found');
|
||||||
var add_all_songs=$('#searchAddAllSongs');
|
|
||||||
if (obj.totalEntities > 0) {
|
if (obj.totalEntities > 0) {
|
||||||
add_all_songs.removeAttr('disabled');
|
$('#searchAddAllSongs').removeAttr('disabled').removeClass('disabled');
|
||||||
add_all_songs.removeClass('disabled');
|
|
||||||
} else {
|
} else {
|
||||||
add_all_songs.attr('disabled','disabled');
|
$('#searchAddAllSongs').attr('disabled','disabled').addClass('disabled');
|
||||||
add_all_songs.addClass('disabled');
|
|
||||||
}
|
}
|
||||||
case 'browse':
|
case 'browse':
|
||||||
if(current_app !== 'browseFilesystem' && current_app !== 'search')
|
if(current_app !== 'browseFilesystem' && current_app !== 'search')
|
||||||
@ -619,17 +612,16 @@ function webSocketConnect() {
|
|||||||
showNotification('myMPD lost connection to MPD','','','danger');
|
showNotification('myMPD lost connection to MPD','','','danger');
|
||||||
break;
|
break;
|
||||||
case 'update_queue':
|
case 'update_queue':
|
||||||
if(current_app === 'queue') {
|
if(current_app === 'queue')
|
||||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "song_change":
|
case "song_change":
|
||||||
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri);
|
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri);
|
||||||
break;
|
break;
|
||||||
case 'settings':
|
case 'settings':
|
||||||
if (!isNaN(obj.data.max_elements_per_page)) {
|
if (!isNaN(obj.data.max_elements_per_page))
|
||||||
MAX_ELEMENTS_PER_PAGE=obj.data.max_elements_per_page;
|
MAX_ELEMENTS_PER_PAGE=obj.data.max_elements_per_page;
|
||||||
}
|
|
||||||
if(obj.data.random)
|
if(obj.data.random)
|
||||||
$('#btnrandom').removeClass('btn-secondary').addClass("btn-success")
|
$('#btnrandom').removeClass('btn-secondary').addClass("btn-success")
|
||||||
else
|
else
|
||||||
@ -645,26 +637,20 @@ function webSocketConnect() {
|
|||||||
else
|
else
|
||||||
$('#btnsingle').removeClass("btn-success").addClass("btn-secondary");
|
$('#btnsingle').removeClass("btn-success").addClass("btn-secondary");
|
||||||
|
|
||||||
if(obj.data.crossfade != undefined) {
|
if(obj.data.crossfade != undefined)
|
||||||
$('#inputCrossfade').removeAttr('disabled');
|
$('#inputCrossfade').removeAttr('disabled').val(obj.data.crossfade);
|
||||||
$('#inputCrossfade').val(obj.data.crossfade);
|
else
|
||||||
} else {
|
|
||||||
$('#inputCrossfade').attr('disabled', 'disabled');
|
$('#inputCrossfade').attr('disabled', 'disabled');
|
||||||
}
|
|
||||||
|
|
||||||
if(obj.data.mixrampdb != undefined) {
|
if(obj.data.mixrampdb != undefined)
|
||||||
$('#inputMixrampdb').removeAttr('disabled');
|
$('#inputMixrampdb').removeAttr('disabled').val(obj.data.mixrampdb);
|
||||||
$('#inputMixrampdb').val(obj.data.mixrampdb);
|
else
|
||||||
} else {
|
|
||||||
$('#inputMixrampdb').attr('disabled', 'disabled');
|
$('#inputMixrampdb').attr('disabled', 'disabled');
|
||||||
}
|
|
||||||
|
|
||||||
if(obj.data.mixrampdelay != undefined) {
|
if(obj.data.mixrampdelay != undefined)
|
||||||
$('#inputMixrampdelay').removeAttr('disabled');
|
$('#inputMixrampdelay').removeAttr('disabled').val(obj.data.mixrampdelay);
|
||||||
$('#inputMixrampdelay').val(obj.data.mixrampdelay);
|
else
|
||||||
} else {
|
|
||||||
$('#inputMixrampdb').attr('disabled', 'disabled');
|
$('#inputMixrampdb').attr('disabled', 'disabled');
|
||||||
}
|
|
||||||
|
|
||||||
if(obj.data.repeat)
|
if(obj.data.repeat)
|
||||||
$('#btnrepeat').removeClass('btn-secondary').addClass("btn-success")
|
$('#btnrepeat').removeClass('btn-secondary').addClass("btn-success")
|
||||||
@ -747,8 +733,8 @@ function setPagination(number) {
|
|||||||
$('#'+current_app+'PaginationTopPage').text('Page '+(pagination / MAX_ELEMENTS_PER_PAGE + 1)+' / '+totalPages);
|
$('#'+current_app+'PaginationTopPage').text('Page '+(pagination / MAX_ELEMENTS_PER_PAGE + 1)+' / '+totalPages);
|
||||||
$('#'+current_app+'PaginationBottomPage').text('Page '+(pagination / MAX_ELEMENTS_PER_PAGE + 1)+' / '+totalPages);
|
$('#'+current_app+'PaginationBottomPage').text('Page '+(pagination / MAX_ELEMENTS_PER_PAGE + 1)+' / '+totalPages);
|
||||||
if (totalPages > 1) {
|
if (totalPages > 1) {
|
||||||
$('#'+current_app+'PaginationTopPage').removeClass('disabled');
|
$('#'+current_app+'PaginationTopPage').removeClass('disabled').removeAttr('disabled');
|
||||||
$('#'+current_app+'PaginationBottomPage').removeClass('disabled');
|
$('#'+current_app+'PaginationBottomPage').removeClass('disabled').removeAttr('disabled');
|
||||||
$('#'+current_app+'PaginationTopPages').empty();
|
$('#'+current_app+'PaginationTopPages').empty();
|
||||||
$('#'+current_app+'PaginationBottomPages').empty();
|
$('#'+current_app+'PaginationBottomPages').empty();
|
||||||
for (var i=0;i<totalPages;i++) {
|
for (var i=0;i<totalPages;i++) {
|
||||||
@ -756,26 +742,26 @@ function setPagination(number) {
|
|||||||
$('#'+current_app+'PaginationBottomPages').append('<button onclick="gotoPage('+(i * MAX_ELEMENTS_PER_PAGE)+',this,event)" type="button" class="mr-1 mb-1 btn-sm btn btn-secondary">'+(i+1)+'</button>');
|
$('#'+current_app+'PaginationBottomPages').append('<button onclick="gotoPage('+(i * MAX_ELEMENTS_PER_PAGE)+',this,event)" type="button" class="mr-1 mb-1 btn-sm btn btn-secondary">'+(i+1)+'</button>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$('#'+current_app+'PaginationTopPage').addClass('disabled');
|
$('#'+current_app+'PaginationTopPage').addClass('disabled').attr('disabled','disabled');
|
||||||
$('#'+current_app+'PaginationBottomPage').addClass('disabled');
|
$('#'+current_app+'PaginationBottomPage').addClass('disabled').attr('disabled','disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(number > pagination + MAX_ELEMENTS_PER_PAGE) {
|
if(number > pagination + MAX_ELEMENTS_PER_PAGE) {
|
||||||
$('#'+current_app+'PaginationTopNext').removeClass('disabled');
|
$('#'+current_app+'PaginationTopNext').removeClass('disabled').removeAttr('disabled');
|
||||||
$('#'+current_app+'PaginationBottomNext').removeClass('disabled');
|
$('#'+current_app+'PaginationBottomNext').removeClass('disabled').removeAttr('disabled');
|
||||||
$('#'+current_app+'ButtonsBottom').removeClass('hide');
|
$('#'+current_app+'ButtonsBottom').removeClass('hide');
|
||||||
} else {
|
} else {
|
||||||
$('#'+current_app+'PaginationTopNext').addClass('disabled');
|
$('#'+current_app+'PaginationTopNext').addClass('disabled').attr('disabled','disabled');
|
||||||
$('#'+current_app+'PaginationBottomNext').addClass('disabled');
|
$('#'+current_app+'PaginationBottomNext').addClass('disabled').attr('disabled','disabled');
|
||||||
$('#'+current_app+'ButtonsBottom').addClass('hide');
|
$('#'+current_app+'ButtonsBottom').addClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pagination > 0) {
|
if(pagination > 0) {
|
||||||
$('#'+current_app+'PaginationTopPrev').removeClass('disabled');
|
$('#'+current_app+'PaginationTopPrev').removeClass('disabled').removeAttr('disabled');
|
||||||
$('#'+current_app+'PaginationBottomPrev').removeClass('disabled');
|
$('#'+current_app+'PaginationBottomPrev').removeClass('disabled').removeAttr('disabled');
|
||||||
} else {
|
} else {
|
||||||
$('#'+current_app+'PaginationTopPrev').addClass('disabled');
|
$('#'+current_app+'PaginationTopPrev').addClass('disabled').attr('disabled','disabled');
|
||||||
$('#'+current_app+'PaginationBottomPrev').addClass('disabled');
|
$('#'+current_app+'PaginationBottomPrev').addClass('disabled').attr('disabled','disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,10 +1044,6 @@ function scrollToTop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gotoPage(x,element,event) {
|
function gotoPage(x,element,event) {
|
||||||
if ($(element).hasClass('disabled')) {
|
|
||||||
event.preventDefault();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (x) {
|
switch (x) {
|
||||||
case "next":
|
case "next":
|
||||||
pagination += MAX_ELEMENTS_PER_PAGE;
|
pagination += MAX_ELEMENTS_PER_PAGE;
|
||||||
|
@ -893,8 +893,14 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset, char *filter)
|
|||||||
case MPD_ENTITY_TYPE_PLAYLIST:
|
case MPD_ENTITY_TYPE_PLAYLIST:
|
||||||
pl = mpd_entity_get_playlist(entity);
|
pl = mpd_entity_get_playlist(entity);
|
||||||
entityName = mpd_playlist_get_path(pl);
|
entityName = mpd_playlist_get_path(pl);
|
||||||
if (strncmp(filter,"!",1) == 0 || strncasecmp(filter,entityName,1) == 0 ||
|
char *plName = strrchr(entityName, '/');
|
||||||
( strncmp(filter,"0",1) == 0 && isalpha(*entityName) == 0 )
|
if (plName != NULL) {
|
||||||
|
plName ++;
|
||||||
|
} else {
|
||||||
|
plName = strdup(entityName);
|
||||||
|
}
|
||||||
|
if (strncmp(filter,"!",1) == 0 || strncasecmp(filter,plName,1) == 0 ||
|
||||||
|
( strncmp(filter,"0",1) == 0 && isalpha(*plName) == 0 )
|
||||||
) {
|
) {
|
||||||
entities_returned ++;
|
entities_returned ++;
|
||||||
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"playlist\",\"plist\":");
|
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"playlist\",\"plist\":");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user