diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index ce2fd8e..5112874 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -222,6 +222,18 @@ function webSocketConnect() {
if(current_app !== 'queue')
break;
+ if (obj.totalTime > 0) {
+ var hours = Math.floor(obj.totalTime / 3600);
+ var minutes = Math.floor(obj.totalTime / 60) - hours * 60;
+ var seconds = obj.totalTime - hours * 3600 - minutes * 60;
+
+ $('#panel-heading-info').text('Total: ' +
+ (hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
+ minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
+ } else {
+ $('#panel-heading-info').empty();
+ }
+
$('#salamisandwich > tbody').empty();
for (var song in obj.data) {
var minutes = Math.floor(obj.data[song].duration / 60);
From 84b3ea71a4075aa67e7d715493e1d12ef5b84a36 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Wed, 4 Apr 2018 19:44:08 +0200
Subject: [PATCH 3/6] Switch queue's line break before album from HTML to CSS.
---
htdocs/css/mpd.css | 6 ++++--
htdocs/js/mpd.js | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/htdocs/css/mpd.css b/htdocs/css/mpd.css
index 8931c92..6579fcc 100644
--- a/htdocs/css/mpd.css
+++ b/htdocs/css/mpd.css
@@ -60,8 +60,10 @@ body {
}
#salamisandwich td:nth-child(2) span {
- font-style:italic;
- font-size:90%;
+ font-style: italic;
+ font-size: 90%;
+
+ display: block;
}
tbody {
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 5112874..a79affa 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -241,7 +241,7 @@ function webSocketConnect() {
$('#salamisandwich > tbody').append(
"
" + (obj.data[song].pos + 1) + " | " +
- "" + obj.data[song].artist + " " + obj.data[song].album + " | " +
+ "" + obj.data[song].artist + "" + obj.data[song].album + " | " +
"" + obj.data[song].title + " | " +
"" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
");
@@ -361,7 +361,7 @@ function webSocketConnect() {
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 + " | ";
+ var details = "" + obj.data[item].artist + "" + obj.data[item].album + " | " + obj.data[item].title + " | ";
}
$('#salamisandwich > tbody').append(
From c226026a51fc5503223ccae8b68a2ab968caa1e4 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Wed, 4 Apr 2018 21:09:02 +0200
Subject: [PATCH 4/6] Treat album while browsing the same way as in the queue.
---
htdocs/js/mpd.js | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index a79affa..7765644 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -241,8 +241,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 +
" | |
");
}
@@ -358,15 +358,17 @@ 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 + " | ";
- }
+// 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(
+ $('#salamisandwich > tbody').append(
"" +
- " | " + details +
+ " | " +
+ "" + obj.data[song].artist + "" + obj.data[song].album + " | " +
+ "" + obj.data[song].title + " | " +
"" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
"
);
From 18417b9ed581270a829ad6cf946a8c530ecaa6e1 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Wed, 4 Apr 2018 22:00:32 +0200
Subject: [PATCH 5/6] Reset #panel-heading-info on update of #panel-heading.
---
htdocs/js/mpd.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index 7765644..ef1ad1d 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -45,6 +45,8 @@ var app = $.sammy(function() {
socket.send('MPD_API_GET_QUEUE,'+pagination);
$('#panel-heading').text("Queue");
+ $('#panel-heading-info').empty();
+
$('#queue').addClass('active');
}
@@ -121,6 +123,8 @@ var app = $.sammy(function() {
$('#dirble_right').find("tr:gt(0)").remove();
$('#panel-heading').text("Dirble");
+ $('#panel-heading-info').empty();
+
$('#dirble').addClass('active');
$('#next').addClass('hide');
@@ -147,6 +151,8 @@ var app = $.sammy(function() {
$('#dirble_right').find("tr:gt(0)").remove();
$('#panel-heading').text("Dirble");
+ $('#panel-heading-info').empty();
+
$('#dirble').addClass('active');
dirble_stations = false;
From 2cb99de8521cdbe0aaa85eb7526360ebc75f0b77 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Thu, 5 Apr 2018 00:59:39 +0200
Subject: [PATCH 6/6] Revert some changes: There's no need to print the
artist/album for each song while browsing.
---
htdocs/js/mpd.js | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js
index ef1ad1d..13fd4e4 100644
--- a/htdocs/js/mpd.js
+++ b/htdocs/js/mpd.js
@@ -364,17 +364,17 @@ 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 + " | ";
-// }
+ if (obj.data[item].artist == null) {
+ var artist = "";
+ } else {
+ var artist = " | " + obj.data[item].artist +
+ "" + obj.data[item].album + " | ";
+ }
$('#salamisandwich > tbody').append(
" | " +
" | " +
- "" + obj.data[song].artist + "" + obj.data[song].album + " | " +
- "" + obj.data[song].title + " | " +
+ artist + obj.data[item].title + "" +
"" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
" | |
"
);