Run prettier

This commit is contained in:
Mouse Reeve 2022-01-10 16:55:30 -08:00
parent 4202498442
commit 60761b19ba
1 changed files with 38 additions and 39 deletions

View File

@ -1,5 +1,5 @@
(function() { (function () {
'use strict'; "use strict";
/** /**
* Suggest a completion as a user types * Suggest a completion as a user types
@ -30,7 +30,7 @@
suggestionsBox.innerHTML = ""; suggestionsBox.innerHTML = "";
// Populate suggestions box // Populate suggestions box
suggestions.forEach(suggestion => { suggestions.forEach((suggestion) => {
const suggestionItem = document.createElement("option"); const suggestionItem = document.createElement("option");
suggestionItem.textContent = suggestion; suggestionItem.textContent = suggestion;
@ -40,7 +40,7 @@
function getSuggestions(input, trie) { function getSuggestions(input, trie) {
// Follow the trie through the provided input // Follow the trie through the provided input
input.split("").forEach(letter => { input.split("").forEach((letter) => {
trie = trie[letter]; trie = trie[letter];
if (!trie) { if (!trie) {
@ -58,55 +58,54 @@
function searchTrie(trie) { function searchTrie(trie) {
const options = Object.values(trie); const options = Object.values(trie);
if (typeof trie == 'string') { if (typeof trie == "string") {
return [trie]; return [trie];
} }
return options.map(option => { return options
.map((option) => {
const newTrie = option; const newTrie = option;
if (typeof newTrie == 'string') { if (typeof newTrie == "string") {
return [newTrie]; return [newTrie];
} }
return searchTrie(newTrie); return searchTrie(newTrie);
}).reduce((prev, next) => prev.concat(next)); })
.reduce((prev, next) => prev.concat(next));
} }
document document.querySelectorAll("[data-autocomplete]").forEach((input) => {
.querySelectorAll('[data-autocomplete]') input.addEventListener("input", autocomplete);
.forEach(input => {
input.addEventListener('input', autocomplete);
}); });
})(); })();
const mimetypeTrie = { const mimetypeTrie = {
"a": { a: {
"a": { a: {
"c": "AAC", c: "AAC",
}, },
"z": { z: {
"w": "AZW", w: "AZW",
}
}, },
"d": "Daisy",
"e": "ePub",
"f": "FLAC",
"h": "HTML",
"m": {
"4": {
"a": "M4A",
"b": "M4B",
}, },
"o": "MOBI", d: "Daisy",
"p": "MP3", e: "ePub",
f: "FLAC",
h: "HTML",
m: {
4: {
a: "M4A",
b: "M4B",
}, },
"o": "OGG", o: "MOBI",
"p": { p: "MP3",
"d": {
"f": "PDF",
}, },
"l": "Plaintext", o: "OGG",
p: {
d: {
f: "PDF",
},
l: "Plaintext",
}, },
}; };