I need to write a tool that exports some chats into offline HTML files. Is there a possibility to add search support (e.g. add some home page index.html that contains a search field and shows search results)? The question is in common: what tools/frameworks/smth other can you advice for this?
I need to write a tool that exports some chats into offline HTML files.
Share
I assume you want to do the search in a browser, because if not, then the
greputility would be very efficient.You can add a JavaScript to every exported page, which will scan the content and do the search. You can also handle multiple pages by creating an index page with “search data” and links to every subpage, but it depends on the amount of text you want to search. Searching on a single page will be easier.
The basic workflow will be:
<input>)<tr>in case of tables,<li>if you use lists, and so on) and check whether the typed text appears intextContentproperty of this element.This is the most basic form.
A little more efficient way would be to prepare an index array (by the script, in memory) where you store the
textContent(or anything you want to do your search on) and the element which contains itWhen looping over the elements hide the elements which do not match, and unhide elements which do (for example add or remove the class “filtered”).