-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
28 lines (23 loc) · 917 Bytes
/
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
document.onreadystatechange = updateClock();
function updateClock() {
const date = new Date()
document.getElementById("current-time-text").innerText =
date.toLocaleTimeString([], { hour12: false }) + " - " + date.toDateString()
const hour = date.getHours()
}
setInterval(updateClock, 1000)
function doSearch() {
const query = document.getElementById('search-input').value
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();
}
})
function getWeatherData(city) {
fetch("https://wttr.in/" + city + "?format=%C+%c+%t+%w+%m")
.then(response => response.text())
.then(data => document.getElementById("weatherData").innerHTML = data)
}