<strong>gui-dat</strong> is a lightweight controller library for JavaScript. It allows you to easily manipulate variables and fire functions on the fly.
<preid="demo-pre"class="prettyprint"><spanclass="tag"><script</span><spanclass="pln"></span><spanclass="atn">type</span><spanclass="pun">=</span><spanclass="atv">"text/javascript"</span><spanclass="pln"></span><spanclass="atn">src</span><spanclass="pun">=</span><spanclass="atv">"gui.min.js"</span><spanclass="tag">></script></span><spanclass="pln"><br></span><spanclass="tag"><script</span><spanclass="pln"></span><spanclass="atn">type</span><spanclass="pun">=</span><spanclass="atv">"text/javascript"</span><spanclass="tag">></span><spanclass="pln"><br><br>window</span><spanclass="pun">.</span><spanclass="pln">onload </span><spanclass="pun">=</span><spanclass="pln"></span><spanclass="kwd">function</span><spanclass="pun">()</span><spanclass="pln"></span><spanclass="pun">{</span><spanclass="pln"><br><br> </span><spanclass="kwd">var</span><spanclass="pln"> fizzyText </span><spanclass="pun">=</span><spanclass="pln"></span><spanclass="kwd">new</span><spanclass="pln"></span><spanclass="typ"><ahref="demo/demo.js">FizzyText</a></span><spanclass="pun">(</span><spanclass="str">"gui-dat"</span><spanclass="pun">);</span><spanclass="pln"><br><br> GUI</span><spanclass="pun">.</span><spanclass="pln">start</span><spanclass="pun">();</span><spanclass="pln"><br> <br> </span><spanclass="com">// Adds a text field</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="str">"message"</span><spanclass="pun">);</span><spanclass="pln"><br> <br> </span><spanclass="com">// Adds sliders with min and max</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="str">"maxSize"</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">0.5</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">7</span><spanclass="pun">);</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="str">"growthSpeed"</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">0.01</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">1</span><spanclass="pun">);</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="str">"speed"</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">0.1</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">2</span><spanclass="pun">);</span><spanclass="pln"><br> <br> </span><spanclass="com">// Adds sliders with min, max and increment.</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="str">"noiseStrength"</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">10</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">100</span><spanclass="pun">,</span><spanclass="pln"></span><spanclass="lit">5</span><spanclass="pun">);</span><spanclass="pln"><br> <br> </span><spanclass="com">// Adds a boolean checkbox</span><spanclass="pln"><br> GUI</span><spanclass="pun">.</span><spanclass="pln">add</span><spanclass="pun">(</span><spanclass="pln">fizzyText</span><spanclass="pun">,</span><spanclass="pln"></span><span
<li><strong>gui-dat</strong> will infer the type of the property you're trying to add<br/>(based on its initial value) and create the corresponding control.</li>
<li>The properties must be public, i.e. defined by <code><strong>this</strong>.prop = value</code>.</li>
By <ahref="http://georgemichaelbrower.com/">George Michael Brower</a>, <ahref="http://jonobr1.com/">Jono Brandel</a>, and <ahref="http://github.com/jonobr1/GUI-DAT">you</a>.