File size: 1,678 Bytes
9756872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function goToPage2() {
  window.location.href = "page2.html";
}

function plotCreativity(event) {
  event.preventDefault();
  alert("Plotting the creativity");
}

function calculatesimilarity(event) {
  event.preventDefault();
  alert("Plotting the visual creativity");
}

function analyzeData(event) {
  event.preventDefault();

  // Collect the word list from the textarea
  const wordList = document.querySelector('textarea[name="wordlist"]').value;

  // Prepare the data to be sent to the backend
  const formData = { wordList };

  fetch("/analyze", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(formData),
  })
    .then((response) => response.json())
    .then((data) => {
      console.log("Analysis result:", data);
      alert("Data analyzed. Check console for results.");
    })
    .catch((error) => {
      console.error("Error:", error);
    });
}

function uploadAndAnalyze(event) {
  event.preventDefault();

  const fileInput = document.querySelector('input[type="file"]');
  const file = fileInput.files[0];

  if (file) {
    const formData = new FormData();
    formData.append("file", file);

    fetch("/upload", {
      method: "POST",
      body: formData,
    })
      .then((response) => response.json())
      .then((data) => {
        console.log("Upload and analysis result:", data);
        alert("File uploaded and data analyzed. Check console for results.");
      })
      .catch((error) => {
        console.error("Error:", error);
      });
  } else {
    alert("Please select a file to upload.");
  }
}

// JavaScript to update the word1 value based on the dropdown selection