Don't check for methods on window.native

It turns out that `window.native.someMethod` always evaluates as
`undefined` -- even if calling that method would succeed. This change
removes checks for such methods so that the WeDo2 blocks can work.
Note that the hat blocks are still unimplemented, and some assumptions
are made about the form that arguments and `util` will take.
This commit is contained in:
Christopher Willis-Ford 2016-05-03 09:29:51 -07:00
parent e1109e8ca6
commit e8089cd2a5

View file

@ -110,7 +110,7 @@ WeDo2Blocks.prototype._motorOnFor = function(direction, durationSeconds, util) {
clearTimeout(this._motorTimeout);
this._motorTimeout = null;
}
if (window.native && window.native.motorRun) {
if (window.native) {
window.native.motorRun(direction, this._motorSpeed);
}
@ -119,7 +119,7 @@ WeDo2Blocks.prototype._motorOnFor = function(direction, durationSeconds, util) {
if (instance._motorTimeout == myTimeout) {
instance._motorTimeout = null;
}
if (window.native && window.native.motorStop) {
if (window.native) {
window.native.motorStop();
}
util.done();
@ -164,7 +164,7 @@ WeDo2Blocks.prototype._getColor = function(colorName) {
};
WeDo2Blocks.prototype.setColor = function(argValues) {
if (window.native && window.native.setLedColor) {
if (window.native) {
var rgbColor = this._getColor(argValues[0]);
window.native.setLedColor(
255 * rgbColor[0], 255 * rgbColor[1], 255 * rgbColor[2]);