-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapp-check.js
75 lines (65 loc) · 3.03 KB
/
app-check.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/********************************************************
* Code : RemoteDebugApp
* File : app-check.js - check if the requisites,
* to run app is OK
* Programmer: Joao Lopes
* Comments : Note this file is obfuscated,
* due this code is protected,
* because it uses same portions
* of my commercial codes
********************************************************/
{
var message = "";
var newLocation = "about:blank";
try {
// Check if is HTTPS
if (location.protocol == 'https:') {
message = "*** HTTPS (SSL) not supported:\n"+
"RemoteDebugApp not support HTTPS yet, \n" +
"due a limitation on Arduino web socket server," +
"that not support a web socket with SSL (wss)." +
"This is required with in HTTPS connection.\n" +
"If try access a web socket without SSL," +
"a error occurs in javacript, and it not is accessed.\n\n" +
"Note: Though it yet not secure HTTPS,\n" +
"After page load, all of data transmit is between " +
"the Javascript (client) and web socket server" +
"on Arduino board.\n" +
"And all traffic is only in local network," +
"none of data is exposed to internet\n\n" +
"Click in button to reload the app in HTTP";
newLocation = 'http:' + window.location.href.substring(window.location.protocol.length);
}
// Check browser version
var parser = new UAParser();
var browser = parser.getBrowser();
var os = parser.getOS();
console.info("browser: " + browser);
if (browser) {
console.info("browser name: " + browser.name + " os: " + os.name + " " + os.version);
//alert("browser name: " + browser.name + " os: " + os.name + " " + os.version);
if (browser.name.substring(0, 2) == "IE") {
message = "*** Internet explorer not supported:\n" +
"This HTML5 Web App not support Internet Explorer\n" +
"Please use the Edge or another modern browser, as Chrome or Firefox\n\n" +
"Click in button to exit";
}
if (os.name == "iOS" && os.version.substring(0, 3) == "10.") {
message = "*** iOS 10 not supported\n"+
"This HTML5 Web App not support iOS version 10\n"+
// "Please use another modern browser, as Chrome or Firefox\n\n" +
"Click in button to exit";
}
}
} catch (error) {
console.error("error on app-check");
message = "An error occurs on app checking";
} finally {
if (message != "") {
alert (message);
// Redirect
location.replace (newLocation);
}
}
}
// End