-
Notifications
You must be signed in to change notification settings - Fork 179
/
main.js
executable file
·53 lines (47 loc) · 1.38 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
function api_invoke(uri, params, callback) {
$.ajax({
url: uri,
data: params,
type: 'POST',
cache: false,
dataType: 'json',
success: function (data) {
callback(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
if (XMLHttpRequest.status == 302) {
location.href = "/login.html";
return;
}
if ("undefined" == typeof(XMLHttpRequest.responseJSON)) {
alert("System error, please try again later.");
return;
}
alert(XMLHttpRequest.responseJSON.msg);
}
});
}
function load_page(pageUrl) {
$(".content-wrapper").load(pageUrl);
}
function get_query_string(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)return unescape(r[2]);
return null;
}
function is_ip(ip) {
var re = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
return re.test(ip);
}
function check_port(port) {
if (port > 65535) {
return false;
}
var re = /^[1-9]+[0-9]*]*$/
return re.test(port);
}
function check_weight(weight) {
var re = /^[1-9]+[0-9]*]*$/
return re.test(weight);
}