percentage of accuracy shown

This commit is contained in:
qt31415926
2015-03-29 10:00:12 -04:00
parent b1112b4a46
commit df0a7870ff
3 changed files with 7 additions and 2 deletions
+1
View File
@@ -1 +1,2 @@
*.swp
*.swo
+1
View File
@@ -29,6 +29,7 @@
<div class="row text-center">
<input id="submit1" class="btn btn-primary" type="submit" value="Submit">
<a id="submit2" class="btn btn-success" href="#" disabled="enabled">Go Back</a>
<br><p id="percent"></p>
<br><strong></strong>
</div>
<div class="row">
+5 -2
View File
@@ -17,7 +17,7 @@ var sayings = [
var passed = false;
window.onload = function setupUpdater(){
var input=document.getElementsByTagName('textarea')[0]
, count=document.getElementById('charCount')
, count=document.getElementById('percent')
, target=document.getElementById('target')
, targetText = sayings[Math.floor(Math.random()*sayings.length)]
, a = FuzzySet([targetText])
@@ -34,14 +34,17 @@ window.onload = function setupUpdater(){
var newText=input.value;
var score = a.get(newText)[0][0];
if (score>0.91) {
set(count, "");
passed = true;
return;
} else if (score> 0.1){
set(count, "You are " + score*100 + "% accurate (need >91)");
}
}
function eventHandler(){
if(timeout) clearTimeout(timeout);
timeout=setTimeout(handleChange, 130);
timeout=setTimeout(handleChange, 50);
}
input.onkeydown=input.onkeyup=onClick=eventHandler;
};