Searchbox terminada ?
This commit is contained in:
@@ -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">
|
||||
|
||||
17
script.js
17
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()
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user