ammaan commited on
Commit
4c81dc7
1 Parent(s): d8aed13

Create index.js

Browse files
Files changed (1) hide show
  1. static/index.js +29 -0
static/index.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ async function sendDataToBackend(inputData) {
2
+ try {
3
+ document.getElementById("loader").style.display = "block";
4
+ const response = await fetch(
5
+ `/getdata?input=${encodeURIComponent(inputData)}`
6
+ );
7
+ if (response.ok) {
8
+ const data = await response.json();
9
+ document.getElementById("loader").style.display = "none";
10
+ document.getElementById("summaryResult").innerText = data.summary;
11
+ }
12
+ } catch (error) {
13
+ console.error(error);
14
+ }
15
+ }
16
+
17
+ function handleSubmit(event) {
18
+ event.preventDefault();
19
+ const inputElement = document.getElementById("youtubeLinkInput");
20
+ const inputData = inputElement.value.trim();
21
+ if (inputData) {
22
+ sendDataToBackend(inputData);
23
+ }
24
+ }
25
+
26
+ document.addEventListener("DOMContentLoaded", () => {
27
+ const form = document.getElementById("summaryForm");
28
+ form.addEventListener("submit", handleSubmit);
29
+ });