Skip to content

Commit

Permalink
Better warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vshymanskyy committed Jun 11, 2024
1 parent 0112f2c commit 7b7ead9
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ViperIDE.html
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ <h1>ViperIDE</h1>

function addCSS(css) { document.head.appendChild(document.createElement("style")).innerHTML = css }

const iOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent)

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
Expand Down Expand Up @@ -813,12 +815,18 @@ <h1>ViperIDE</h1>
url = prompt('WebREPL device address:', '192.168.1.123:8266')
if (!url) return;

if (url.startsWith("http://")) { url = url.slice(7) }
if (url.startsWith("https://")) { url = url.slice(8) }
if (!url.includes("://")) { url = "ws://" + url }

if (window.location.protocol === "https:") {
/* Navigate to device, which should automatically reload and ask for WebREPL password */
window.location.assign(url.replace("ws://", "http://"))
return
if (!iOS) {
/* Navigate to device, which should automatically reload and ask for WebREPL password */
window.location.assign(url.replace("ws://", "http://"))
return
} else {
// TODO
}
}
} else {
url = webrepl_url
Expand All @@ -832,6 +840,10 @@ <h1>ViperIDE</h1>
await disconnect()
port = new WebSocketREPL(url, pass)
} else if (type === 'ble') {
if (iOS) {
toastr.error('WebBluetooth is not available on iOS')
return;
}
if (window.location.protocol === "http:") {
toastr.error('WebBluetooth cannot be accessed with unsecure connection')
return;
Expand All @@ -845,6 +857,10 @@ <h1>ViperIDE</h1>
await disconnect()
port = new WebBluetooth()
} else if (type === 'usb') {
if (iOS) {
toastr.error('WebSerial is not available on iOS')
return;
}
if (window.location.protocol === "http:") {
toastr.error('WebSerial cannot be accessed with unsecure connection')
return;
Expand Down

0 comments on commit 7b7ead9

Please sign in to comment.