Commit 1c6096c1 authored by Ad Schellevis's avatar Ad Schellevis

cleanup js code in system_groupmanager.php for https://github.com/opnsense/core/issues/1005

parent 464f7d6d
......@@ -161,70 +161,11 @@ legacy_html_escape_form_data($pconfig);
legacy_html_escape_form_data($a_group);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<script type="text/javascript">
//<![CDATA[
function setall_selected(id) {
selbox = document.getElementById(id);
count = selbox.options.length;
for (index = 0; index<count; index++) {
selbox.options[index].selected = true;
}
}
function clear_selected(id) {
selbox = document.getElementById(id);
count = selbox.options.length;
for (index = 0; index<count; index++) {
selbox.options[index].selected = false;
}
}
function remove_selected(id) {
selbox = document.getElementById(id);
index = selbox.options.length - 1;
for (; index >= 0; index--) {
if (selbox.options[index].selected) {
selbox.remove(index);
}
}
}
function copy_selected(srcid, dstid) {
src_selbox = document.getElementById(srcid);
dst_selbox = document.getElementById(dstid);
count = dst_selbox.options.length;
for (index = count - 1; index >= 0; index--) {
if (dst_selbox.options[index].value == '') {
dst_selbox.remove(index);
}
}
count = src_selbox.options.length;
for (index = 0; index < count; index++) {
if (src_selbox.options[index].selected) {
option = document.createElement('option');
option.text = src_selbox.options[index].text;
option.value = src_selbox.options[index].value;
dst_selbox.add(option, null);
}
}
}
function move_selected(srcid, dstid) {
copy_selected(srcid, dstid);
remove_selected(srcid);
}
function presubmit() {
clear_selected('notmembers');
setall_selected('members');
}
$( document ).ready(function() {
// remove group
$(".act-del-group").click(function(event){
......@@ -250,8 +191,21 @@ $( document ).ready(function() {
}]
});
});
$("#add_groups").click(function(){
$("#members").append($("#notmembers option:selected"));
$("#notmembers option:selected").remove();
$("#members option:selected").prop('selected', false);
})
$("#remove_groups").click(function(){
$("#notmembers").append($("#members option:selected"));
$("#members option:selected").remove();
$("#notmembers option:selected").prop('selected', false);
})
$("#save").click(function(){
$("#members > option").prop('selected', true);
$("#notmembers > option").prop('selected', false);
});
});
//]]>
</script>
......@@ -268,7 +222,7 @@ $( document ).ready(function() {
<div class="tab-content content-box col-xs-12 table-responsive">
<?php
if ($act == "new" || $act == "edit") :?>
<form method="post" name="iform" id="iform" onsubmit="presubmit()">
<form method="post" name="iform" id="iform">
<input type="hidden" id="act" name="act" value="" />
<input type="hidden" id="groupid" name="groupid" value="<?=(isset($id) ? $id : '');?>" />
<input type="hidden" id="privid" name="privid" value="" />
......@@ -325,11 +279,11 @@ $( document ).ready(function() {
</td>
<td class="text-center">
<br />
<a href="javascript:move_selected('notmembers','members')" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Add Groups"); ?>">
<a id="add_groups" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Add Groups"); ?>">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
<br /><br />
<a href="javascript:move_selected('members','notmembers')" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Remove Groups"); ?>">
<a id="remove_groups" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Remove Groups"); ?>">
<span class="glyphicon glyphicon-arrow-left"></span>
</a>
</td>
......@@ -392,7 +346,7 @@ $( document ).ready(function() {
<tr>
<td></td>
<td>
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
<input name="save" id="save" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='/system_groupmanager.php'" />
<?php
if (isset($id)) :?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment