| 17 | |
| 18 | //Start the Reader |
| 19 | function startReader(event){ |
| 20 | //only run on #start button |
| 21 | if(event.target.id !== 'start') |
| 22 | return; |
| 23 | |
| 24 | // If there's no text to read, do nothing |
| 25 | if (!textElem.value.length) |
| 26 | return; |
| 27 | |
| 28 | //store the words in words array |
| 29 | words = |
| 30 | textElem.value.split(' ') //divide the space separated words into words array |
| 31 | .filter(function(individualWord){ //filters empty array elements |
| 32 | return individualWord.length; |
| 33 | }); |
| 34 | |
| 35 | //get the words per minute |
| 36 | speed = (60 / parseInt(wpmElem.value, 10)) * 1000; //speed of a word in milliseconds |
| 37 | |
| 38 | //set the current item to the first word |
| 39 | current = 0; |
| 40 | |
| 41 | //Run the reader |
| 42 | run(); |
| 43 | } |
| 44 | |
| 45 | //Stop the Reader |
| 46 | function stopReader(event){ |