metafocus
A highly configurable rsvp reader with new reticle types.
Installation
npm install metafocus --save
Getting Started
First, load the metafocus module:
var metafocus = ;
To conveniently use metafocus in your code, you'll need to set up a reference for each method in the module. An example of how to do this:
var handleFile = metafocushandleFile startReading = metafocusstartReading getTextFromPDF = metafocusgetTextFromPDF setWPM = metafocussetWPM setPause = metafocussetPause; setFF = metafocussetFF; setRewind = metafocussetRewind;
Linux
Metafocus requires pdftext and pdffonts, which requires poppler-utils to be installed:
Debian/Ubuntu:
apt-get install poppler-utils
Fedora/CentOS:
yum install poppler-utils
The methods below are expecting references to the UI controls you are using to interface with the metafocus library (events, UI rendering, etc.) as their parameters:
startReading(ret, counterElem)
-
Create a reference in the DOM (for browser UIs) to the element you want to use to trigger the metafocus reader to begin cycling through the document.
var startButton = document;var counterDiv = document; //for displaying the current word index -
Create a UI element to act as the 'reticle' that metafocus will update with the current word. In the example below, we're using webcomponents:
In the app/components directory:
On the page:
Script to create the reticle and reference it:
{ var template = document; var importedReticle = templateimport; var clone = document; return clone;} //reticle init:var reticleTemplate = ;var reticlePlaceholder = document;reticlePlaceholder;var reticle = document;
Pass the reticle reference as a parameter on the startButton click event:
startButton;
setPause(button), setFF(button), setRewind(button)
Pass the target of the click event to each of these methods, so it can be updated with the status of each control 'command':
pauseButton; ffButton; rewindButton;
readFile(files, customFilter, cb)
Pass a callback that will update the UI when the file read is completed:
var { var filename = ;}
The filter is an optional function you create and pass in as a parameter to the readFile() function. The example below will remove an email and name from the text, along with a regex that matches unwanted numbers:
{ var matchesFilter = false; var regexNumbers = /\W+/g; ifvalue matchesFilter = true; return !matchesFilter;}