Skip to content

Instantly share code, notes, and snippets.

@pedroxs
Created July 1, 2014 17:28
Show Gist options
  • Select an option

  • Save pedroxs/5aed2d3d8603547f444a to your computer and use it in GitHub Desktop.

Select an option

Save pedroxs/5aed2d3d8603547f444a to your computer and use it in GitHub Desktop.
/*
* helper function for fast typing on
* http://10fastfingers.com/
*
* 200 ms seems good enough
*/
function Gambi(interval) {
var timerId, start, stop, getId, currentWord;
start = function() {
timerId = window.setInterval(function() {
var word = jQuery('span.highlight');
if(!currentWord || currentWord.text() !== word.text()) {
currentWord = word;
jQuery('#inputfield').val(currentWord.text());
}
}, interval);
};
stop = function() {
window.clearInterval(timerId);
};
getId = function() { return timerId; };
return {
id: getId,
start: start,
stop: stop
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment