Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
fe848ddd
Commit
fe848ddd
authored
Mar 15, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) refactor vpn_pppoe_edit.php, zap jquery.ipv4v6ify.js row_helper.js
parent
181dd67b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
468 additions
and
810 deletions
+468
-810
jquery.ipv4v6ify.js
src/www/javascript/jquery.ipv4v6ify.js
+0
-139
row_helper.js
src/www/javascript/row_helper.js
+0
-97
vpn_pppoe_edit.php
src/www/vpn_pppoe_edit.php
+468
-574
No files found.
src/www/javascript/jquery.ipv4v6ify.js
deleted
100644 → 0
View file @
181dd67b
/*jslint browser: true, eqeqeq: true, undef: true */
/*global jQuery */
/******************************************************************************
Lines above are for jslint, the JavaScript verifier. http://www.jslint.com/
******************************************************************************/
/* MIT-licensed code from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some */
/* (C) 2007 Mozilla Developer Network and/or Jeff Walden */
if
(
!
Array
.
prototype
.
some
)
{
Array
.
prototype
.
some
=
function
(
fun
/*, thisp */
)
{
"
use strict
"
;
if
(
!
this
)
{
throw
new
TypeError
();
}
var
t
=
Object
(
this
);
var
len
=
t
.
length
>>>
0
;
if
(
typeof
fun
!==
"
function
"
)
{
throw
new
TypeError
();
}
var
thisp
=
arguments
[
1
];
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
if
(
i
in
t
&&
fun
.
call
(
thisp
,
t
[
i
],
i
,
t
))
{
return
true
;
}
}
return
false
;
};
}
(
function
(
$
)
{
// --------------------------------------------------------------------
// find pairs of <input class='ipv4v6'> (textbox for IPv4 or IPv6 addr)
// and <select class='ipv4v6'> (dropdown for # bits in CIDR) and
// activate behavior that restricts options in the <select> when an
// ipv4 address is typed in the <input>.
// --------------------------------------------------------------------
var
_ipv4v6ify
=
function
(
input1
,
input2
)
{
var
options
=
Array
.
prototype
.
slice
.
call
(
input2
.
options
,
0
);
var
has_128
=
options
.
some
(
function
(
x
)
{
return
parseInt
(
x
.
value
,
10
)
===
128
;
});
var
has_0
=
options
.
some
(
function
(
x
)
{
return
parseInt
(
x
.
value
,
10
)
===
0
;
});
var
max_ipv6
=
has_128
?
128
:
127
;
var
min_ipv6
=
has_0
?
0
:
1
;
var
max_ipv4
=
has_128
?
32
:
31
;
var
min_ipv4
=
has_0
?
0
:
1
;
var
was_ipv4
=
undefined
;
var
is_ipv4
=
undefined
;
var
restrict_bits_to_ipv4
=
function
()
{
input2
.
options
.
length
=
0
;
for
(
var
i
=
0
;
i
<
options
.
length
;
i
+=
1
)
{
var
val
=
parseInt
(
options
[
i
].
value
,
10
);
if
(
val
>=
min_ipv4
&&
val
<=
max_ipv4
)
{
input2
.
options
.
add
(
options
[
i
]);
}
}
};
var
unrestrict_bits
=
function
()
{
input2
.
options
.
length
=
0
;
for
(
var
i
=
0
;
i
<
options
.
length
;
i
+=
1
)
{
input2
.
options
.
add
(
options
[
i
]);
}
};
var
onchange_handler
=
function
()
{
was_ipv4
=
is_ipv4
;
is_ipv4
=
/
\.
/
.
test
(
input1
.
value
)
&&
!
/
\:
/
.
test
(
input1
.
value
);
// handle state transitions to gracefully change the
// value in the dropdown.
var
bits
=
parseInt
(
$
(
input2
).
val
(),
10
);
if
(
was_ipv4
===
false
&&
is_ipv4
===
true
)
{
restrict_bits_to_ipv4
();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if
(
bits
<
min_ipv4
)
{
$
(
input2
).
val
(
min_ipv4
);
}
else
if
(
bits
<
max_ipv4
)
{
$
(
input2
).
val
(
bits
);
}
else
{
$
(
input2
).
val
(
max_ipv4
);
}
}
else
if
(
was_ipv4
===
true
&&
is_ipv4
===
false
)
{
unrestrict_bits
();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
if
(
bits
<
min_ipv4
)
{
$
(
input2
).
val
(
min_ipv6
);
}
else
if
(
bits
<
max_ipv4
)
{
$
(
input2
).
val
(
bits
);
}
else
{
$
(
input2
).
val
(
max_ipv6
);
}
}
else
if
(
was_ipv4
===
undefined
&&
is_ipv4
===
true
)
{
// initial value is an ipv4 address
restrict_bits_to_ipv4
();
/* min_ipv4 -> min_ipv4 */
/* ... -> ... */
/* max_ipv4 -> max_ipv4 */
/* ... -> ... */
/* max_ipv6 -> max_ipv4 */
if
(
bits
<
min_ipv4
)
{
$
(
input2
).
val
(
min_ipv4
);
}
else
if
(
bits
<
max_ipv4
)
{
$
(
input2
).
val
(
bits
);
}
else
{
$
(
input2
).
val
(
max_ipv4
);
}
}
};
$
(
input1
).
unbind
(
"
change
"
).
bind
(
"
change
"
,
onchange_handler
).
trigger
(
"
change
"
);
};
$
.
fn
.
extend
({
"
ipv4v6ify
"
:
function
()
{
return
this
.
each
(
function
()
{
var
inputs
,
i
,
input1
,
input2
;
inputs
=
$
(
this
).
find
(
"
:input.ipv4v6
"
).
toArray
();
for
(
i
=
0
;
i
<
inputs
.
length
-
1
;
i
+=
1
)
{
input1
=
inputs
[
i
];
input2
=
inputs
[
i
+
1
];
if
(
input1
.
type
===
"
text
"
&&
input2
.
type
===
"
select-one
"
)
{
_ipv4v6ify
(
input1
,
input2
);
}
}
});
}
});
$
(
function
()
{
$
(
document
).
ipv4v6ify
();
});
})(
jQuery
);
src/www/javascript/row_helper.js
deleted
100644 → 0
View file @
181dd67b
// Global Variables
var
rowname
=
new
Array
(
4999
);
var
rowtype
=
new
Array
(
4999
);
var
newrow
=
new
Array
(
4999
);
var
rowsize
=
new
Array
(
4999
);
for
(
i
=
0
;
i
<
4999
;
i
++
)
{
rowname
[
i
]
=
''
;
rowtype
[
i
]
=
''
;
newrow
[
i
]
=
''
;
rowsize
[
i
]
=
'
30
'
;
}
var
field_counter_js
=
0
;
var
loaded
=
0
;
var
is_streaming_progress_bar
=
0
;
var
temp_streaming_text
=
""
;
var
addRowTo
=
(
function
()
{
return
(
function
(
tableId
)
{
var
$
=
jQuery
;
var
d
,
tbody
,
tr
,
td
,
bgc
,
i
,
ii
,
j
;
d
=
document
;
tbody
=
d
.
getElementById
(
tableId
).
getElementsByTagName
(
"
tbody
"
).
item
(
0
);
tr
=
d
.
createElement
(
"
tr
"
);
for
(
i
=
0
;
i
<
field_counter_js
;
i
++
)
{
td
=
d
.
createElement
(
"
td
"
);
if
(
typeof
(
rowtype
[
i
])
==
'
function
'
)
{
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' />
"
+
rowtype
[
i
](
rowname
[
i
],
rowsize
[
i
],
totalrows
)
+
"
"
;
}
else
if
(
rowtype
[
i
]
==
'
textbox
'
)
{
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><input size='
"
+
rowsize
[
i
]
+
"
' class='formfld unknown' type='text' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
' />
"
;
}
else
if
(
rowtype
[
i
]
==
'
textbox,ipv4v6
'
)
{
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><input size='
"
+
rowsize
[
i
]
+
"
' class='formfld unknown ipv4v6' type='text' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
' />
"
;
}
else
if
(
rowtype
[
i
]
==
'
password
'
)
{
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><input type='password' size='
"
+
rowsize
[
i
]
+
"
' class='formfld pwd' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
' />
"
;
}
else
if
(
rowtype
[
i
]
==
'
select
'
)
{
var
cidr
;
var
str
;
for
(
cidr
=
128
;
cidr
>=
1
;
cidr
--
)
{
str
=
str
+
"
<option value=
\"
"
+
cidr
+
"
\"
>
"
+
cidr
+
"
</option>
"
;
}
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><select size='1' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
'>
"
+
str
+
"
</select>
"
;
}
else
if
(
rowtype
[
i
]
==
'
select,ipv4v6
'
)
{
var
cidr
;
var
str
;
for
(
cidr
=
128
;
cidr
>=
1
;
cidr
--
)
{
str
=
str
+
"
<option value=
\"
"
+
cidr
+
"
\"
>
"
+
cidr
+
"
</option>
"
;
}
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><select class='ipv4v6' size='1' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
'>
"
+
str
+
"
</select>
"
;
}
else
if
(
rowtype
[
i
]
==
'
select_source
'
)
{
var
cidr
;
var
str
;
for
(
cidr
=
128
;
cidr
>=
1
;
cidr
--
)
{
str
=
str
+
"
<option value=
\"
"
+
cidr
+
"
\"
>
"
+
cidr
+
"
</option>
"
;
}
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><select size='1' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' id='
"
+
rowname
[
i
]
+
totalrows
+
"
'>
"
+
str
+
"
</select>
"
;
}
else
{
td
.
innerHTML
=
"
<input type='hidden' value='
"
+
totalrows
+
"
' name='
"
+
rowname
[
i
]
+
"
_row-
"
+
totalrows
+
"
' /><input type='checkbox' name='
"
+
rowname
[
i
]
+
totalrows
+
"
' />
"
;
}
tr
.
appendChild
(
td
);
}
td
=
d
.
createElement
(
"
td
"
);
td
.
rowSpan
=
"
1
"
;
td
.
innerHTML
=
'
<a onclick="removeRow(this); return false;" href="#" class="btn btn-default btn-xs"><span class="fa fa-trash"></span></a>
'
;
tr
.
appendChild
(
td
);
tbody
.
appendChild
(
tr
);
totalrows
++
;
if
(
$
(
tr
).
ipv4v6ify
)
$
(
tr
).
ipv4v6ify
();
});
})();
function
removeRow
(
el
)
{
var
cel
;
while
(
el
&&
el
.
nodeName
.
toLowerCase
()
!=
"
tr
"
)
el
=
el
.
parentNode
;
if
(
el
&&
el
.
parentNode
)
{
cel
=
el
.
getElementsByTagName
(
"
td
"
).
item
(
0
);
el
.
parentNode
.
removeChild
(
el
);
}
}
function
find_unique_field_name
(
field_name
)
{
// loop through field_name and strip off -NUMBER
var
last_found_dash
=
0
;
for
(
var
i
=
0
;
i
<
field_name
.
length
;
i
++
)
{
// is this a dash, if so, update
// last_found_dash
if
(
field_name
.
substr
(
i
,
1
)
==
"
-
"
)
last_found_dash
=
i
;
}
if
(
last_found_dash
<
1
)
return
field_name
;
return
(
field_name
.
substr
(
0
,
last_found_dash
));
}
src/www/vpn_pppoe_edit.php
View file @
fe848ddd
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment