-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice-popup.js
28 lines (23 loc) · 867 Bytes
/
device-popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
async function setDeviceListOptions () {
const selectElement = document.getElementById('midiOutSelect');
const deviceList = await window.WebMidiAPI.openMidiDeviceSelection();
deviceList.forEach(function (device) {
const node = document.createElement('option');
const textnode = document.createTextNode(device.name);
node.appendChild(textnode);
node.setAttribute('value', device.id);
selectElement.appendChild(node);
});
}
function closeWindow () {
const selectElement = document.getElementById('midiOutSelect');
window.WebMidiAPI.setMidiOutputId(selectElement.value);
window.WebMidiAPI.closeDevicePopup();
return true;
}
setDeviceListOptions();
document.addEventListener('DOMContentLoaded', function () {
const form = document.getElementById('device-form');
form.addEventListener('submit', closeWindow);
});