Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any possibility to add a search engine? #13

Open
alebulo opened this issue Sep 1, 2021 · 5 comments
Open

Is there any possibility to add a search engine? #13

alebulo opened this issue Sep 1, 2021 · 5 comments

Comments

@alebulo
Copy link

alebulo commented Sep 1, 2021

The library that I made from your template, which is perfect, works great, but I have more than 14000 titles and it is tedious to search by category, how do I have them arranged ... is there the possibility of adding a search engine?

@tim-elmer
Copy link
Contributor

It's not impossible, but might be outside the scope of the project.

The main question is what are you interested in searching on and in? Filenames are easy, but if you are looking for a tagging system, things get more complicated (and more expensive). Additionally, if we are just searching the current directory, that's much easier (and cheaper) than searching the whole indexed directory, as we would need to either recursively index and search the whole directory on the fly, or build an indexing database, which is definitely out of scope.

@lorenzos
Copy link
Owner

lorenzos commented Sep 1, 2021

I agree everything @tim-elmer said. If you @alebulo just need a quick way to search filenames on the fly (a-la CTRL+F), you could try implementing a basic (but I guess inefficient) client-side filter in JS, that scans through the plain DOM Minixed already created and hides non-matching entries...

@tim-elmer
Copy link
Contributor

tim-elmer commented Sep 1, 2021

You could also relatively easily modify your own version of Minixed to return an index of pattern-matched results in the current directory if you want it done server-side, but you'll need to know/learn some PHP.

@alebulo
Copy link
Author

alebulo commented Sep 2, 2021

thank you for all guys!!!

@wilbert-vb
Copy link

It turns out that a local search script is a whole lot simpler in a table as opposed to the current unordered list.

Here is an example for a table:

   <script>
      $(document).ready(function () {
        $("#s").on("keyup", function () {
          var value = $(this).val().toLowerCase();
          $("#list tr").filter(function () {
            $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
          });
        });
      });
    </script>

Here is an example for a list:

window.addEventListener("load", () => {
  // (A) GET HTML ELEMENTS
  var filter = document.getElementById("the-filter"), // search box
      list = document.querySelectorAll("#the-list li"); // all list items
 
  // (B) ATTACH KEY UP LISTENER TO SEARCH BOX
  filter.onkeyup = () => {
    // (B1) GET CURRENT SEARCH TERM
    let search = filter.value.toLowerCase();
 
    // (B2) LOOP THROUGH LIST ITEMS - ONLY SHOW THOSE THAT MATCH SEARCH
    for (let i of list) {
      let item = i.innerHTML.toLowerCase();
      if (item.indexOf(search) == -1) { i.classList.add("hide"); }
      else { i.classList.remove("hide"); }
    }
  };
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants