-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
70 lines (61 loc) · 2.34 KB
/
main.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
window.onload = function () {
var ip = document.getElementById('ip');
var url = document.getElementById('url');
var provision = document.getElementById('provision');
var admin = document.getElementById('admin');
var reboot = document.getElementById('reboot');
ip.onclick = function () {
ip.style.removeProperty('border');
};
url.onclick = function () {
url.style.removeProperty('border');
};
function Validate() {
var patt1 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):[0-9]{1,5}$/;
var patt2 = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
var match1 = ip.value.match(patt1);
var match2 = ip.value.match(patt2);
if (ip.value == "") {
alert("Please submit an IP address.");
ip.style.borderColor = 'red';
return false;
} else if ((match1 || match2) == null) {
alert("Please submit a valid IP address.");
ip.style.borderColor = 'red';
return false;
} else {
return true;
}
};
provision.onclick = function () {
var lowercase = url.value.toLowerCase();
if (Validate()) {
if (url.value == "") {
alert("Please insert the configuration Url");
url.style.borderColor = "red";
return false;
} else if ((lowercase.indexOf('http') == -1) || (lowercase.indexOf('cfg') == -1)) {
alert("Please insert a valid configuration Url");
url.style.borderColor = "red";
return false;
} else {
alert("Your phone may reboot in few seconds")
link = (ip.value) + "/admin/resync?" + (url.value)
window.open("http://" + link)
}
}
};
admin.onclick = function () {
if (Validate()) {
link = (ip.value) + "/admin/advanced"
window.open("http://" + link)
}
};
reboot.onclick = function () {
if (Validate()) {
alert("Your phone will reboot now!")
link = (ip.value) + "/admin/reboot"
window.open("http://" + link)
}
};
};