-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.js
191 lines (159 loc) · 4.79 KB
/
functions.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
function mURLin_ValidateURLForm()
{
var host;
var URL;
var timeout;
var proxyserver;
var proxyenabled;
var result = true;
// Validate each entry
host = document.getElementById('selected_host');
if (host.value === "")
{
alert("You must select a host to map the URL to.")
result = false;
}
URL = document.getElementById('url');
if (!ValidateURL(URL.value))
{
URL.style.background = '#FFAAAA';
result = false;
}
else
{
URL.style.background = '#FFFFFF';
}
if ((document.getElementById('text_match').value).length >= 2048)
{
(document.getElementById('text_match')).style.background = '#FFAAAA';
result = false;
}
else
{
(document.getElementById('text_match')).style.background = '#FFFFFF';
}
timeout = document.getElementById('timeout');
if (timeout.value < 0 || timeout.value > 100 || timeout.value === "")
{
timeout.style.background = '#FFAAAA';
result = false;
}
else
{
timeout.style.background = '#FFFFFF';
}
proxyserver = document.getElementById('proxyaddress');
proxyenabled = document.getElementById('proxyserver');
if (proxyserver.value == "" && proxyenabled.checked == true)
{
proxyserver.style.background = '#FFAAAA';
result = false;
}
else
{
proxyserver.style.background = '#FFFFFF';
}
return result;
}
function ValidateURL(url)
{
if (url.length < 2048)
return /^(ftp|http|https):\/\/[^ "]+$/.test(url);
else
return false;
}
function mURLin_test_match(text_match, url, timeout, proxyserver, proxyaddress, proxyusername, proxypassword)
{
var proxy = "";
if (proxyserver === true)
proxy = "&proxy=" + proxyaddress;
$.get("./scripts/test_regex.php?regex=" + encodeURIComponent(text_match) + "&url=" + encodeURIComponent(url) + "&timeout=" + timeout + proxy + "&proxyusername=" + proxyusername + "&proxypassword=" + proxypassword, function(result)
{
alert(result);
});
}
function mURLin_open_url(url, timeout, proxyserver, proxyaddress, proxyusername, proxypassword)
{
var proxy = "";
if (proxyserver === true)
proxy = "&proxy=" + proxyaddress;
window.open('showpage.php?page=' + encodeURIComponent(url) + "&timeout=" + timeout + proxy + "&proxyusername=" + proxyusername + "&proxypassword=" + proxypassword, 'urlWin', 'toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, width=600, height=400');
}
function CheckAll(id, value)
{
var checkboxes = document.getElementsByName(id);
for(index = 0; index < checkboxes.length; ++index)
{
checkboxes[index].checked = value;
}
}
function CheckAllFunction(state, allchk)
{
if(!state.checked)
{
var allbox = document.getElementById(allchk);
allbox.checked = false;
}
}
function CheckBox(chkbox, allchk)
{
// Check the box and uncheck the select all box if required
var box = document.getElementById(chkbox);
box.checked = !box.checked;
CheckAllFunction(box, allchk);
}
function mURLin_SelectHostClick(show)
{
var shade = document.getElementById('shade');
var popup = document.getElementById('popup');
var display;
if(show)
display = 'inline';
else
display = 'none';
shade.style.display = display;
popup.style.display = display;
}
function mURLin_RefreshHosts(selectedhost, filter)
{
$.get("./scripts/get_hosts.php?id=" + selectedhost + "&filter=" + filter, function(result)
{
document.getElementById('hosttable').innerHTML = result;
});
}
function mURLin_SelectNewHost(hostid)
{
// Select new host 'hostid'
$.get("./scripts/get_hosts.php?action=info&id=" + hostid, function(result)
{
// Split the result into 3...
var s = result.split(",");
document.getElementById('hostname_text').innerHTML = s[2];
document.getElementById('dns_text').innerHTML = s[1];
document.getElementById('selected_host').value = s[0];
});
// Close the shade
mURLin_SelectHostClick(false);
}
function mURLin_selectHost(hostid)
{
document.getElementById(hostid).checked = true;
}
//function mURLin_CheckURLForm()
//{
// // Check each element in the form for validity
// var name = document.getElementById('id');
// var url = document.getElementById('url');
// var text_match = document.getElementById('text_match');
// var timeout = document.getElementById('timeout');
//
// var result = true;
//
// if (name.value = "" || name.value == "NEW")
// {
// result = false;
// name.bgcolor="light red";
// }
//
// return result;
//}