Skip to content

Commit

Permalink
js
Browse files Browse the repository at this point in the history
  • Loading branch information
lswang1618 committed Dec 12, 2014
1 parent cd2dc12 commit 2790285
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
44 changes: 43 additions & 1 deletion webpage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,52 @@
<script src="assets/jquery-2.1.1.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function getOutput(){
getRequest(
'predict.php',
drawOutput,
drawError
);
return false;
}

function drawOutput(response){
$("#out").innerHTML = response;
}

function drawError(){
$("#out").innerHTML = "There seems to be an error, please try again!";
}

function getRequest(url, success, error){
var req = false;
try{
req = new XMLHttpRequest();
} catch(e){
}

if (!req) return false;
if (typeof success != 'function') success = function(){};
if (typeof error != 'function') error = function() {};
req.onreadystatechange = function(){
if (req.readyState == 4){
return req.status === 200 ?
success(req.responseText) : error(req.status);
}
}
req.open("GET", url, true);
req.send(null);
return req;
}
$(document).ready(function(){
$('a').click(function(){
var clicked = $(this).attr("href");
var dest = $(clicked).offset().top;
$("html, body").animate({scrollTop: dest-15}, 1000);
return false;
});
});


</script>
</head>
<body>
Expand Down Expand Up @@ -132,6 +170,10 @@ <h3> Test Accuracy </h3>
<div class="section" id="response">
<!-- <img class="thumb" src="assets/email.png"> -->
<h1 id="name">Response Predictor</h1>
<h3> Type in an email below </h3>
<textarea id="email" rows="10" cols="150"></textarea>
<a href="#response" onclick = "return getOutput();"> submit </a>
<div id="out"></div>
</div>
</div>
<script src="graph.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions webpage/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,11 @@ text {
font: 10px sans-serif;
pointer-events: none;
text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff;
}

textarea{
padding: 10px;
display: block;
margin: 0;
color: #000;
}

0 comments on commit 2790285

Please sign in to comment.