" + (obj.data[song].pos + 1) + " | " +
- ""+ obj.data[song].title +" | " +
- ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
+ " | " + obj.data[song].artist + " [" + obj.data[song].album + "] - " + obj.data[song].title + " | " +
+ "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
");
}
@@ -299,14 +299,14 @@ function webSocketConnect() {
};
//Make queue table sortable
- $("#salamisandwich > tbody").sortable({
+ $('#salamisandwich > tbody').sortable({
helper: fixHelperModified,
stop: function(event,ui) {renumber_table('#salamisandwich',ui.item)}
}).disableSelection();
break;
- case "search":
+ case 'search':
$('#wait').modal('hide');
- case "browse":
+ case 'browse':
if(current_app !== 'browse' && current_app !== 'search')
break;
@@ -319,7 +319,7 @@ function webSocketConnect() {
}
for (var item in obj.data) {
switch(obj.data[item].type) {
- case "directory":
+ case 'directory':
var clazz = 'dir';
if (filter !== undefined) {
var first = obj.data[item].dir[0];
@@ -338,7 +338,7 @@ function webSocketConnect() {
"" +
" | " +
- "" + obj.data[item].title +" | " +
- ""+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
+ " | " + (typeof obj.data[item].artist !== 'undefined' ? obj.data[item].artist + " [" + obj.data[item].album + "] - " : '') + obj.data[item].title + " | " +
+ "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
"
);
break;
- case "wrap":
+ case 'wrap':
if(current_app == 'browse') {
$('#next').removeClass('hide');
} else {
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 2911e46..099f673 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -475,6 +475,24 @@ char* mpd_get_title(struct mpd_song const *song)
return str;
}
+char* mpd_get_artist(struct mpd_song const *song)
+{
+ char *str;
+
+ str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
+
+ return str;
+}
+
+char* mpd_get_album(struct mpd_song const *song)
+{
+ char *str;
+
+ str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM, 0);
+
+ return str;
+}
+
int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)
{
struct mpd_status *status;
@@ -559,18 +577,10 @@ int mpd_put_current_song(char *buffer)
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
-
- if(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0));
- }
-
- if(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0) != NULL)
- {
- cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
- cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ALBUM, 0));
- }
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(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, "}}");
mpd_song_free(song);
@@ -604,6 +614,10 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(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, "},");
}
mpd_entity_free(entity);
@@ -718,6 +732,10 @@ int mpd_search(char *buffer, char *searchstr)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
+ cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
+ cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(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, "},");
mpd_song_free(song);
From 3fe7d9c44c5980b0e93353aa9116196b415d7ac2 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Fri, 2 Feb 2018 02:40:40 +0100
Subject: [PATCH 2/5] Some more spelling
---
htdocs/index.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/htdocs/index.html b/htdocs/index.html
index 3996042..d74dc67 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -177,15 +177,15 @@
# |
- Title |
+ Track |
Duration |
|
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index ef760bf..6c8841a 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -238,7 +238,8 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" + (obj.data[song].pos + 1) + " | " +
- "" + obj.data[song].artist + " [" + obj.data[song].album + "] - " + obj.data[song].title + " | " +
+ "" + obj.data[song].artist + " " + obj.data[song].album + " | " +
+ "" + obj.data[song].title + " | " +
"" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
");
}
@@ -334,7 +335,7 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" +
" | " +
- "" + basename(obj.data[item].dir) + " | " +
+ "" + basename(obj.data[item].dir) + " | " +
" | |
"
);
break;
@@ -346,7 +347,7 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"" +
" | " +
- "" + basename(obj.data[item].plist) + " | " +
+ "" + basename(obj.data[item].plist) + " | " +
" | |
"
);
break;
@@ -354,10 +355,15 @@ function webSocketConnect() {
var minutes = Math.floor(obj.data[item].duration / 60);
var seconds = obj.data[item].duration - minutes * 60;
+ if (typeof obj.data[item].artist === 'undefined') {
+ var details = "" + obj.data[item].title + " | ";
+ } else {
+ var details = "" + obj.data[item].artist + " " + obj.data[item].album + " | " + obj.data[item].title + " | ";
+ }
+
$('#salamisandwich > tbody').append(
"" +
- " | " +
- "" + (typeof obj.data[item].artist !== 'undefined' ? obj.data[item].artist + " [" + obj.data[item].album + "] - " : '') + obj.data[item].title + " | " +
+ " | " + details +
"" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
"
);
@@ -367,8 +373,8 @@ function webSocketConnect() {
$('#next').removeClass('hide');
} else {
$('#salamisandwich > tbody').append(
- " | " +
- "Too many results, please refine your search! | " +
+ "
| " +
+ "Too many results, please refine your search! | " +
" | |
"
);
}
diff --git a/src/mpd_client.c b/src/mpd_client.c
index 099f673..1054ede 100644
--- a/src/mpd_client.c
+++ b/src/mpd_client.c
@@ -480,8 +480,11 @@ char* mpd_get_artist(struct mpd_song const *song)
char *str;
str = (char *)mpd_song_get_tag(song, MPD_TAG_ARTIST, 0);
-
- return str;
+ if (str == NULL) {
+ return "";
+ } else {
+ return str;
+ }
}
char* mpd_get_album(struct mpd_song const *song)
@@ -489,8 +492,11 @@ char* mpd_get_album(struct mpd_song const *song)
char *str;
str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM, 0);
-
- return str;
+ if (str == NULL) {
+ return "";
+ } else {
+ return str;
+ }
}
int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)
From 73a844eb71ce852b7f03bfcb0bda97cb6aa307f0 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Sat, 3 Feb 2018 16:34:22 +0100
Subject: [PATCH 4/5] Fixed error with "... added" notifications
---
htdocs/js/mpd.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 6c8841a..99fc70f 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -395,7 +395,7 @@ function webSocketConnect() {
socket.send(onClickAction + "," + decodeURI($(this).parents("tr").attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', $(this).parents("tr")).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', $(this).parents("tr")).text() + "\" added"
} }).show();
}).fadeTo('fast',1);
}
@@ -429,7 +429,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
@@ -437,7 +437,7 @@ function webSocketConnect() {
socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
$('.top-right').notify({
message:{
- text: "Playlist " + $('td:nth-child(2)', this).text() + " added"
+ text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
}
}).show();
break;
From b4084034d0f87bbec1ae23781d62bc49d75f066e Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Sun, 4 Feb 2018 13:24:44 +0100
Subject: [PATCH 5/5] Reverted some formatting; aligned CSS
---
htdocs/css/mpd.css | 14 +++++++-------
htdocs/index.html | 6 +++---
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/htdocs/css/mpd.css b/htdocs/css/mpd.css
index 88987e2..5d6afd3 100644
--- a/htdocs/css/mpd.css
+++ b/htdocs/css/mpd.css
@@ -22,10 +22,10 @@ body {
}
#counter {
- font-size: 24px;
- margin-top: -6px;
- margin-left: 10px;
- min-width: 50px;
+ font-size: 24px;
+ margin-top: -6px;
+ margin-left: 10px;
+ min-width: 50px;
}
#search {
@@ -33,7 +33,7 @@ body {
}
.btn-group-hover {
- opacity: 20%;
+ opacity: 20%;
}
.btn:active,
@@ -60,8 +60,8 @@ body {
}
#salamisandwich td:nth-child(2) span {
- font-style:italic;
- font-size:90%;
+ font-style:italic;
+ font-size:90%;
}
tbody {
diff --git a/htdocs/index.html b/htdocs/index.html
index 726d193..683f860 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -177,15 +177,15 @@