NavigateX/static/SCRIPTS/Search.js

35 lines
966 B
JavaScript

function searchGoogle() {
const searchText = document.getElementById("searchBox").value;
if (searchText.trim() !== "") {
const googleURL = `https://www.google.com/search?q=${encodeURIComponent(searchText)}`;
window.location.href = googleURL;
}
}
document.getElementById("searchBox").addEventListener("keyup", function(event) {
if (event.key === "Enter") {
searchGoogle();
}
});
document.querySelector(".search-button").addEventListener("click", function() {
searchGoogle();
});
function clearSearchBox() {
document.getElementById("searchBox" +
"" +
"" +
"").value = '';
searchBox.style.backgroundColor = '#2a1212'
searchBox.style.border = '2px solid #ff0000';
searchBox.style.boxShadow = '0 0 5px #ff0000';
setTimeout(function() {
searchBox.style.backgroundColor = '';
searchBox.style.border = '';
searchBox.style.boxShadow = '';
}, 350);
}