ianluo commited on
Commit
506e4be
1 Parent(s): d1d8914
Files changed (1) hide show
  1. static/script.js +10 -12
static/script.js CHANGED
@@ -1,23 +1,21 @@
1
- const textGenForm = document.querySelector(".text-gen-form")
2
 
3
  const translateText = async (text) => {
4
- console.log('start translate');
5
- const inferResponse = await fetch(`infer_t5?input=${text}`);
6
- const inferJson = await inferResponse.json();
7
 
8
- return inferJson.output;
9
- }
10
 
11
- textGenForm.addEventListener("submit", async (e) => {
12
- e.preventDefault();
13
 
14
- const textGenInput = document.getElementById("text-gen-input");
15
- const textGenParagraph = document.querySelector(".text-gen-output");
16
 
17
  try {
18
  textGenParagraph.textContent = await translateText(textGenInput.value);
19
- console.log(textGenParagraph.textContent);
20
  } catch (err) {
21
- console.log(err);
22
  }
23
  });
 
1
+ const textGenForm = document.querySelector('.text-gen-form');
2
 
3
  const translateText = async (text) => {
4
+ const inferResponse = await fetch(`infer_t5?input=${text}`);
5
+ const inferJson = await inferResponse.json();
 
6
 
7
+ return inferJson.output;
8
+ };
9
 
10
+ textGenForm.addEventListener('submit', async (event) => {
11
+ event.preventDefault();
12
 
13
+ const textGenInput = document.getElementById('text-gen-input');
14
+ const textGenParagraph = document.querySelector('.text-gen-output');
15
 
16
  try {
17
  textGenParagraph.textContent = await translateText(textGenInput.value);
 
18
  } catch (err) {
19
+ console.error(err);
20
  }
21
  });