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