From df0a7870ff3d8f6500739970dc71601c895220b1 Mon Sep 17 00:00:00 2001 From: qt31415926 Date: Sun, 29 Mar 2015 10:00:12 -0400 Subject: [PATCH] percentage of accuracy shown --- .gitignore | 1 + background.html | 1 + js/verify.js | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1377554..3819313 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.swp +*.swo diff --git a/background.html b/background.html index 46b449f..5b480ed 100644 --- a/background.html +++ b/background.html @@ -29,6 +29,7 @@
Go Back +


diff --git a/js/verify.js b/js/verify.js index 75e360f..82b1ddd 100644 --- a/js/verify.js +++ b/js/verify.js @@ -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; };