cettings

Helper for configuring voxel settings

cettings

HTML setting inputs like for a game.

** Work in progress **

View this example

var settings = require('cettings')({
  controls: {
    forward: {
      value: '<up>',
      type: 'bindkey',
      onfunction(keyval) {
        return 'altered ' + val
      },
    },
  },
})
 
container.appendChild(settings.html())
 
settings.on('set', function(keyval) {
  console.log(key + ' was set to ' + val)
})

config is an object with the first level keys being the headings and second level is for fields. Each field accepts:

  • value The value entered for the field
  • type Either 'bindkey' to enable it to prompt for a key binding or 'text' for plain text.
  • label For a custom label.
  • on A callback function to alter the value.

Builds and returns the HTML for the settings:

<div class="settings">
  <ul>
    <li>
      <h3>controls</h3>
      <ul>
        <li>
          <label for="controls.forward">forward</label>
          <input id="controls.forward" />
        </li>
      </ul>
    </li>
  </ul>
</div>

Called whenever a value has been set.

With npm do:

npm install cettings

Use browserify to require('cettings').

  • 0.1.0 - initial release

Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.