Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jeenuv/reasy
base: 0eae089e4b
...
head fork: jeenuv/reasy
compare: 8e47111f6e
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 15, 2011
@jeenuv Keyboard shortcuts for = and - for adjusting WPM 2014221
@jeenuv Couple of state fixes ef29034
@jeenuv Going backward reduces speed transiently
Going backward means use missed some parts and probably would like to
take good look at it again. The number of words gone backward is
dependent on reading speed - more the speed, farther we go backward
8e47111
Showing with 27 additions and 5 deletions.
  1. +27 −5 reasy.js
View
32 reasy.js
@@ -44,12 +44,24 @@ REASY.keyHandler = function () {
if (REASY.keystate == "handling")
return;
- // Quit
if (event.keyCode == ("q".charCodeAt(0) - 32)) {
+ // Quit
REASY.hideStage();
return false;
+ } else if (event.keyCode == 187) { // +
+ // Increase WPM
+ REASY.wpm = parseInt(REASY.wpm) + 10;
+ REASY.wpmSpan.text(REASY.wpm);
+ return false;
+ } else if (event.keyCode == 189) { // -
+ // Decrease WPM
+ REASY.wpm = parseInt(REASY.wpm) - 10;
+ REASY.wpmSpan.text(REASY.wpm);
+ return false;
}
+ REASY.keystate = "handling";
+
// Signal to pause reading and wait until it's
var wasAlreadyPaused = (REASY.state == "paused")
REASY.state = "paused";
@@ -60,12 +72,14 @@ REASY.keyHandler = function () {
// Subtract 32 from keycode for alphabets
if (code == ("b".charCodeAt(0) - 32)) {
- // Backward
- idx -= 10;
+ REASY.anchorIndex = idx; // Remember where we were
+ // Backward proprotional to the WPM
+ idx -= parseInt(REASY.wpm / 30);
if (idx < 0)
idx = 0;
REASY.nextIdx = idx;
} else if (code == ("f".charCodeAt(0) - 32)) {
+ REASY.anchorIndex = 0; // Forget the anchor
// Forward
idx += 10;
if (idx > REASY.words.length)
@@ -88,7 +102,8 @@ REASY.keyHandler = function () {
REASY.state = "running";
REASY.play();
REASY.keystate = "";
- }, 600, event.keyCode);
+ },
+ 600, event.keyCode);
return false;
};
@@ -207,6 +222,7 @@ REASY.hideStage = function () {
REASY.stage.css("display", "none");
REASY.state = "stopped";
REASY.textArea.text("");
+ REASY.anchorIndex = 0;
$(document).unbind("keyup", REASY.keyHandler);
$(document).unbind("keyup", REASY.launchHandler)
.keyup(REASY.launchHandler);
@@ -241,8 +257,13 @@ REASY.play = function () {
// TODO: factor in length of the word
if (REASY.punc.test(word) == true)
delay = 650;
- else
+ else {
delay = 60000 / REASY.wpm;
+ // Go slow until we reach back where user pressed back, presumably for
+ // re-reading that part of text
+ if (REASY.anchorIndex > 0 && REASY.anchorIndex >= index)
+ delay *= 2;
+ }
REASY.nextIdx++;
// Schedule read for updation
@@ -264,6 +285,7 @@ REASY.run = function () {
var selection = window.getSelection().toString();
if (selection.length < 25) {
REASY.log("Length of selected string less than threshold");
+ REASY.state = "stopped";
return;
}

No commit comments for this range

Something went wrong with that request. Please try again.