Commit 563d4cf7 authored by Henk Verlinde's avatar Henk Verlinde
Browse files

Merge branch 'master' of github.com:h-enk/doks

parents 476a8b49 abb93d71
Loading
Loading
Loading
Loading

.github/FUNDING.yml

0 → 100644
+12 −0
Original line number Diff line number Diff line
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: doks # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+21 −24
Original line number Diff line number Diff line
@@ -117,39 +117,36 @@ Source:
  suggestions.addEventListener('click', accept_suggestion, true);

  function show_results(){
    const maxResult = 5;

    var value = this.value;
    var results = index.search(value, { limit: 5, index: ["content"], enrich: true });
    var entry, childs = suggestions.childNodes;
    var i = 0, len = results.length;
    var results = index.search(value, {limit: maxResult, enrich: true});

    suggestions.classList.remove('d-none');
    suggestions.innerHTML = "";

    results.forEach(function(results) {
    //flatSearch now returns results for each index field. create a single list
    const flatResults = {}; //keyed by href to dedupe results
    results.forEach(result=>{
        result.result.forEach(r=>{
          flatResults[r.doc.href] = r.doc;
        });
    });

      entry = document.createElement('div');
    //construct a list of suggestions list
    for(const href in flatResults) {
        const doc = flatResults[href];

        const entry = document.createElement('div');
        entry.innerHTML = '<a href><span></span><span></span></a>';

      a = entry.querySelector('a'),
      t = entry.querySelector('span:first-child'),
      d = entry.querySelector('span:nth-child(2)');

      // console.log(results);

      a.href = results.result[i].doc.href;
      t.textContent = results.result[i].doc.title;
      d.textContent = results.result[i].doc.description;
        entry.querySelector('a').href = href;
        entry.querySelector('span:first-child').textContent = doc.title;
        entry.querySelector('span:nth-child(2)').textContent = doc.description;

        suggestions.appendChild(entry);

    });

    while(childs.length > len){

        suggestions.removeChild(childs[i])
        if(suggestions.childElementCount == maxResult) break;
    }

  }

  function accept_suggestion(){