-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (25 loc) · 903 Bytes
/
index.js
File metadata and controls
30 lines (25 loc) · 903 Bytes
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
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")
.then((response) => response.text())
.then((data) => (document.getElementById("weatherData").innerHTML = data));
}