1
|
/*
|
2
|
pool.js
|
3
|
part of pfSense (http://www.pfsense.com/)
|
4
|
|
5
|
Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
/* Add server to virtual server pool
|
31
|
* operates on whatever form is passed to it
|
32
|
*/
|
33
|
function AddServerToPool(form) {
|
34
|
|
35
|
var theSel = form['servers[]'];
|
36
|
for(i=theSel.length-1; i>=0; i--)
|
37
|
{
|
38
|
if(theSel.options[i].value == form.ipaddr.value) {
|
39
|
alert("IP Address Already In List");
|
40
|
return true;
|
41
|
}
|
42
|
}
|
43
|
|
44
|
if (form.type.selectedIndex == 1) {
|
45
|
if (!form.monitorip.value) {
|
46
|
alert("Monitor IP Required First!");
|
47
|
return true;
|
48
|
}
|
49
|
}
|
50
|
|
51
|
var ServerPort=form.ipaddr.value;
|
52
|
if(form.type.selectedIndex == 0)
|
53
|
var ServerPort=form.ipaddr.value;
|
54
|
else
|
55
|
var ServerPort=form.ipaddr.value + "|" + form.monitorip.value;
|
56
|
form['servers[]'].options[form['servers[]'].options.length] = new Option(ServerPort,ServerPort);
|
57
|
}
|
58
|
|
59
|
|
60
|
function AllServers(id, selectAll) {
|
61
|
var opts = document.getElementById(id).getElementsByTagName('option');
|
62
|
for (i = 0; i < opts.length; i++)
|
63
|
{
|
64
|
opts[i].selected = selectAll;
|
65
|
}
|
66
|
}
|
67
|
|
68
|
|
69
|
function RemoveServerFromPool(form)
|
70
|
{
|
71
|
var theSel = form['servers[]'];
|
72
|
var selIndex = theSel.selectedIndex;
|
73
|
if (selIndex != -1) {
|
74
|
for(i=theSel.length-1; i>=0; i--)
|
75
|
{
|
76
|
if(theSel.options[i].selected)
|
77
|
{
|
78
|
theSel.options[i] = null;
|
79
|
}
|
80
|
}
|
81
|
if (theSel.length > 0) {
|
82
|
theSel.selectedIndex = selIndex == 0 ? 0 : selIndex - 1;
|
83
|
}
|
84
|
}
|
85
|
}
|