-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
39 lines (35 loc) · 1.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
document.onreadystatechange = updateClock()
function updateClock() {
const date = new Date()
document.getElementById("current-time-text").innerText = date.toLocaleTimeString([], { hourCycle: 'h23' })
const hour = date.getHours()
if (hour < 5 || hour >= 18) {
document.getElementById("time-greeting-text").innerText = "Good evening."
}
else if (hour < 12) {
document.getElementById("time-greeting-text").innerText = "Good morning."
}
else {
document.getElementById("time-greeting-text").innerText = "Good afternoon."
}
}
setInterval(updateClock, 1000)
function doSearch() {
const query = document.getElementById('search-input').value
switch (document.getElementById("search-engine-select").value) {
case 'google':
window.location.href = `https://www.google.com/search?q=${query}`
break;
case 'bing':
window.location.href = `https://www.bing.com/?q=${query}`
break;
case 'ddg':
window.location.href = `https://www.duckduckgo.com/?q=${query}`
}
}
const searchInput = document.getElementById("search-input")
searchInput.addEventListener("keypress", function onEvent(event) {
if (event.key === "Enter") {
document.getElementById("search-button").click();
}
});