From 0faf70ad05b90731638c6d760a59a0036ecc6d36 Mon Sep 17 00:00:00 2001
From: eb041592 <35889760+eb041592@users.noreply.github.com>
Date: Wed, 4 Apr 2018 19:40:12 +0200
Subject: [PATCH] Add queue's total time to panel header.
---
htdocs/index.html | 9 +++++----
htdocs/js/mpd.js | 12 ++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/htdocs/index.html b/htdocs/index.html
index 6bf5c60..eb3319a 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -81,10 +81,11 @@
-
+
-
Queue
+
Queue
+
@@ -218,7 +219,7 @@
ympd uses following excellent software:
-
+
-
+
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);