mirror of
https://github.com/wassname/mad.git
synced 2026-07-27 11:23:58 +08:00
percentage of accuracy shown
This commit is contained in:
@@ -1 +1,2 @@
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
@@ -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
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user