Removed and added variables

Removed useless variables and added a variable...
Added const/let to variable declaration...
This commit is contained in:
Carlos 2020-11-10 23:47:35 -03:00 committed by GitHub
parent 89506b4503
commit dff1d9a4d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,15 +3,17 @@ window.onload = function() {
}
function initSearchBar() {
document.getElementById("search-bar-input").value = ""
document.getElementById("search-bar-input").focus()
const searchBarInput = document.getElementById("search-bar-input")
searchBarInput.value = ""
searchBarInput.focus()
document.getElementById("search-bar-input").addEventListener("keypress", (event) => {
if (event.key != 'Enter') return
searchBarInput.addEventListener("keypress", (event) => {
if (event.key !== 'Enter') return
googleSearchUrl = "https://www.duckduckgo.com/?q="
otherThing = "&atb=v225-7&ia=web"
query = document.getElementById("search-bar-input").value.replace(/\ /g, "+")
document.location = googleSearchUrl + query + otherThing
const searchEnginer = "https://www.duckduckgo.com/?q="
const endQuery = "&atb=v225-7&ia=web"
document.location = searchEnginer + searchBarInput.value.replace(/\ /g, "+") + endQuery
})
}