baresearch.js

a small & fast public domain filtered search JavaScript library

currently 48 SLOC

Download:

It essentialy works like grep, but for HTML DOM.

The source code is written with an intention for you to modify it. It contains comments with suggestions for extending it's functionality.

If you want something more elaborate built with the same principles, there will be an extended version of this with fuzzy search and some other features in the future.

Now straight to the point. This is how you use it:

<!-- Include the script anywhere. It'll wait for the page to load. --> <script src="./path/to/baresearch.js"></script> <!-- Below is the container of our filtered search. It doesn't need any special classes. --> <div> <!-- The search box must have class="baresearch-search" --> <p></p> <input type="text" class="baresearch-search"> <p> In between the elements managed by the library you may have as many elements of your own as you want. </p> <!-- Now, a wrapper with items. Items are all of it's immediate children. In this case it's the divs. The h3-s and p-s are part of them, but not items of their own. A wrapper of items must have a class="baresearch-items". --> <div class="baresearch-items"> <!-- 1st item --> <div> <h3>This header is inside an item,</h3> <p>the form of which doesn't matter.</p> <p>All the text will be searched.</p> </div> <!-- 2nd item --> <div> <p>Another item</p> <p>Note that items don't need</p> <p>any special classes</p> </div> <!-- have as many elements as you want --> </div> <div class="baresearch-empty"> <p> This is the message displayed when there are no items matching the search. </p> <p> The script hides it on load, so you don't have to pre-hide it in your stylesheets. </p> </div> </div>

That's it. You don't need to use any fancy JavaScript API — there is none.
All you have to do is include the script and put the classes in.

Here's a working example:

Lorem ipsum dolor sit amet, consectetur adipisicing elit.

Nam, quisquam officiis! Veniam corrupti saepe, illo fugit quo reprehenderit deserunt atque numquam autem nesciunt quidem pariatur eius natus, exercitationem doloremque! Modi.

To be, or not to be: that is the question:
Whether ’tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them. To die: to sleep...
Hamlet, Act III, Scene I

Might as well put it here.

The project's license 1/5

This is free and unencumbered software released into the public domain.

License 2/5

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

License 3/5

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

License 4/5

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 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.

License 5/5

For more information, please refer to https://unlicense.org

The summary:

You can do whatever you want with it.

You technically don't have to leave any atribution, but it would be nice ;)

Full UTF-8 support

六四事件

六四事件是中华人民共和国历史上的一个转折点,它的爆发标志着邓小平、赵紫阳等人在中国大陆推动的后期政治体制改革失败,赵紫阳、鲍彤等中共改革派高层被撤职,1980年代不同程度放開的自由與言論從此轉向收緊。国际社会对此事件普遍表示了谴责和制裁,也有部分国家表示同情或者支持,而六四事件的經濟影響也直接导致了中華人民共和國改革开放的放缓甚至停滞,直至1992年邓小平南巡后才重新提速。不過,邓小平任内推行的废除干部领导职务终身制則一直延续下来,期間更完成了3任政權的和平更替,直至習近平2018年修宪后被废除。

Zażółć gęślą jaźń

Pictures work too.

Y by Zdzisław Beksiński Y (2005) by Zdzisław Beksiński

Tis true without lying, certain and most true.

That which is below is like that which is above and that which is above is like that which is below to do the miracle of one only thing

And as all things have been and arose from one by the mediation of one: so all things have their birth from this one thing by adaptation.

Tabula Smaragdina, translation by Isaac Newton

Sorry, there are no items matching your search phrase.

Try something different.

You can have multiple searches on the same page. The only thing you have to do is to keep them in seperate containers.


This website doesn't track you and doesn't have any ads.
If you've got a spare buck, please consider .