-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
71 lines (65 loc) · 1.75 KB
/
index.php
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
70
71
<?php include ('core/koneksi.php') ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{margin:0px auto;}
#wrapper{padding:1em 0;}
#hasil{padding:.5em 0; text-align:center;}
input#analyze{width:100%; font-size:30px; padding:.5em; border-radius:4px; border:1px solid #ccc;}
img, button{transition:.25s ease; -moz-transition:.25s ease; -webkit-transition:.25s ease; -o-transition:.25s ease;}
.hide{opacity:0;}
</style>
<link rel="stylesheet" href="assets/bootstrap.min.css">
</head>
<body>
<div id="wrapper" class="container">
<span class="btn btn-primary" id="refresh">
Refresh
</span>
<input type="text" id="analyze" placeholder="Masukkan kalimat komentar disini">
<div id="hasil">
<img src="assets/pie.gif" class="hide">
<div id="out"></div>
<input type="hidden" name="unique_id" value="">
</div>
</div>
<script src="assets/jquery-1.12.3.min.js"></script>
<script src="assets/less-1.3.3.min.js"></script>
<script>
$(function(){
$("#analyze").on("keypress",function(e){
if(e.which == 13){
$("img").removeClass("hide");
$.ajax({
url : "api.php",
method : "GET",
data : {q : $("#analyze").val()},
dataType : "json"
}).done(function(data){
$("img").addClass("hide");
if(data['error'] == 0){
if(data['sentiment'] == 1){
vclass = 'alert-success';
}
else{
vclass = 'alert-warning';
}
$("#out").html("<div class='alert "+vclass+"'>"+data['message']+"</div>");
$("input[name=unique_id]").val(data['unique_id']);
}
else{
$("#out").html("<div class='alert alert-info'>"+data['message']+"</div>");
}
});
}
});
$("#refresh").click(function(){
location.reload();
});
});
</script>
</body>
</html>