npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metafocus

v0.1.5

Published

A highly configurable rsvp reader with new reticle types.

Downloads

14

Readme

metafocus

A highly configurable rsvp reader with new reticle types.

Installation

npm install metafocus --save

Getting Started

First, load the metafocus module:

var metafocus = require('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 =  metafocus.handleFile,
    startReading = metafocus.startReading,
    getTextFromPDF = metafocus.getTextFromPDF,
    setWPM = metafocus.setWPM,
    setPause = metafocus.setPause;
    setFF = metafocus.setFF;
    setRewind = metafocus.setRewind;

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)

  1. 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.getElementById('start'); 
    var counterDiv = document.getElementById('counter'); //for displaying the current word index
  2. 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:

<template id="reticle">
 <div id="reticle" class="metafocus showBorder"></div>
</template>

On the page:

<link rel="import" id="reticle-template" href="app/components/reticle.html">

Script to create the reticle and reference it:

function createReticle(){
 var template = document.querySelector('#reticle-template');
 var importedReticle = template.import.querySelector('#reticle');
 var clone = document.importNode(importedReticle.content, true);
 return clone;
}

//reticle init:
var reticleTemplate = createReticle();
var reticlePlaceholder = document.querySelector('#reticlePlaceholder');
reticlePlaceholder.appendChild(reticleTemplate);
var reticle = document.getElementById('reticle');

Pass the reticle reference as a parameter on the startButton click event:

startButton.addEventListener('click', function (event) {
 ///the reticle above will be updated with the currrent word, counterDiv is passed in so it can be updated with the index of the current word:
 startReading(reticle, counterDiv);
});

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.addEventListener('click', function (event) {
  setPause(event.target);
});

ffButton.addEventListener('click', function (event) {
  setFF(event.target);
});

rewindButton.addEventListener('click', function (event) {
  setRewind(event.target);
});

readFile(files, customFilter, cb)

Pass a callback that will update the UI when the file read is completed:

var readFile = function(files){
    var filename = handleFile(files, simpleFilter, function(filename, wordCount){
        fileNamePlaceholder.innerHTML = "<div id='fileName' class='fileUpload showBorder'>" + filename + "</div>";
        wordCountDiv.innerHTML = wordCount;
    });
}

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:


function simpleFilter(value){
  var matchesFilter = false;
  switch(value){
    case '<[email protected]>,':
      matchesFilter = true;
      break;
    case '':
      matchesFilter = true;
      break;
    case '.':
      matchesFilter = true;
      break;
    case 'My Name':
      matchesFilter = true;
      break;
  }

  var regexNumbers = /(\d)\W+/g;
  if(value.match(regexNumbers)){
    matchesFilter = true;
  }

  return !matchesFilter;
}