diff options
Diffstat (limited to 'assets/script.js')
-rw-r--r-- | assets/script.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/assets/script.js b/assets/script.js index 34c386e..6d9e476 100644 --- a/assets/script.js +++ b/assets/script.js @@ -1,7 +1,7 @@ const searchInput = document.getElementById('search'); const suggestionsDiv = document.getElementById('suggestions'); -(async function(){ +async function enableAutocomplete() { const res = await fetch('/laws.json'); const laws = await res.json(); searchInput.addEventListener('input', (e) => { @@ -48,4 +48,7 @@ const suggestionsDiv = document.getElementById('suggestions'); suggestionsDiv.replaceChildren(...suggestions); }); -})(); +} + +if ('json' in searchInput.dataset) + enableAutocomplete();
\ No newline at end of file |