Skip to content

Commit

Permalink
ui: rewor the rework of the subnet selector; closes #5129
Browse files Browse the repository at this point in the history
(cherry picked from commit 60d6243)
  • Loading branch information
fichtner committed Aug 2, 2021
1 parent dc62156 commit 0680b5c
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/www/javascript/opnsense_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,28 @@ function hook_ipv4v6(classname, data_id)
var selectlist_id = $(this).attr('id');
if ($(this).data(data_id) != undefined) {
$("#"+$(this).data(data_id)).change(function () {
if ($(this).val().indexOf(":") == -1) {
$("#"+selectlist_id).val('32');
let net = $("#"+selectlist_id).val();
let type = $(this).data('ipv4v6');
let val = $(this).val();
if (val.indexOf(":") != -1) {
for (let i = 33; i <= 128; ++i) {
$("#"+selectlist_id+' option[value=' + i + ']').hide()
$("#"+selectlist_id+' option[value=' + i + ']').show()
}
if ((type === undefined && val == '') || type === '4') {
net = '64';
}
type = '6';
} else {
if ((type === undefined && val == '') || type === '6') {
net = '32';
}
type = '4';
for (let i = 33; i <= 128; ++i) {
$("#"+selectlist_id+' option[value=' + i + ']').show()
$("#"+selectlist_id+' option[value=' + i + ']').hide()
}
$("#"+selectlist_id).val('64');
}
$("#"+selectlist_id).val(net);
$(this).data('ipv4v6', type);
/* when select list uses selectpicker, refresh */
if ($("#"+selectlist_id).hasClass('selectpicker')) {
$("#"+selectlist_id).selectpicker('refresh');
Expand Down

0 comments on commit 0680b5c

Please sign in to comment.