From 8126a0cf4b46c193023b5c088198d0ee164c1a2b Mon Sep 17 00:00:00 2001 From: George Michael Brower Date: Sun, 23 Jan 2011 14:39:07 -0700 Subject: [PATCH] Initial files --- demo.html | 28 +++++++++++++++++++--------- gui.js | 29 ++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/demo.html b/demo.html index 2ec3ce2..0e1d656 100644 --- a/demo.html +++ b/demo.html @@ -8,17 +8,27 @@ var controllableObject = "numberProperty": 20, "anotherNumberProperty": 0, "textProperty": "a string", - "booleanProperty": false + "booleanProperty": false, + "functionProperty": function() { + alert("hi"); + }, }; - - - /* -GUI.number(controllableObject, "numberProperty"); -GUI.number(controllableObject, "anotherNumberProperty", -100, 100); -GUI.text(controllableObject, "textProperty"); -GUI.boolean(controllableObject, "booleanProperty"); -*/ +// Creates a number box +GUI.add(controllableObject, "numberProperty"); + +// Creates a slider (min, max) +GUI.add(controllableObject, "anotherNumberProperty", -100, 100); + +// Creates a text field +GUI.add(controllableObject, "textProperty"); + +// Creates a checkbox +GUI.add(controllableObject, "booleanProperty"); + +// Creates a button +GUI.add(controllableObject, "functionProperty"); + diff --git a/gui.js b/gui.js index 492810b..15c5a07 100644 --- a/gui.js +++ b/gui.js @@ -1,7 +1,30 @@ var GUI = new function() { - this.add = function(a) { - console.log(typeof a); + + + var addHandlers = { + + "number": function() { + // + } + } -} \ No newline at end of file + + this.add = function() { + + var object = arguments[0]; + var property = arguments[1]; + + var value = object[property]; + var type = typeof value; + + if (addHandlers[type]) { + + } else { + // don't know how to handle this data type + } + + } + +}; \ No newline at end of file