Commit 8591636a authored by Ad Schellevis's avatar Ad Schellevis

cleanup js in widgets/ipsec.widget.php for https://github.com/opnsense/core/issues/1005

parent 8fd415a9
...@@ -34,42 +34,9 @@ require_once("guiconfig.inc"); ...@@ -34,42 +34,9 @@ require_once("guiconfig.inc");
$ipsec_detail_array = array(); $ipsec_detail_array = array();
$ipsec_tunnels = array(); $ipsec_tunnels = array();
$ipsec_leases = array(); $ipsec_leases = array();
$activetunnels = 0;
if (isset($config['ipsec']['phase1'])) { if (isset($config['ipsec']['phase1'])) {
echo "<div>&nbsp;</div>\n";
$tab_array = array();
$tab_array[] = array(gettext("Overview"), true, "ipsec-Overview");
$tab_array[] = array(gettext("Tunnels"), false, "ipsec-tunnel");
$tab_array[] = array(gettext("Mobile"), false, "ipsec-mobile");
echo "<div id=\"tabs\">";
$tabscounter = 0;
foreach ($tab_array as $ta) {
$dashpos = strpos($ta[2],'-');
$tabname = $ta[2] . "-tab";
$tabclass = substr($ta[2],0,$dashpos);
$tabclass = $tabclass . "-class";
if ($ta[1] == true) {
$tabActive = "table-cell";
$tabNonActive = "none";
} else {
$tabActive = "none";
$tabNonActive = "table-cell";
}
echo "<div id=\"{$ta[2]}-active\" class=\"{$tabclass}-tabactive\" style=\"display:{$tabActive}; background-color:#EEEEEE; color:black;\">";
echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
echo "&nbsp;&nbsp;&nbsp;</b>";
echo "</div>";
echo "<div id=\"{$ta[2]}-deactive\" class=\"{$tabclass}-tabdeactive\" style=\"display:{$tabNonActive}; background-color:#777777; color:white; cursor: pointer;\" onclick=\"return changeTabDIV('{$ta[2]}')\">";
echo "<b>&nbsp;&nbsp;&nbsp;{$ta[0]}";
echo "&nbsp;&nbsp;&nbsp;</b>";
echo "</div>";
}
echo "</div>";
$ipsec_leases = json_decode(configd_run("ipsec list leases"), true); $ipsec_leases = json_decode(configd_run("ipsec list leases"), true);
if ($ipsec_leases == null) { if ($ipsec_leases == null) {
$ipsec_leases = array(); $ipsec_leases = array();
...@@ -81,8 +48,6 @@ if (isset($config['ipsec']['phase1'])) { ...@@ -81,8 +48,6 @@ if (isset($config['ipsec']['phase1'])) {
} }
// parse configured tunnels // parse configured tunnels
$activetunnels = 0;
foreach ($ipsec_status as $status_key => $status_value) { foreach ($ipsec_status as $status_key => $status_value) {
if (isset($status_value['children'])) { if (isset($status_value['children'])) {
foreach($status_value['children'] as $child_status_key => $child_status_value) { foreach($status_value['children'] as $child_status_key => $child_status_value) {
...@@ -90,8 +55,8 @@ if (isset($config['ipsec']['phase1'])) { ...@@ -90,8 +55,8 @@ if (isset($config['ipsec']['phase1'])) {
'local-addrs' => $status_value['local-addrs'], 'local-addrs' => $status_value['local-addrs'],
'remote-addrs' => $status_value['remote-addrs'], 'remote-addrs' => $status_value['remote-addrs'],
); );
$ipsec_tunnels[$child_status_key]['local-ts'] = implode(',', $child_status_value['local-ts']); $ipsec_tunnels[$child_status_key]['local-ts'] = implode(', ', $child_status_value['local-ts']);
$ipsec_tunnels[$child_status_key]['remote-ts'] = implode(',', $child_status_value['remote-ts']); $ipsec_tunnels[$child_status_key]['remote-ts'] = implode(', ', $child_status_value['remote-ts']);
} }
} }
foreach ($status_value['sas'] as $sas_key => $sas_value) { foreach ($status_value['sas'] as $sas_key => $sas_value) {
...@@ -106,45 +71,30 @@ if (isset($config['ipsec']['phase1'])) { ...@@ -106,45 +71,30 @@ if (isset($config['ipsec']['phase1'])) {
if (isset($config['ipsec']['phase2'])) { if (isset($config['ipsec']['phase2'])) {
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function changeTabDIV(selectedDiv){ $(document).ready(function() {
var dashpos = selectedDiv.indexOf("-"); $(".ipsec-tab").click(function(){
var tabclass = selectedDiv.substring(0,dashpos); $(".ipsec-tab").css('background-color', '#777777');
d = document; $(".ipsec-tab").css('color', 'white');
//get deactive tabs first $(this).css('background-color', '#EEEEEE');
tabclass = tabclass + "-class-tabdeactive"; $(this).css('color', 'black');
var tabs = document.getElementsByClassName(tabclass); $(".ipsec-tab-content").hide();
var incTabSelected = selectedDiv + "-deactive"; $("#"+$(this).attr('for')).show();
for (i=0; i<tabs.length; i++){ });
var tab = tabs[i].id; });
dashpos = tab.lastIndexOf("-");
var tab2 = tab.substring(0,dashpos) + "-deactive";
if (tab2 == incTabSelected){
tablink = d.getElementById(tab2);
tablink.style.display = "none";
tab2 = tab.substring(0,dashpos) + "-active";
tablink = d.getElementById(tab2);
tablink.style.display = "table-cell";
//now show main div associated with link clicked
tabmain = d.getElementById(selectedDiv);
tabmain.style.display = "block";
}
else
{
tab2 = tab.substring(0,dashpos) + "-deactive";
tablink = d.getElementById(tab2);
tablink.style.display = "table-cell";
tab2 = tab.substring(0,dashpos) + "-active";
tablink = d.getElementById(tab2);
tablink.style.display = "none";
//hide sections we don't want to see
tab2 = tab.substring(0,dashpos);
tabmain = d.getElementById(tab2);
tabmain.style.display = "none";
}
}
}
</script> </script>
<div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;"> <div id="tabs">
<div for="ipsec-Overview" class="ipsec-tab table-cell" style="background-color:#EEEEEE; color:black; cursor: pointer; display:table-cell">
<strong>&nbsp;&nbsp;<?=gettext("Overview");?>&nbsp;&nbsp;</strong>
</div>
<div for="ipsec-tunnel" class="ipsec-tab table-cell" style="background-color:#777777; color:white; cursor: pointer; display:table-cell">
<strong>&nbsp;&nbsp;<?=gettext("Tunnels");?>&nbsp;&nbsp;</strong>
</div>
<div for="ipsec-mobile" class="ipsec-tab table-cell" style="background-color:#777777; color:white; cursor: pointer; display:table-cell">
<strong>&nbsp;&nbsp;<?=gettext("Mobile");?>&nbsp;&nbsp;</strong>
</div>
</div>
<div id="ipsec-Overview" class="ipsec-tab-content" style="display:block;background-color:#EEEEEE;">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
...@@ -176,7 +126,7 @@ if (isset($config['ipsec']['phase2'])) { ...@@ -176,7 +126,7 @@ if (isset($config['ipsec']['phase2'])) {
</table> </table>
</div> </div>
<div id="ipsec-tunnel" style="display:none;background-color:#EEEEEE;"> <div id="ipsec-tunnel" class="ipsec-tab-content" style="display:none;background-color:#EEEEEE;">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
...@@ -212,7 +162,7 @@ if (isset($config['ipsec']['phase2'])) { ...@@ -212,7 +162,7 @@ if (isset($config['ipsec']['phase2'])) {
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="ipsec-mobile" style="display:none;background-color:#EEEEEE;"> <div id="ipsec-mobile" class="ipsec-tab-content" style="display:none;background-color:#EEEEEE;">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
......
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