0.1.0 • Published 12 years ago
cettings v0.1.0
cettings
HTML setting inputs like for a game.
Work in progress
example
var settings = require('cettings')({
  controls: {
    forward: {
      value: '<up>',
      type: 'bindkey',
      on: function(key, val) {
        return 'altered ' + val
      },
    },
  },
})
container.appendChild(settings.html())
settings.on('set', function(key, val) {
  console.log(key + ' was set to ' + val)
})api
var settings = require('cettings')(config)
config is an object with the first level keys being the headings and second level is for fields. Each field accepts:
valueThe value entered for the fieldtypeEither'bindkey'to enable it to prompt for a key binding or'text'for plain text.labelFor a custom label.onA callback function to alter the value.
settings.html()
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>settings.on('set', key, val)
Called whenever a value has been set.
install
With npm do:
npm install cettingsUse browserify to require('cettings').
release history
- 0.1.0 - initial release
 
license
Copyright (c) 2013 Kyle Robinson Young
Licensed under the MIT license.
0.1.0
12 years ago