diff options
author | alyx <alyx@aleteoryx.me> | 2022-02-04 22:21:43 +0000 |
---|---|---|
committer | Aleteoryx <alyx@aleteoryx.me> | 2022-02-04 22:21:43 +0000 |
commit | 418e48e13cfd874de2677cde76227164cd00a005 (patch) | |
tree | 7a6ef68e326942e4426a62b30b5430a4743e5cc0 /script.js | |
parent | 59d5ade418fdb0c6fe2d0c100f0a32b4c2dacd32 (diff) | |
download | RRCUtils-418e48e13cfd874de2677cde76227164cd00a005.tar.gz RRCUtils-418e48e13cfd874de2677cde76227164cd00a005.tar.bz2 RRCUtils-418e48e13cfd874de2677cde76227164cd00a005.zip |
made the sorting of search results be based on closeness as opposed to alphabetical
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -10,14 +10,16 @@ const fusenameopts = { minMatchCharLength: 1, ignoreLocation: true, threshold: 0, - keys: ["ReadonlyName"] + keys: ["ReadonlyName"], + includeScore: true }; const fusedescopts = { isCaseSensitive: false, minMatchCharLength: 1, ignoreLocation: true, threshold: 0, - keys: ["Description"] + keys: ["Description"], + includeScore: true }; function genExplanation(name) { @@ -143,9 +145,12 @@ window.addEventListener("load", async (e) => { fuse.setCollection(content2.nodes); }); - var content = endOfPath ? fuseinuse.map(fuse => fuse.search(endOfPath).map(e => e.item)) : content2.nodes; - content = Array.from(new Set(content.flat())); - content.sort((a, b) => (a.ReadonlyName.toLowerCase() > b.ReadonlyName.toLowerCase()) ? 1 : -1); + var content = endOfPath ? (() => { + let m = fuseinuse.map(fuse => fuse.search(endOfPath)).flat() + m.sort((a,b) => a.score - b.score); + m = Array.from(new Set(m.map(e => e.item))); + return m; + })() : content2.nodes; //console.log(content2.nodes) content = content.map(el => { |