ammaan's picture
Create index.js
4c81dc7 verified
raw
history blame
869 Bytes
async function sendDataToBackend(inputData) {
try {
document.getElementById("loader").style.display = "block";
const response = await fetch(
`/getdata?input=${encodeURIComponent(inputData)}`
);
if (response.ok) {
const data = await response.json();
document.getElementById("loader").style.display = "none";
document.getElementById("summaryResult").innerText = data.summary;
}
} catch (error) {
console.error(error);
}
}
function handleSubmit(event) {
event.preventDefault();
const inputElement = document.getElementById("youtubeLinkInput");
const inputData = inputElement.value.trim();
if (inputData) {
sendDataToBackend(inputData);
}
}
document.addEventListener("DOMContentLoaded", () => {
const form = document.getElementById("summaryForm");
form.addEventListener("submit", handleSubmit);
});