Skip to content

Commit dc11ded

Browse files
committed
fixed some console error
1 parent 388b492 commit dc11ded

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

generators/webduino.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -763,16 +763,18 @@ Blockly.JavaScript['sound_recognition'] = function (block) {
763763
var statements_recognition_ = Blockly.JavaScript.statementToCode(block, 'recognition_');
764764
var recognition = Blockly.JavaScript.variableDB_.getDistinctName(
765765
'recognition', Blockly.Variables.NAME_TYPE);
766-
console.log(dropdown_interimresults_);
767-
var inter1, inter2, mobile;
766+
var inter1, inter2, consoleFinal1, consoleFinal2;
768767
if (dropdown_interimresults_ == 'on') {
769768
inter1 = 'false';
770769
inter2 = 'true';
770+
consoleFinal1 = '';
771+
consoleFinal2 = 'console.log("final");\n';
771772
} else if (dropdown_interimresults_ == 'off') {
772773
inter1 = 'true';
773774
inter2 = 'false';
775+
consoleFinal1 = 'console.log("final");\n';
776+
consoleFinal2 = '';
774777
}
775-
console.log(dropdown_interimresults_);
776778
var code = '(function(){\n' +
777779
' if (!("webkitSpeechRecognition" in window)) {\n' +
778780
' alert("本瀏覽器不支援語音辨識,請更換瀏覽器!(Chrome 25 版以上才支援語音辨識)");\n' +
@@ -793,8 +795,9 @@ Blockly.JavaScript['sound_recognition'] = function (block) {
793795
' if(event.results[resultLength].isFinal===' + inter1 + '){\n' +
794796
' console.log(resultTranscript);\n' +
795797
' ' + statements_recognition_ +
798+
' ' + consoleFinal1 +
796799
' }else if(event.results[resultLength].isFinal===' + inter2 + '){\n' +
797-
' console.log("final");\n' +
800+
' ' + consoleFinal2 +
798801
' }\n' +
799802
' };\n' +
800803
' ' + recognition + '.start();\n' +
@@ -811,15 +814,15 @@ Blockly.JavaScript['sound_recognition_check'] = function (block) {
811814
var b = value_text_.split(', ');
812815
var code;
813816
if (b.length == 1) {
814-
code = ' if(resultTranscript.indexOf("' + b[0] + '")!==-1){\n' +
817+
code = 'if(resultTranscript.indexOf("' + b[0] + '")!==-1){\n' +
815818
' ' + statements_do_ +
816819
' }\n';
817820
} else {
818-
code = ' if(resultTranscript.indexOf("' + b[0] + '")!==-1){\n' +
821+
code = 'if(resultTranscript.indexOf("' + b[0] + '")!==-1){\n' +
819822
' ' + statements_do_ +
820823
' }\n';
821824
for (var i = 1; i < b.length; i++) {
822-
code += ' if(resultTranscript.indexOf("' + b[i] + '")!==-1){\n' +
825+
code += 'if(resultTranscript.indexOf("' + b[i] + '")!==-1){\n' +
823826
' ' + statements_do_ +
824827
' }\n';
825828
}

0 commit comments

Comments
 (0)