~cypheon/idris2-quickdocs

d239bea2dd6717eb2b598420bb2e67804b7201b5 — Johann Rudloff 1 year, 5 months ago 36f65fb
Some small fixes and code quality changes
1 files changed, 10 insertions(+), 4 deletions(-)

M app.js
M app.js => app.js +10 -4
@@ 5,6 5,7 @@ let cells = [];
let initialized = false;
let matched = [];
let selected = 0;
let matcher = 'namespace';

let pendingUpdate = null;



@@ 70,7 71,7 @@ function matchSubsequence(item, query) {
}

function matchNamespace(item, query) {
  const quoted = query.replaceAll(/[.+*\\()\[\]<>$^]/g, '\\$&');
  const quoted = query.replaceAll(/[.+*\\()[\]<>$^]/g, '\\$&');
  const reQuery = new RegExp(quoted.replaceAll('\\.', '.*\\.'));
  return reQuery.test(item[IDX_FULLNAME_LOWER]);
}


@@ 82,6 83,12 @@ function matchSimple(item, query) {
  return false;
}

const matchers = {
  'simple': matchSimple,
  'subsequence': matchSubsequence,
  'namespace': matchNamespace,
};

function openResult(linkTarget) {
  const iframe = document.querySelector('#content iframe');
  iframe.src = linkTarget;


@@ 101,8 108,6 @@ function clickResult(evt) {
  return false;
}

const matches = matchNamespace;

function searchKeyDown(evt) {
  if (evt.key === 'ArrowDown') {
    ++selected;


@@ 160,6 165,7 @@ function updateSearchResults(evt) {

  console.log(`search (${cells.length} / ${data.length}): `, query);
  const startTime = Number(new Date());
  const matches = matchers[matcher];

  for (let i = 0; i < data.length; ++i) {
    const entryMatches = matches(data[i], query);


@@ 217,7 223,7 @@ function init() {
    if (res.ok) {
      return res.json();
    } else {
      throw new Error("error loading index: " + e.status);
      throw new Error("error loading index: " + res.status);
    }
  }).then((index) => {
    data = index;