-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
51 lines (48 loc) · 2.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sentiment Analysis Web App</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
"use strict";
function submitForm(oFormElement) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var result = parseFloat(xhr.responseText);
var resultElement = document.getElementById('result');
if (result == 0) {
resultElement.className = 'bg-danger';
resultElement.innerHTML = 'Your review was NEGATIVE!';
} else {
resultElement.className = 'bg-success';
resultElement.innerHTML = 'Your review was POSITIVE!';
}
}
xhr.open (oFormElement.method, oFormElement.action, true);
var review = document.getElementById('review');
xhr.send (review.value);
return false;
}
</script>
</head>
<body>
<div class="container">
<h1>Is your review positive, or negative?</h1>
<p>Enter your review below and click submit to find out...</p>
<form method="POST"
action="https://hlnhcw8hr4.execute-api.us-west-2.amazonaws.com/Test"
onsubmit="return submitForm(this);" > <!-- HERE IS WHERE YOU NEED TO ENTER THE API URL -->
<div class="form-group">
<label for="review">Review:</label>
<textarea class="form-control" rows="5" id="review">Please write your review here.</textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<h1 class="bg-success" id="result"></h1>
</div>
</body>
</html>