Permalink
Browse files

Merge pull request #7 from hsanchez/master

static structure of botprint
  • Loading branch information...
2 parents 60ffbe5 + 07f906e commit 468a2290ad24712ccccff836608db79a17d6af7f @linzhp committed Jun 5, 2012
View
@@ -19,7 +19,7 @@
<h2>Cheat Sheet</h2>
<ul>
<li>
- 1. Add your desired Shape
+ 1. Add your desired Chassis
</li>
<li>
2. Pick a nice Color
@@ -35,9 +35,9 @@
<!--<br/><br/><br/>-->
<div id="palette">
<div class="palette-set clearfix">
- <h2>Add a Shape</h2>
- <a href="#" class="default" data-guivar="shape" data-guival="Free">Free</a>
- <a href="#" data-guivar="shape" data-guival="Square">Square</a>
+ <h2>Add a Chassis</h2>
+ <!--<a href="#" class="default" data-guivar="shape" data-guival="Free">Free</a>-->
+ <a href="#" class="default" data-guivar="shape" data-guival="Square">Square</a>
<a href="#" data-guivar="shape" data-guival="Polygon">Polygon</a>
<a href="#" data-guivar="shape" data-guival="Ellipse">Ellipse</a>
</div>
@@ -48,7 +48,7 @@
<a href="#" data-guivar="color" data-guival="#FFFFFF">White</a>
</div>
<div class="palette-set clearfix">
- <h2>Suggest Wheels Location</h2>
+ <h2>Mark Wheels Location</h2>
<a href="#" data-guivar="wheelsLocation" data-guival="true">Yes</a>
<a href="#" class="default" data-guivar="wheelsLocation" data-guival="false">No</a>
</div>
@@ -99,6 +99,7 @@
<script src="js/vendor/ThreeDebug.js"></script>
<script src="js/vendor/dat.gui.js"></script>
<script src="js/vendor/Modernizr.js"></script>
+<script src="js/vendor/Base.js"></script>
<!-- scripts concatenated and minified via build script -->
<script src="js/plugins.js"></script>
View
@@ -0,0 +1,9 @@
+var Arrays = Base.extend({
+ constructor: null,
+ // Array Remove - By John Resig (MIT Licensed)
+ remove: function(array, from, to) {
+ var rest = array.slice((to || from) + 1 || array.length);
+ array.length = from < 0 ? array.length + from : from;
+ return array.push.apply(array, rest);
+ }
+});
View
@@ -0,0 +1,20 @@
+var BatteryPack = Base.extend({
+ constructor: function(name, deck, shape){
+ this._name = name;
+ this._deck = deck;
+ this._shape = shape;
+ },
+
+ name: function(){
+ return this._name;
+ },
+
+ deck: function() {
+ return this._deck;
+ },
+
+ shape: function() {
+ return this._shape;
+ }
+
+});
View
@@ -0,0 +1 @@
+var Bracket = MechanicalParts.extend();
@@ -0,0 +1 @@
+var Breadboard = ElectronicParts.extend();
View
@@ -0,0 +1,28 @@
+var Deck = MechanicalParts.extend({
+ constructor: function(name, shape){
+ this.base(name, null, shape);
+ this._container = new Array();
+
+ },
+
+ add: function(parts){
+ for(var part in parts){
+ this._container.push(part);
+ }
+ },
+
+ _findIndex: function(part){
+ var idx = 0;
+ for(var each in this._container){
+ if(each == part){
+ return idx;
+ }
+
+ idx++;
+ }
+ },
+
+ remove: function(part) {
+ Arrays.remove(this._findIndex(part));
+ }
+});
@@ -0,0 +1,29 @@
+var ElectronicParts = Base.extend({
+ constructor: function(name, shape, deck){
+ this._name = name;
+ this._shape = shape;
+ this._deck = deck;
+ },
+
+ name: function(){
+ return this._name;
+ },
+
+ shape: function() {
+ return this._shape;
+ },
+
+ deck: function(){
+ return this._deck;
+ },
+
+ mount: function(deck){
+ if(this._deck != deck){
+ this._deck = deck;
+ }
+ },
+
+ unmount: function(){
+ this.mount(null);
+ }
+});
@@ -0,0 +1,30 @@
+var MechanicalParts = Base.extend({
+ constructor: function(name, deck, shape){
+ this._name = name;
+ this._deck = deck;
+ this._shape = shape;
+ },
+
+ name: function(){
+ return this._name;
+ },
+
+ deck: function() {
+ return this._deck;
+ },
+
+ shape: function() {
+ return this._shape;
+ },
+
+ mount: function(deck){
+ if(this._deck != deck){
+ this._deck = deck;
+ }
+ },
+
+ unmount: function(){
+ this.mount(null);
+ }
+
+});
@@ -0,0 +1 @@
+var Microcontroller = ElectronicParts.extend();
@@ -0,0 +1,30 @@
+var RobotChassis = Base.extend({
+ constructor: function(shape, decks){
+ this._shape = shape;
+ this._decks = decks;
+ },
+
+ shape: function() {
+ return this._shape;
+ },
+
+ decks: function(){
+ return this._decks;
+ },
+
+ add: function(deck, parts){
+ for(var eachDeck in this._decks){
+ if(eachDeck == deck){
+ eachDeck.add(parts);
+ }
+ }
+ },
+
+ remove: function(deck, parts){
+ for(var eachDeck in this._decks){
+ if(eachDeck == deck){
+ deck.remove(parts);
+ }
+ }
+ }
+});
View
@@ -0,0 +1,19 @@
+var Servo = Base.extend({
+ constructor: function(name, deck, shape){
+ this._name = name;
+ this._deck = deck;
+ this._shape = shape;
+ },
+
+ name: function(){
+ return this._name;
+ },
+
+ deck: function() {
+ return this._deck;
+ },
+
+ shape: function() {
+ return this._shape;
+ }
+});
View
@@ -0,0 +1 @@
+var Skid = MechanicalParts.extend();
View
@@ -0,0 +1,19 @@
+var Wheel = Base.extend({
+ constructor: function(name, deck, shape){
+ this._name = name;
+ this._deck = deck;
+ this._shape = shape;
+ },
+
+ name: function(){
+ return this._name;
+ },
+
+ deck: function() {
+ return this._deck;
+ },
+
+ shape: function() {
+ return this._shape;
+ }
+});
View
@@ -0,0 +1,140 @@
+/*
+ Base.js, version 1.1a
+ Copyright 2006-2010, Dean Edwards
+ License: http://www.opensource.org/licenses/mit-license.php
+ @see http://dean.edwards.name/weblog/2006/03/base/
+ */
+
+var Base = function() {
+ // dummy
+};
+
+Base.extend = function(_instance, _static) { // subclass
+ var extend = Base.prototype.extend;
+
+ // build the prototype
+ Base._prototyping = true;
+ var proto = new this;
+ extend.call(proto, _instance);
+ proto.base = function() {
+ // call this method from any other method to invoke that method's ancestor
+ };
+ delete Base._prototyping;
+
+ // create the wrapper for the constructor function
+ //var constructor = proto.constructor.valueOf(); //-dean
+ var constructor = proto.constructor;
+ var klass = proto.constructor = function() {
+ if (!Base._prototyping) {
+ if (this._constructing || this.constructor == klass) { // instantiation
+ this._constructing = true;
+ constructor.apply(this, arguments);
+ delete this._constructing;
+ } else if (arguments[0] != null) { // casting
+ return (arguments[0].extend || extend).call(arguments[0], proto);
+ }
+ }
+ };
+
+ // build the class interface
+ klass.ancestor = this;
+ klass.extend = this.extend;
+ klass.forEach = this.forEach;
+ klass.implement = this.implement;
+ klass.prototype = proto;
+ klass.toString = this.toString;
+ klass.valueOf = function(type) {
+ //return (type == "object") ? klass : constructor; //-dean
+ return (type == "object") ? klass : constructor.valueOf();
+ };
+ extend.call(klass, _static);
+ // class initialisation
+ if (typeof klass.init == "function") klass.init();
+ return klass;
+};
+
+Base.prototype = {
+ extend: function(source, value) {
+ if (arguments.length > 1) { // extending with a name/value pair
+ var ancestor = this[source];
+ if (ancestor && (typeof value == "function") && // overriding a method?
+ // the valueOf() comparison is to avoid circular references
+ (!ancestor.valueOf || ancestor.valueOf() != value.valueOf()) &&
+ /\bbase\b/.test(value)) {
+ // get the underlying method
+ var method = value.valueOf();
+ // override
+ value = function() {
+ var previous = this.base || Base.prototype.base;
+ this.base = ancestor;
+ var returnValue = method.apply(this, arguments);
+ this.base = previous;
+ return returnValue;
+ };
+ // point to the underlying method
+ value.valueOf = function(type) {
+ return (type == "object") ? value : method;
+ };
+ value.toString = Base.toString;
+ }
+ this[source] = value;
+ } else if (source) { // extending with an object literal
+ var extend = Base.prototype.extend;
+ // if this object has a customised extend method then use it
+ if (!Base._prototyping && typeof this != "function") {
+ extend = this.extend || extend;
+ }
+ var proto = {toSource: null};
+ // do the "toString" and other methods manually
+ var hidden = ["constructor", "toString", "valueOf"];
+ // if we are prototyping then include the constructor
+ var i = Base._prototyping ? 0 : 1;
+ while (key = hidden[i++]) {
+ if (source[key] != proto[key]) {
+ extend.call(this, key, source[key]);
+
+ }
+ }
+ // copy each of the source object's properties to this object
+ for (var key in source) {
+ if (!proto[key]) extend.call(this, key, source[key]);
+ }
+ }
+ return this;
+ }
+};
+
+// initialise
+Base = Base.extend({
+ constructor: function() {
+ this.extend(arguments[0]);
+ }
+}, {
+ ancestor: Object,
+ version: "1.1",
+
+ forEach: function(object, block, context) {
+ for (var key in object) {
+ if (this.prototype[key] === undefined) {
+ block.call(context, object[key], key, object);
+ }
+ }
+ },
+
+ implement: function() {
+ for (var i = 0; i < arguments.length; i++) {
+ if (typeof arguments[i] == "function") {
+ // if it's a function, call it
+ arguments[i](this.prototype);
+ } else {
+ // add the interface using the extend method
+ this.prototype.extend(arguments[i]);
+ }
+ }
+ return this;
+ },
+
+ toString: function() {
+ return String(this.valueOf());
+ }
+});

0 comments on commit 468a229

Please sign in to comment.