-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
130 lines (96 loc) · 3.89 KB
/
index.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="app.js"></script>
<title>Weather App</title>
</head>
<body>
<header>
<h1><a href="https://www.eshank.biz/#" target="_blank">Eshank Tyagi</a></h1>
<a href="https://www.eshank.biz/#contact-section" target="_blank">Contact Me</a>
</header>
<main>
<div id="cityInput">
<form onsubmit="return runFun()" id="cityInput">
<input type="text" id="getMyInput" name="city" placeholder="Enter your city...">
</form>
<div >
<input id="searchLogo" type="image" src="images/search.png" onclick="searchWeather()" alt="search icon">
<h3>Search</h3>
</div>
</div>
<div id="weatherDisplay">
<h2 id="currentTemperature"> 0°C </h2>
<h3 id="searchedCity"> No Input </h3>
<div id="otherDetails">
<div id="otherDetailsInside">
<div id = "humidity" class = "otherDetail">
<div class = "detailContainer">
<img src="images/humidity.png" alt="humidity icon">
<h3 id="humidityValue"> 0.0% </h3>
</div>
<h4> Humidity</h4>
</div>
<div id="wind" class = "otherDetail">
<div class = "detailContainer">
<img src="images/wind.png" alt="wind icon">
<h3 id="windValue"> 0.0km/h </h3>
</div>
<h4> Wind</h4>
</div>
<div id = "pressure" class = "otherDetail">
<div class = "detailContainer">
<img src="images/pressure.png" alt="pressure icon">
<h3 id="pressureValue"> 0.0hPa </h3>
</div>
<h4> Pressure</h4>
</div>
</div>
</div>
</div>
</main>
</body>
</html>
<!-- <main>
<form action="">
<input type="text" name="city" placeholder="City Name">
<button type="submit">Submit</button>
</form>
<div id=""></div>
<div id="weather-info"></div>
</main> -->
<!-- <script>
// Fetch weather data from API and update the weather-info div
function fetchWeatherData(city) {
// Make API request and handle the response
// Replace the API_URL with the actual API endpoint
fetch(`API_URL?city=${city}`)
.then(response => response.json())
.then(data => {
// Update the weather-info div with the weather data
const weatherInfo = document.getElementById('weather-info');
weatherInfo.innerHTML = `
<h2>${data.city}</h2>
<p>Temperature: ${data.temperature}°C</p>
<p>Humidity: ${data.humidity}%</p>
<p>Conditions: ${data.conditions}</p>
`;
})
.catch(error => {
console.error('Error fetching weather data:', error);
});
}
// Handle form submission
const form = document.querySelector('form');
form.addEventListener('submit', function(event) {
event.preventDefault();
const cityInput = document.querySelector('input[name="city"]');
const city = cityInput.value.trim();
if (city) {
fetchWeatherData(city);
}
});
</script> -->