diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-08-10 19:45:40 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-08-11 00:17:56 +0300 |
commit | b1c307335f85173d30795c4cd57dffcda24c18ce (patch) | |
tree | 6fc8e704f5bdbeeb9fd0e36ecfdb9f9425b7051e | |
parent | 6f7465844ca3fae38fa84234d8de97f39fe9576c (diff) |
ncp-web: use checkboxes for yes/no fieldsv0.19.5
-rw-r--r-- | ncp-web/ncp-launcher.php | 11 | ||||
-rw-r--r-- | ncp-web/ncp.css | 2 | ||||
-rw-r--r-- | ncp-web/ncp.js | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/ncp-web/ncp-launcher.php b/ncp-web/ncp-launcher.php index 03672c78..ce3e88a5 100644 --- a/ncp-web/ncp-launcher.php +++ b/ncp-web/ncp-launcher.php @@ -35,7 +35,16 @@ if ( $_POST['action'] == "cfgreq" ) while ( $line = fgets($fh) ) { - if ( preg_match('/^(\w+)_=(.*)$/', $line, $matches) ) + if ( preg_match('/^(\w+)_=(yes|no)$/', $line, $matches) ) + { + if ( $matches[2] == "yes" ) + $checked = "checked"; + $output = $output . "<tr>"; + $output = $output . "<td><label for=\"$matches[1]\">$matches[1]</label></td>"; + $output = $output . "<td><input type=\"checkbox\" id=\"$matches[1]\" name=\"$matches[1]\" value=\"$matches[2]\" $checked></td>"; + $output = $output . "</tr>"; + } + else if ( preg_match('/^(\w+)_=(.*)$/', $line, $matches) ) { $output = $output . "<tr>"; $output = $output . "<td><label for=\"$matches[1]\">$matches[1]</label></td>"; diff --git a/ncp-web/ncp.css b/ncp-web/ncp.css index 1abbe2f8..40829a1f 100644 --- a/ncp-web/ncp.css +++ b/ncp-web/ncp.css @@ -1013,7 +1013,7 @@ select { width: 100%; } -#config-box-wrapper input { +#config-box-wrapper input[type='text'] { width: 100%; } diff --git a/ncp-web/ncp.js b/ncp-web/ncp.js index a643212f..8fdd5e0a 100644 --- a/ncp-web/ncp.js +++ b/ncp-web/ncp.js @@ -56,6 +56,8 @@ $(function() // create configuration object var cfg = {}; $( 'input' , '#config-box' ).each( function(item){ + if( item.getAttribute('type') == 'checkbox' ) + item.value = item.checked ? 'yes' : 'no'; cfg[item.name] = item.value; } ); |