You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.2 KiB

<!DOCTYPE html>
<html lang="en">
<title>Sentiment Analysis Web App</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></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!';
} (oFormElement.method, oFormElement.action, true);
var review = document.getElementById('review');
xhr.send (review.value);
return false;
<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"
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>
<button type="submit" class="btn btn-default">Submit</button>
<h1 class="bg-success" id="result"></h1>