-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.js
30 lines (25 loc) · 915 Bytes
/
common.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
29
/** Global variables */
var dataList = document.querySelector('#midi-data ul')
const MIDI_SERVICE_UID = '03B80E5A-EDE8-4B33-A751-6CE34EC4C700'.toLowerCase();
const MIDI_IO_CHARACTERISTIC_UID = '7772E5DB-3868-4112-A1A9-F2669D106BF3'.toLowerCase();
/** Get variable from URL
* Use: ?bleDevice=BLE_MIDI_Service
*/
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
/** Console function
* Only present on RX-page. */
function printToConsole(content) {
var newItem = document.createElement('li');
newItem.appendChild(document.createTextNode(content));
dataList.appendChild(newItem);
}
if (!navigator.bluetooth) {
printToConsole('Browser does not support web Bluetooth!');
console.log('Web Bluetooth API is not available in browser.');
}