]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
ids.cgi: Show/Hide subscription code area dynamically.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 30 Jan 2019 08:27:37 +0000 (09:27 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Wed, 30 Jan 2019 08:27:37 +0000 (09:27 +0100)
Dynamically (Java Script) show/hide the area for entering the
subscription code / oinkcode based on the choosen ruleset.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
html/cgi-bin/ids.cgi

index fa5bf2399d41da146499713cda884b8d082d2c25..6fbc0b7b79d9a38ad20b7b717538508574d03ef6 100644 (file)
@@ -612,6 +612,22 @@ $selected{'AUTOUPDATE_INTERVAL'}{$rulessettings{'AUTOUPDATE_INTERVAL'}} = "selec
 ### Java Script ###
 print <<END
 <script>
+       // JQuery 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();
+                       }
+               });
+       });
+
        // Tiny java script function to show/hide the rules
        // of a given category.
        function showhide(tblname) {
@@ -780,7 +796,7 @@ print <<END
                </tr>
 
                <tr>
-                       <td><select name='RULES'>
+                       <td><select name='RULES' id='RULES'>
                                <option value='emerging' $selected{'RULES'}{'emerging'} >$Lang::tr{'emerging rules'}</option>
                                <option value='community' $selected{'RULES'}{'community'} >$Lang::tr{'community rules'}</option>
                                <option value='registered' $selected{'RULES'}{'registered'} >$Lang::tr{'registered user rules'}</option>
@@ -801,8 +817,8 @@ print <<END
                        <td colspan='2'><br><br></td>
                </tr>
 
-               <tr>
-                       <td colspan='2' nowrap='nowrap'>Oinkcode:&nbsp;<input type='text' size='40' name='OINKCODE' value='$rulessettings{'OINKCODE'}'></td>
+               <tr style='display:none' id='code'>
+                       <td colspan='2'>Oinkcode:&nbsp;<input type='text' size='40' name='OINKCODE' value='$rulessettings{'OINKCODE'}'></td>
                </tr>
 
                <tr>