https://github.com/bredele/lookfor
Client-side full-text search using CSS and built for speed.
https://github.com/bredele/lookfor
Last synced: about 1 year ago
JSON representation
Client-side full-text search using CSS and built for speed.
- Host: GitHub
- URL: https://github.com/bredele/lookfor
- Owner: bredele
- Created: 2013-09-21T17:16:02.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-20T23:52:39.000Z (about 12 years ago)
- Last Synced: 2025-04-14T14:12:39.752Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 266 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
Awesome Lists containing this project
README
look for
======
Client-side full-text search using CSS and built for speed.
## Installation
with component:
$ component install bredele/lookfor
with nodejs:
$ npm install lookfor
## Usage
`lookfor` uses dataset (`data-search`) to index dom elements...
```html
```
...and dynamically creates and updates a stylesheet node for search.
```js
var search = require('lookfor')();
search('beep');
search('boop');
```
see [examples](https://github.com/bredele/lookfor/blob/master/examples/index.html).
## How does it work?
`lookfor` relies on CSS3 selectors (such as `:not()` and `[attr*=]`) rather than JavaScript. Instead changing one by one all the elements matching the query, `lookfor` updates the inner HTML of a single `` element. Here's an example:
```html
<style>
.searchable:not([data-search*='beep']) {
display: none;
}
```
The browser does all the work and won't trigger unnecessary repain/relayout mechanism.
## Web components
`lookfor` can be used to performed a full-text search in a web component. It's easy you just has to pass the web component host element (`el`):
```js
var search = require('lookfor')(el);
```
## License
The MIT License (MIT)
Copyright (c) 2014 Olivier Wietrich
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.