diff options
| -rw-r--r-- | index.html | 30 | ||||
| -rw-r--r-- | main.mjs | 13 |
2 files changed, 29 insertions, 14 deletions
@@ -4,17 +4,23 @@ <script defer src="main.mjs"></script> </head> <body> - <h1>Setup AIRMX Pro</h1> - <div> - <input type="text" id="ssid" placeholder="SSID" /> - </div> - <div> - <input type="password" id="password" placeholder="Password" /> - </div> - <div> - <button id="connect" type="button"> - Connect - </button> - </div> + <p id="unsupported-message" style="display: none;"> + Your browser does not support the Web Bluetooth API. Please switch to Google Chrome and try again. + </p> + + <main> + <h1>Setup AIRMX Pro</h1> + <div> + <input type="text" id="ssid" placeholder="SSID" /> + </div> + <div> + <input type="password" id="password" placeholder="Password" /> + </div> + <div> + <button id="connect" type="button" onclick="connect()"> + Connect + </button> + </div> + </main> </body> </html> @@ -216,5 +216,14 @@ function handleDeviceResponse(event) { console.log(`Received data from device: ${receivedBytes.join(' ')}`) } -const button = document.getElementById('connect') -button.addEventListener('click', connect) +function supportBluetoothApi() { + return 'bluetooth' in navigator +} + +if (! supportBluetoothApi()) { + const unsupportedMessage = document.getElementById('unsupported-message') + unsupportedMessage.style.display = 'block' + + const main = document.querySelector('main') + main.style.display = 'none' +} |
