forked from mirrors/bookwyrm
Run prettier
This commit is contained in:
parent
4202498442
commit
60761b19ba
1 changed files with 38 additions and 39 deletions
|
@ -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
|
||||||
const newTrie = option;
|
.map((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: {
|
||||||
|
w: "AZW",
|
||||||
},
|
},
|
||||||
"z": {
|
|
||||||
"w": "AZW",
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"d": "Daisy",
|
d: "Daisy",
|
||||||
"e": "ePub",
|
e: "ePub",
|
||||||
"f": "FLAC",
|
f: "FLAC",
|
||||||
"h": "HTML",
|
h: "HTML",
|
||||||
"m": {
|
m: {
|
||||||
"4": {
|
4: {
|
||||||
"a": "M4A",
|
a: "M4A",
|
||||||
"b": "M4B",
|
b: "M4B",
|
||||||
},
|
},
|
||||||
"o": "MOBI",
|
o: "MOBI",
|
||||||
"p": "MP3",
|
p: "MP3",
|
||||||
},
|
},
|
||||||
"o": "OGG",
|
o: "OGG",
|
||||||
"p": {
|
p: {
|
||||||
"d": {
|
d: {
|
||||||
"f": "PDF",
|
f: "PDF",
|
||||||
},
|
},
|
||||||
"l": "Plaintext",
|
l: "Plaintext",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue