From 7f9467358fe7d1c3d50d2c698a5c8f65238f04bd Mon Sep 17 00:00:00 2001 From: George Michael Brower Date: Sun, 23 Jan 2011 14:47:42 -0700 Subject: [PATCH] Added add handlers --- demo.html | 3 +++ gui.js | 37 +++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/demo.html b/demo.html index 0e1d656..aab97bd 100644 --- a/demo.html +++ b/demo.html @@ -12,6 +12,7 @@ var controllableObject = "functionProperty": function() { alert("hi"); }, + "objectProp": {} }; // Creates a number box @@ -29,6 +30,8 @@ GUI.add(controllableObject, "booleanProperty"); // Creates a button GUI.add(controllableObject, "functionProperty"); +GUI.add(controllableObject, "objectProp"); + diff --git a/gui.js b/gui.js index 15c5a07..b881cd3 100644 --- a/gui.js +++ b/gui.js @@ -1,16 +1,6 @@ var GUI = new function() { - - var addHandlers = { - - "number": function() { - // - } - - } - - this.add = function() { var object = arguments[0]; @@ -18,13 +8,32 @@ var GUI = new function() { var value = object[property]; var type = typeof value; - - if (addHandlers[type]) { - + var handler = addHandlers[type]; + if (handler) { } else { - // don't know how to handle this data type + console.error("I don't know how to handle data type: " + type); } } + var addHandlers = { + + "number": function() { + // + }, + + "string": function() { + // + }, + + "boolean": function() { + // + }, + + "function": function() { + // + }, + + }; + }; \ No newline at end of file