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

findinnw

v2.0.0

Published

Simulate the Ctrl+F (find) feature from Chrome in NW.js

Downloads

30

Readme

"Find" in NW.js

Adds "Ctrl+F" find box to highlight text in the DOM

Animated example

Use

  1. npm install --save findinnw
  2. In your HTML file add:
    <script src="node_modules/findinnw/dist/find-in-nw.js"></script>
    <script>
      findInNw.initialize();
    </script>
  3. Use CTRL+F to display and give focus to the search box
  4. After typing, press ENTER to go to highlight/scroll to the next match.
  5. Use TAB to navigate to the "previous", "next", and "close" buttons.
  6. Use ENTER or SPACE to activate a button when focused.
  7. User ESC to hide the search box and return focus to the body

API

findInNw.initialize(options);

This is the initialization command. It must be ran once. You can pass in an options object documented below:

options

Option | Type | Description :-- | :-- | :-- verbose | Boolean | Console logs information, included mutations that re-trigger searches classesToIgnore | Array of Strings | List of class names to ignore when deciding to re-trigger searches automatically when the DOM changes idsToIgnore | Array of Strings | List of IDs to ignore when deciding to re-trigger searches automatically when the DOM changes passThrough | Object | Any findAndReplaceDOMText options

Note: If you notice the search box is acting funny (the "Next"/"Previous" buttons aren't working as expected for example), then most likely there are DOM changes occurring that are re-triggering the search to display accurate results. This causes the "current" highlighted item to be reset. You should turn on verbose, then look at the mutations logged when the funny behavior occurs. Each mutation has a target (the element that changed). You can add that targeted element's ID or classname to the array of classesToIgnore or idsToIgnore. This should stop the funny behavior.

Example:

findInNw.initialize({
  verbose: true,
  classesToIgnore: ['tooltip', 'tabCount'],
  idsToIgnore: ['back-to-top'],
  passThrough: {}
});

findInNw.showSearchBox();

This is used to programmitcally display the search box. CTRL+F will still display it too.

findInNw.hideSearchBox();

This is used to programmitcally hide the search box. ESC will still hide it too.

findInNw.search('Text to find');

This is used to programmitcally find text.

findInNw.highlightNext(); and findInNw.highlightPrevious();

This will highlight and scroll to the next or previous match.

findInNw.clearTokens();

This is used to remove all the highlighted tokens.

Customizing Styles

Highlight tokens

All highlight tokens of matching searched text will be wrapped in a <mark class="find-in-nw-token">searched text</mark>.

They will also contain a data-find-in-nw-position="4" data attribute, the number correlates to a zero-based index of all matches.

As you navigate from one match to the next, the currently selected match will have a class of .find-in-nw-current-token.

You can customize this by targeting the following

mark.find-in-nw-token {
    background-color: #00F;
}

mark.find-in-nw-current-token {
    background-color: #38D878;
}

Search Box

Each element of the search box is styled by targeting a class. They also all have a matching ID that you can target to override them.

/* The container for the input/count/close */
#find-in-nw-search-box {}

/* The input field you type in */
#find-in-nw-input {}

/* The current selected match number. Ex: The number 1 in "1/5" */
#find-in-nw-current {}

/* The separator between the current and count. Ex: The slash (/) in "1/5" */
#find-in-nw-of {}

/* The count of matching highlighted items. Ex: The number 5 in "1/5" */
#find-in-nw-count {}

/* The case sensitivty toggle, Ex: Aa button */
#find-in-nw-case-sensitive {}

/* The previous and next buttons, ∧ and ∨ */
#find-in-nw-previous {}
#find-in-nw-next {}

/* The × close button */
#find-in-nw-close {}

Contributing

  1. Create an issue first for your desired improvements and how you think they should be implemented.
  2. If plan is approved (or no response given in a timely manner), then you can submit a PR.
  3. Make sure to run npm run validate prior to submitting your PR and fix any errors or warnings.