천현우

TTP: update TTP functions, insert/delete tab

1 '기본 함수 사용', 1 '기본 함수 사용',
2 '인풋', -> input() 2 '인풋', -> input()
3 - '스플릿', -> .split()
4 -
5 '프린트', -> print( 3 '프린트', -> print(
6 '섬', -> sum( 4 '섬', -> sum(
7 '맥스', -> max( 5 '맥스', -> max(
......
...@@ -1368,15 +1368,23 @@ function transcribeText() { ...@@ -1368,15 +1368,23 @@ function transcribeText() {
1368 } 1368 }
1369 1369
1370 let input_line = "" 1370 let input_line = ""
1371 -function uploadSoundData(blob) { 1371 +let tab = '';
1372 +let before_val = '';
1373 +let chk = 1;
1374 +let tmp = [];
1375 +async function uploadSoundData(blob) {
1372 let filename = new Date().toISOString(); 1376 let filename = new Date().toISOString();
1373 let xhr = new XMLHttpRequest(); 1377 let xhr = new XMLHttpRequest();
1374 let formData = new FormData(); 1378 let formData = new FormData();
1375 xhr.onload = function(e) { 1379 xhr.onload = function(e) {
1376 if(this.readyState === 4) { 1380 if(this.readyState === 4) {
1377 - let transcript = JSON.parse(e.target.responseText) 1381 + let transcript = JSON.parse(e.target.responseText) + '';
1378 document.getElementById("output").innerHTML += `${cnt++}: ${transcript}<br><br>`; 1382 document.getElementById("output").innerHTML += `${cnt++}: ${transcript}<br><br>`;
1379 - uploadTranscriptData(transcript); 1383 + tmp = transcript.split(' ');
1384 + if (tmp[0] == '종료') tab = tab.slice(1);
1385 + else{
1386 + uploadTranscriptData(tab, transcript);
1387 + }
1380 } 1388 }
1381 }; 1389 };
1382 formData.append("audio_data", blob, filename); 1390 formData.append("audio_data", blob, filename);
...@@ -1384,7 +1392,7 @@ function uploadSoundData(blob) { ...@@ -1384,7 +1392,7 @@ function uploadSoundData(blob) {
1384 xhr.send(formData); 1392 xhr.send(formData);
1385 } 1393 }
1386 1394
1387 -function uploadTranscriptData(txt) { 1395 +async function uploadTranscriptData(tabs, txt) {
1388 let request = new XMLHttpRequest(); 1396 let request = new XMLHttpRequest();
1389 let form = new FormData(); 1397 let form = new FormData();
1390 request.onload = function(e) { 1398 request.onload = function(e) {
...@@ -1392,9 +1400,13 @@ function uploadTranscriptData(txt) { ...@@ -1392,9 +1400,13 @@ function uploadTranscriptData(txt) {
1392 console.log(e.target.responseText) 1400 console.log(e.target.responseText)
1393 input_line += e.target.responseText; 1401 input_line += e.target.responseText;
1394 sourceEditor.setValue(input_line); 1402 sourceEditor.setValue(input_line);
1403 + if ((tmp[0] == '함수' || tmp[0] == '반복문' || tmp[0] == '조건문') && e.target.responseText != '') {
1404 + tab += '\t';
1405 + }
1395 } 1406 }
1396 }; 1407 };
1397 form.append("transcript_data", txt); 1408 form.append("transcript_data", txt);
1409 + form.append("tabs", tabs);
1398 request.open("POST", "/ttp", true); 1410 request.open("POST", "/ttp", true);
1399 request.send(form); 1411 request.send(form);
1400 } 1412 }
...\ No newline at end of file ...\ No newline at end of file
......
This diff is collapsed. Click to expand it.