-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
57 lines (48 loc) · 1.39 KB
/
popup.js
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
var serverhost = "http://127.0.0.1:8000";
const fetchVideoData = async (videoId) => {
var url = serverhost + "/sentiment-analyzer/get-video-sentiment/" + videoId;
console.log(url);
const options = {
method: "GET",
};
const res = {};
let response = await fetch(url, options);
let data = await response.json();
return data;
};
// const fetchTextData = async (rawComment) => {
// let comment = rawComment.replace(" ", "-");
// var url =
// serverhost + "/sentiment-analyzer/get-text-sentiment/" + "I-am-excited";
// const options = {
// method: "GET",
// };
// const res = {};
// fetch(url)
// .then((response) => response.json())
// .then((data) => {
// return data;
// });
// };
let submitButton = document.getElementById("subjectSubmit");
// const submitText = () => {
// let comment = document.getElementById("subjectText").value;
// console.log(comment);
// if (comment) {
// fetchTextData(comment).then((response) => {
// console.log(response);
// });
// }
// };
const getVideoSentiment = async () => {
let videoId = document.getElementById("subjectText").value;
console.log(videoId);
if (videoId) {
let response = await fetchVideoData(videoId);
console.log(JSON.stringify(response));
}
};
if (submitButton) {
console.log("the submit button exists");
submitButton.addEventListener("click", getVideoSentiment);
}