Initial files

This commit is contained in:
George Michael Brower 2011-01-23 14:39:07 -07:00
parent c3021baa2f
commit 8126a0cf4b
2 changed files with 45 additions and 12 deletions

View File

@ -8,17 +8,27 @@ var controllableObject =
"numberProperty": 20, "numberProperty": 20,
"anotherNumberProperty": 0, "anotherNumberProperty": 0,
"textProperty": "a string", "textProperty": "a string",
"booleanProperty": false "booleanProperty": false,
"functionProperty": function() {
alert("hi");
},
}; };
// 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");
/*
GUI.number(controllableObject, "numberProperty");
GUI.number(controllableObject, "anotherNumberProperty", -100, 100);
GUI.text(controllableObject, "textProperty");
GUI.boolean(controllableObject, "booleanProperty");
*/
</script> </script>
</head> </head>
<body> <body>

29
gui.js
View File

@ -1,7 +1,30 @@
var GUI = new function() { var GUI = new function() {
this.add = function(a) {
console.log(typeof a);
var addHandlers = {
"number": function() {
//
}
} }
}
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
}
}
};