Skip to content

Commit

Permalink
ncp-web: use checkboxes for yes/no fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Aug 10, 2017
1 parent 6f74658 commit b1c3073
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ncp-web/ncp-launcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@

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>";
Expand Down
2 changes: 1 addition & 1 deletion ncp-web/ncp.css
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ select {
width: 100%;
}

#config-box-wrapper input {
#config-box-wrapper input[type='text'] {
width: 100%;
}

Expand Down
2 changes: 2 additions & 0 deletions ncp-web/ncp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
} );

Expand Down

0 comments on commit b1c3073

Please sign in to comment.