mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-14 16:38:39 +00:00
Fix trim bug
This commit is contained in:
parent
68b046a5fc
commit
560867ebfe
|
|
@ -66,10 +66,13 @@
|
||||||
this.recognition.onstart = function() {}
|
this.recognition.onstart = function() {}
|
||||||
|
|
||||||
this.recognition.onresult = function(event) {
|
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)) {
|
console.log('.' + result + '.');
|
||||||
self.commands[event.results[event.resultIndex][0].transcript]();
|
|
||||||
|
if(self.commands.hasOwnProperty(result)) {
|
||||||
|
console.log('found');
|
||||||
|
self.commands[result]();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.trim = function(str, char)
|
jsOMS.trim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
|
return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -43,6 +45,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.rtrim = function(str, char)
|
jsOMS.rtrim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return str.replace(new RegExp("[" + char + "]*$"), '');
|
return str.replace(new RegExp("[" + char + "]*$"), '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -60,6 +64,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.ltrim = function(str, char)
|
jsOMS.ltrim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return str.replace(new RegExp("^[" + char + "]*"), '');
|
return str.replace(new RegExp("^[" + char + "]*"), '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.trim = function(str, char)
|
jsOMS.trim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
|
return jsOMS.ltrim(jsOMS.rtrim(str, char), char);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -43,6 +45,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.rtrim = function(str, char)
|
jsOMS.rtrim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return str.replace(new RegExp("[" + char + "]*$"), '');
|
return str.replace(new RegExp("[" + char + "]*$"), '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -60,6 +64,8 @@
|
||||||
*/
|
*/
|
||||||
jsOMS.ltrim = function(str, char)
|
jsOMS.ltrim = function(str, char)
|
||||||
{
|
{
|
||||||
|
char = typeof char === 'undefined' ? ' ' : char;
|
||||||
|
|
||||||
return str.replace(new RegExp("^[" + char + "]*"), '');
|
return str.replace(new RegExp("^[" + char + "]*"), '');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user