]> git.0d.be Git - nanofun.git/commitdiff
add indicators for devices
authorFrédéric Péters <fpeters@0d.be>
Wed, 22 Feb 2017 17:25:34 +0000 (18:25 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sat, 1 Apr 2017 10:37:19 +0000 (12:37 +0200)
index.html
nanofun.css
nanofun.js

index 039f0f3e117490d2e12f28f03fa0b9f83c707e17..9c92333984fb65faeaed5b15958b40bf53d5b8af 100644 (file)
@@ -19,8 +19,7 @@
    </div>
   </div>
   <div id="msg"></div>
    </div>
   </div>
   <div id="msg"></div>
-  <div id="midiinputs"></div>
-  <div id="midioutputs"></div>
+  <div id="devices"><div class="nanopad">nanoPAD</div><div class="nanokontrol">nanoKONTROL</div></div>
 
   <form>
     <div><label>Master</label> <input id="master-gain" type="range" min="0" max="127" value="127"></div>
 
   <form>
     <div><label>Master</label> <input id="master-gain" type="range" min="0" max="127" value="127"></div>
index 99c357ec2255cc89ad1aa2f687fd39520bd000b1..ea67cf559dc3447a3ab07f2fd0e5b9dd71f8969c 100644 (file)
@@ -84,3 +84,18 @@ form label {
   display: inline-block;
   width: 10em;
 }
   display: inline-block;
   width: 10em;
 }
+
+#devices {
+  position: absolute;
+  bottom: 2em;
+  right: 1em;
+}
+
+#devices div {
+  padding: 1px 5px;
+  margin-top: 2px;
+}
+
+#devices div.on {
+  background: #6aff6a;
+}
index 6b8ba95700f9c0c466e39e84c223081b626fd68a..34e1dcc2184a1f675f4092afac24778c9776cccf 100644 (file)
@@ -54,10 +54,6 @@ onMIDIAccessChange: function(e) {
     console.log('on midi access change', e);
     //console.log(this);
     var port = e.port;
     console.log('on midi access change', e);
     //console.log(this);
     var port = e.port;
-    var portContainer = $("#midi" + port.type + "s");
-    if (portContainer.html().startsWith("<p>No connected")) {
-        portContainer.empty();
-    }
 
     if (port.state == "disconnected") {
       if (port.type == "input") {
 
     if (port.state == "disconnected") {
       if (port.type == "input") {
@@ -65,12 +61,17 @@ onMIDIAccessChange: function(e) {
       } else {
         this.outputs[port.name] = undefined;
       }
       } else {
         this.outputs[port.name] = undefined;
       }
+      if (port.name == 'nanoPAD2 MIDI 1') { $('#devices .nanopad').removeClass('on'); }
+      if (port.name == 'nanoKONTROL2 MIDI 1') { $('#devices .nanokontrol').removeClass('on'); }
     } else {
       if (port.type == "input") {
         if (this.inputs[port.name] === undefined) { this.registerPort(port); }
       } else {
         if (this.outputs[port.name] === undefined) { this.registerPort(port); }
       }
     } else {
       if (port.type == "input") {
         if (this.inputs[port.name] === undefined) { this.registerPort(port); }
       } else {
         if (this.outputs[port.name] === undefined) { this.registerPort(port); }
       }
+            console.log('hello:', port.name);
+      if (port.name == 'nanoPAD2 MIDI 1') { $('#devices .nanopad').addClass('on'); }
+      if (port.name == 'nanoKONTROL2 MIDI 1') { $('#devices .nanokontrol').addClass('on'); }
       this.renderPort(port);
     }
 },
       this.renderPort(port);
     }
 },