]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids.cgi: Dynamically generate SHOW/HIDE for expanding or collapsing a ruleset category
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 30 Jan 2019 09:53:17 +0000 (10:53 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 30 Jan 2019 09:53:17 +0000 (10:53 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi
langs/en/cgi-bin/en.pl

index 604d216c8938fea9aee7055cb95f399b4bf89866..ba2136b2f9bf5279cab6f49d91d79ad4a02719ff 100644 (file)
@@ -644,8 +644,13 @@ $selected{'AUTOUPDATE_INTERVAL'}{$rulessettings{'AUTOUPDATE_INTERVAL'}} = "selec
 &Header::openpage($Lang::tr{'intrusion detection system'}, 1, '');
 
 ### Java Script ###
 &Header::openpage($Lang::tr{'intrusion detection system'}, 1, '');
 
 ### Java Script ###
+print"<script>\n";
+
+# Java script variable declaration for show and hide.
+print"var show = \"$Lang::tr{'ids show'}\"\;\n";
+print"var hide = \"$Lang::tr{'ids hide'}\"\;\n";
+
 print <<END
 print <<END
-<script>
        // JQuery function to show/hide the text input field for
        // Oinkcode/Subscription code.
        \$(function() {
        // JQuery function to show/hide the text input field for
        // Oinkcode/Subscription code.
        \$(function() {
@@ -666,6 +671,15 @@ print <<END
        // of a given category.
        function showhide(tblname) {
                \$("#" + tblname).toggle();
        // of a given category.
        function showhide(tblname) {
                \$("#" + tblname).toggle();
+
+               // Get current content of the span element.
+               var content = document.getElementById("span_" + tblname);
+
+               if (content.innerHTML === show) {
+                       content.innerHTML = hide;
+               } else {
+                       content.innerHTML = show;
+               }
        }
 </script>
 END
        }
 </script>
 END
@@ -1043,7 +1057,7 @@ if (%idsrules) {
                        print"</td>\n";
                        print"<td class='base' width='90%'><b>$rulefile</b></td>\n";
                        print"<td class='base' width='5%' align='right'>\n";
                        print"</td>\n";
                        print"<td class='base' width='90%'><b>$rulefile</b></td>\n";
                        print"<td class='base' width='5%' align='right'>\n";
-                       print"<a href=\"javascript:showhide('$categoryname')\">SHOW</a>\n";
+                       print"<a href=\"javascript:showhide('$categoryname')\"><span id='span_$categoryname'>$Lang::tr{'ids show'}</span></a>\n";
                        print"</td>\n";
                        print"</tr>\n";
 
                        print"</td>\n";
                        print"</tr>\n";
 
index 5a7d3af03df721032f4c75c72e0034e1b0a07073..445473813a20150795da6d08eeb80ab37a2691b5 100644 (file)
 'ids automatic rules update' => 'Automatic rules update',
 'ids traffic analyze' => 'Traffic analyzing',
 'ids active on' => 'Active on',
 'ids automatic rules update' => 'Automatic rules update',
 'ids traffic analyze' => 'Traffic analyzing',
 'ids active on' => 'Active on',
+'ids hide' => 'Hide',
 'ids log viewer' => 'IDS log viewer',
 'ids logs' => 'IDS Logs',
 'ids monitored interfaces' => 'Monitored interfaces',
 'ids log viewer' => 'IDS log viewer',
 'ids logs' => 'IDS Logs',
 'ids monitored interfaces' => 'Monitored interfaces',
 'ids rules license2' => 'Acknowledge the license, activate your account by visiting the url you got via mail. Then go to',
 'ids rules license3' => 'press the "Generate code"-button and copy the 40 character Oinkcode into the field below.',
 'ids rules update' => 'IDS rules',
 'ids rules license2' => 'Acknowledge the license, activate your account by visiting the url you got via mail. Then go to',
 'ids rules license3' => 'press the "Generate code"-button and copy the 40 character Oinkcode into the field below.',
 'ids rules update' => 'IDS rules',
+'ids show' => 'Show',
 'iface' => 'Iface',
 'ignore filter' => 'Ignore filter',
 'ike encryption' => 'IKE Encryption:',
 'iface' => 'Iface',
 'ignore filter' => 'Ignore filter',
 'ike encryption' => 'IKE Encryption:',