Code Monkey home page Code Monkey logo

cettings's Introduction

cettings

HTML setting inputs like for a game.

** Work in progress **

example

View this 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:

  • 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.

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 cettings

Use browserify to require('cettings').

release history

  • 0.1.0 - initial release

license

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

cettings's People

Contributors

shama avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.