|
const textGenForm = document.querySelector('.text-gen-form'); |
|
|
|
const translateText = async (text) => { |
|
const inferResponse = await fetch(`infer_t5?input=${text}`); |
|
const inferJson = await inferResponse.json(); |
|
|
|
return inferJson; |
|
}; |
|
|
|
textGenForm.addEventListener('submit', async (event) => { |
|
event.preventDefault(); |
|
|
|
const textGenInput = document.getElementById('text-gen-input'); |
|
const textGenParagraph = document.querySelector('.text-gen-output'); |
|
const textGenParagraph_2 = document.querySelector('.text-gen-output_2'); |
|
const textGenParagraph_3 = document.querySelector('.text-gen-output_3'); |
|
const textGenParagraph_4 = document.querySelector('.text-gen-output_4'); |
|
const textGenParagraph_5 = document.querySelector('.text-gen-output_5'); |
|
|
|
try { |
|
var text_out = await translateText(textGenInput.value); |
|
textGenParagraph.textContent = text_out.size_str; |
|
textGenParagraph_2.textContent = text_out.size_4; |
|
textGenParagraph_3.textContent = text_out.cancer; |
|
textGenParagraph_4.textContent = text_out.transfer; |
|
textGenParagraph_5.textContent = text_out.ly_transfer; |
|
} catch (err) { |
|
console.error(err); |
|
} |
|
}); |