From e8089cd2a50ac97d0a77c770a7ae6c8d35b803dc Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Tue, 3 May 2016 09:29:51 -0700 Subject: [PATCH] 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. --- src/blocks/wedo2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blocks/wedo2.js b/src/blocks/wedo2.js index 786b761b8..67ea1115d 100644 --- a/src/blocks/wedo2.js +++ b/src/blocks/wedo2.js @@ -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]);