OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script> | 2 <script> |
3 'use strict'; | 3 'use strict'; |
4 window.onmessage = messageEvent => { | 4 window.onmessage = messageEvent => { |
5 if (messageEvent.data === 'Ready') { | 5 if (messageEvent.data === 'Ready') { |
6 navigator.usb.addEventListener('connect', connectEvent => { | 6 navigator.usb.addEventListener('connect', connectEvent => { |
7 connectEvent.device.open().then(() => { | 7 connectEvent.device.open().then(() => { |
8 parent.postMessage('Success', '*'); | 8 parent.postMessage('Success', '*'); |
9 }).catch(error => { | 9 }).catch(error => { |
10 console.log(error); | |
11 parent.postMessage('FAIL: open rejected ' + error, '*'); | 10 parent.postMessage('FAIL: open rejected ' + error, '*'); |
12 }); | 11 }); |
13 }); | 12 }); |
14 parent.postMessage('Ready', '*'); | 13 parent.postMessage('Ready', '*'); |
15 } | 14 } |
16 }; | 15 }; |
17 </script> | 16 </script> |
OLD | NEW |