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() {
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");
</script>
</head>
<body>

37
gui.js
View File

@ -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() {
//
},
};
};