Added add handlers

This commit is contained in:
George Michael Brower 2011-01-23 14:47:42 -07:00
parent 8126a0cf4b
commit 7f9467358f
2 changed files with 26 additions and 14 deletions

View File

@ -12,6 +12,7 @@ var controllableObject =
"functionProperty": function() { "functionProperty": function() {
alert("hi"); alert("hi");
}, },
"objectProp": {}
}; };
// Creates a number box // Creates a number box
@ -29,6 +30,8 @@ GUI.add(controllableObject, "booleanProperty");
// Creates a button // Creates a button
GUI.add(controllableObject, "functionProperty"); GUI.add(controllableObject, "functionProperty");
GUI.add(controllableObject, "objectProp");
</script> </script>
</head> </head>
<body> <body>

37
gui.js
View File

@ -1,16 +1,6 @@
var GUI = new function() { var GUI = new function() {
var addHandlers = {
"number": function() {
//
}
}
this.add = function() { this.add = function() {
var object = arguments[0]; var object = arguments[0];
@ -18,13 +8,32 @@ var GUI = new function() {
var value = object[property]; var value = object[property];
var type = typeof value; var type = typeof value;
var handler = addHandlers[type];
if (addHandlers[type]) { if (handler) {
} else { } 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() {
//
},
};
}; };