Searchbox terminada ?

This commit is contained in:
2020-11-21 02:55:02 -03:00
parent 9b26927909
commit e11ed6cd05
3 changed files with 20 additions and 3 deletions

View File

@@ -19,7 +19,7 @@
</div>
<div id="search-box" class="box">
<input class="search-box" name="search" placeholder="Busqueda"/>
<input id="search-input" name="search" placeholder="Buscar en DuckDuckGo"/>
</div>
<div id="weather-box" class="box">

View File

@@ -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()
});

View File

@@ -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;