diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index 2799dce..305cb2d 100644 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -66,10 +66,13 @@ this.recognition.onstart = function() {} this.recognition.onresult = function(event) { - console.log(event.results[event.resultIndex][0].transcript); + let result = jsOMS.trim(event.results[event.resultIndex][0].transcript); - if(self.commands.hasOwnProperty(event.results[event.resultIndex][0].transcript)) { - self.commands[event.results[event.resultIndex][0].transcript](); + console.log('.' + result + '.'); + + if(self.commands.hasOwnProperty(result)) { + console.log('found'); + self.commands[result](); } } diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index b1f39ac..4a619e2 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -26,6 +26,8 @@ */ jsOMS.trim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return jsOMS.ltrim(jsOMS.rtrim(str, char), char); }; @@ -43,6 +45,8 @@ */ jsOMS.rtrim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return str.replace(new RegExp("[" + char + "]*$"), ''); }; @@ -60,6 +64,8 @@ */ jsOMS.ltrim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return str.replace(new RegExp("^[" + char + "]*"), ''); }; diff --git a/Utils/oLib.js b/Utils/oLib.js index 00f6f9f..9368d82 100644 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -26,6 +26,8 @@ */ jsOMS.trim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return jsOMS.ltrim(jsOMS.rtrim(str, char), char); }; @@ -43,6 +45,8 @@ */ jsOMS.rtrim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return str.replace(new RegExp("[" + char + "]*$"), ''); }; @@ -60,6 +64,8 @@ */ jsOMS.ltrim = function(str, char) { + char = typeof char === 'undefined' ? ' ' : char; + return str.replace(new RegExp("^[" + char + "]*"), ''); };