Hide output button(s) if there is only one configured output
authoreb041592 <35889760+eb041592@users.noreply.github.com>
Sat, 3 Feb 2018 23:30:45 +0000 (00:30 +0100)
committereb041592 <35889760+eb041592@users.noreply.github.com>
Sat, 3 Feb 2018 23:30:45 +0000 (00:30 +0100)
htdocs/js/mpd.js

index 5c8a8d1..ba7dfff 100644 (file)
@@ -496,10 +496,14 @@ function webSocketConnect() {
                     break;
                 case "outputnames":
                     $('#btn-outputs-block button').remove();
-                    $.each(obj.data, function(id, name){
-                        var btn = $('<button id="btnoutput'+id+'" class="btn btn-default" onclick="toggleoutput(this, '+id+')"><span class="glyphicon glyphicon-volume-up"></span> '+name+'</button>');
-                        btn.appendTo($('#btn-outputs-block'));
-                    });
+                    if (obj.data.length > 1) {
+                       $.each(obj.data, function(id, name){
+                            var btn = $('<button id="btnoutput'+id+'" class="btn btn-default" onclick="toggleoutput(this, '+id+')"><span class="glyphicon glyphicon-volume-up"></span> '+name+'</button>');
+                            btn.appendTo($('#btn-outputs-block'));
+                        });
+                   } else {
+                        $('#btn-outputs-block').removeClass('btn-group-vertical');
+                   }
                     /* remove cache, since the buttons have been recreated */
                     last_outputs = '';
                     break;