diff --git a/index.html b/index.html index be7c180..e0bdb91 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@
diff --git a/script.js b/script.js index 467844c..17a8cbf 100644 --- a/script.js +++ b/script.js @@ -188,7 +188,24 @@ const photos = new function() { } } +const search = new function () { + this.search_bar = document.getElementById('search-input') + + this.submit_search = (query) => { + const encoded = encodeURIComponent(query) + window.location.href = `https://www.duckduckgo.com/?q=${encoded}` + } + + this.on_load = () => { + this.search_bar.addEventListener('keydown', (e) => { + if(e.key === 'Enter' && this.search_bar.value.length !== 0) + this.submit_search(this.search_bar.value) + }) + } +} + window.addEventListener('load', () => { currency.on_load() photos.on_load() + search.on_load() }); diff --git a/styles.css b/styles.css index 8137074..8dca383 100644 --- a/styles.css +++ b/styles.css @@ -3,7 +3,7 @@ */ * { - font-family: sans; + font-family: sans-serif; } .container { @@ -149,7 +149,7 @@ height: 5em; } -#search-box .search-box { +#search-input{ font-size: 1.5em; font-weight: 600;