ids.cgi: Display oinkcode section after page load whenneccessary.

Message ID 20190412162101.4698-1-stefan.schantl@ipfire.org
State Accepted
Commit 0d34a479c878cd775e541601b2a72238eb3f7546
Headers
Series ids.cgi: Display oinkcode section after page load whenneccessary. |

Commit Message

Stefan Schantl April 13, 2019, 2:21 a.m. UTC
  Fixes #12048.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 html/cgi-bin/ids.cgi | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
  

Patch

diff --git a/html/cgi-bin/ids.cgi b/html/cgi-bin/ids.cgi
index 98c6f57b4..00db6a0c3 100644
--- a/html/cgi-bin/ids.cgi
+++ b/html/cgi-bin/ids.cgi
@@ -689,20 +689,26 @@  print"var show = \"$Lang::tr{'ids show'}\"\;\n";
 print"var hide = \"$Lang::tr{'ids hide'}\"\;\n";
 
 print <<END
-	// JQuery function to show/hide the text input field for
+	// Java Script function to show/hide the text input field for
 	// Oinkcode/Subscription code.
-	\$(function() {
-		\$('#RULES').change(function(){
-			if(\$('#RULES').val() == 'registered') {
-				\$('#code').show();
-			} else if(\$('#RULES').val() == 'subscripted') {
-				\$('#code').show();
-			} else if(\$('#RULES').val() == 'emerging_pro') {
-				\$('#code').show();
-			} else {
-				\$('#code').hide();
-			}
-		});
+	var update_code = function() {
+		if(\$('#RULES').val() == 'registered') {
+			\$('#code').show();
+		} else if(\$('#RULES').val() == 'subscripted') {
+			\$('#code').show();
+		} else if(\$('#RULES').val() == 'emerging_pro') {
+			\$('#code').show();
+		} else {
+			\$('#code').hide();
+		}
+	};
+
+	// JQuery function to call corresponding function when
+	// the ruleset is changed or the page is loaded for showing/hiding
+	// the code area.
+	\$(document).ready(function() {
+		\$('#RULES').change(update_code);
+		update_code();
 	});
 
 	// Tiny java script function to show/hide the rules