This commit is contained in:
deepjyoti30
2020-05-12 19:21:50 +05:30
commit 2953006982
4 changed files with 131 additions and 0 deletions

24
js/main.js Normal file
View File

@@ -0,0 +1,24 @@
window.onload = function() {
this.initBody()
}
searchBarId = "search-bar-input"
function initBody() {
/**
* Function called when the body is loaded.
*
* Do everything like adding an event listener to
* other things.
*/
// Clear the search bar on load, just in case
$("#" + searchBarId).val("")
$("#" + searchBarId).on("keypress", (event) => {
if (event.which != 13) return
// Open google with the search results.
googleSearchUrl = "https://www.google.com/search?q="
query = document.getElementById(searchBarId).value.replace(/\ /g, "+")
document.location = googleSearchUrl + query
})
}