-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
68 lines (63 loc) · 1.86 KB
/
index.html
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
<head>
<link
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.4/css/bulma.min.css"
rel="stylesheet"
/>
<style>
#main {
margin: 2rem;
}
.big {
font-size: 1.2rem;
}
</style>
</head>
<body>
<section class="hero is-success">
<div class="hero-body">
<div class="container">
<h1 class="title">Sentiment Analysis</h1>
<h2 class="subtitle">Attitude on Dementia using Natural Languange Processing</h2>
</div>
</div>
</section>
<div id="main">
<table class="table is-fullwidth">
<thead>
<tr>
<th>Feeling</th>
<th>Score</th>
<th>Author</th>
<th>Comment</th>
</tr>
</thead>
<tbody id="sentimentTable"></tbody>
</table>
</div>
<script>
var request = new XMLHttpRequest();
request.open("GET", "/data", true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var table = document.getElementById("sentimentTable");
var data = JSON.parse(request.responseText);
data.forEach(function(comment) {
var newRow = table.insertRow(table.rows.length);
newRow.insertCell(0).innerHTML = comment.emoji;
newRow.insertCell(1).innerHTML = comment.sentiment;
var rowLink = document.createElement("a");
rowLink.innerHTML = comment.author;
rowLink.href = comment.link;
newRow.insertCell(2).appendChild(rowLink);
newRow.insertCell(3).innerHTML = comment.body;
});
} else {
alert("Could not retrieve data");
}
};
request.onerror = function() {
alert("Could not retrieve data");
};
request.send();
</script>
</body>