1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-01-11 18:00:36 +00:00

Queue Search

This commit is contained in:
jcorporation 2018-05-25 00:08:33 +01:00
parent d773dfb745
commit 78c1aae4e4
2 changed files with 20 additions and 15 deletions

View File

@ -46,6 +46,7 @@ var app = $.sammy(function() {
$('#cardBrowse').addClass('hide');
$('#cardSearch').addClass('hide');
$('.pagination').addClass('hide');
$('#searchqueue > input').val('');
pagination = 0;
browsepath = '';
}
@ -223,7 +224,7 @@ function webSocketConnect() {
$('#queueList > tbody').empty();
for (var song in obj.data) {
if (obj.data[song].type == 'wrap') {
$('#'+current_app+'List > tbody').append(
$('#queueList > tbody').append(
"<tr><td><span class=\"material-icons\">error_outline</span></td>" +
"<td colspan=\"3\">Too many results, please refine your search!</td>" +
"<td></td><td></td></tr>"
@ -251,7 +252,9 @@ function webSocketConnect() {
$('#queuePrev').removeClass('disabled');
$('#queuePagination').removeClass('hide');
}
}
} else {
$('#queuePagination').addClass('hide');
}
if ( isTouch ) {
$('#queueList > tbody > tr > td:last-child').append(
@ -726,15 +729,15 @@ $('#search').submit(function () {
});
$('#searchqueue > input').keyup(function (event) {
// if ( event.which == 13 ) {
var searchstr=$('#searchqueue > input').val();
if (searchstr.length > 3) {
socket.send('MPD_API_SEARCH_QUEUE,' + searchstr);
var searchstr=$('#searchqueue > input').val();
if ( event.which == 13 ) {
if (searchstr.length >= 3) {
socket.send('MPD_API_SEARCH_QUEUE,' + searchstr);
}
else if (searchstr.length == 0) {
socket.send('MPD_API_GET_QUEUE,0');
}
// }
}
if (searchstr.length == 0) {
socket.send('MPD_API_GET_QUEUE,0');
}
});
$('#searchqueue').submit(function () {

View File

@ -760,8 +760,9 @@ int mpd_search(char *buffer, char *searchstr)
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"search\",\"data\":[ ");
while((song = mpd_recv_song(mpd.conn)) != NULL) {
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\"");
// cur += json_emit_raw_str(cur, end - cur, ",\"uri\":");
// cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
@ -808,8 +809,9 @@ int mpd_search_queue(char *buffer, char *searchstr)
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"queuesearch\",\"data\":[ ");
while((song = mpd_recv_song(mpd.conn)) != NULL) {
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\",\"uri\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"song\"");
// cur += json_emit_raw_str(cur, end - cur, ",\"uri\":");
// cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song));
cur += json_emit_raw_str(cur, end - cur, ",\"id\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_id(song));
cur += json_emit_raw_str(cur, end - cur, ",\"pos\":");
@ -828,7 +830,7 @@ int mpd_search_queue(char *buffer, char *searchstr)
mpd_song_free(song);
/* Maximum results */
if(i++ >= 300)
if(i++ >= 100)
{
cur += json_emit_raw_str(cur, end - cur, "{\"type\":\"wrap\"},");
break;