-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.html
273 lines (233 loc) · 7.25 KB
/
weather.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<!DOCTYPE html>
<html lang="en">
<head>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
#menu__bar a {
float: left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
#menu__bar {
/* margin-top: -8px;
padding-top: 0px;
padding-bottom: 0px;
margin-bottom: 0px; */
overflow: hidden;
background-color: #333;
font-family: 'Roboto', sans-serif;
width: 100%;
}
#menu__bar a:hover {
background-color: #ddd;
color: black;
}
#menu__bar a.active {
background-color: #4CAF50;
color: white;
}
form input {
background-color: black;
text-align: center;
border-radius: 50px;
padding: 15px 250px;
margin-top: 20px;
color: white;
}
form :placeholder-shown {
color: white;
}
form {
text-align: center;
}
/* .footer{
background-color: #333333;
color: white;
padding-bottom: 20px;
text-align: center;
padding-top: 20px;
position: fixed;
margin-bottom: 20px;
padding-bottom: 80px;
} */
/* #temp_form{
background-color: red;
padding-bottom: 20px;
height: 500px;
} */
#btn1 {
margin-left: -80px;
border-radius: 100px;
background-color: #3399FF;
padding: 15px 16px;
cursor: pointer;
}
.date {
width: 33%;
height: 40px;
background-color: #202020;
margin: auto;
margin-top: 60px;
color: white;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
padding-top: 10px;
display: flex;
justify-content: space-around;
border-bottom: 2px solid grey;
}
.output {
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
width: 33%;
height: 220px;
background-color: #202020;
margin: auto;
margin-bottom: 330px;
padding-top: 10px;
color: white;
}
#xyz {
font: 300;
font-size: 25px;
padding-bottom: 28px;
padding-top: 28px;
}
#demo1 {
font: 300;
font-size: 25px;
}
/* #demo {
color: white;
padding-top: 20px;
} */
@media (max-width: 1176px) and (min-width: 670px) {
.output {
width: 50%;
}
.date{
width: 50%;
}
}
@media (max-width: 714px) and (min-width: 507px) {
.output {
width: 65%;
}
.date{
width: 65%;
}
form input {
background-color:black;
text-align: center;
border-radius: 50px;
padding: 15px 120px;
margin-top: 20px;
color: white;
}
}
@media (max-width: 507px) and (min-width: 300px){
.output {
width: 65%;
}
.date{
width: 65%;
}
form input {
background-color:black;
text-align: center;
border-radius: 50px;
padding: 15px 60px;
margin-top: 20px;
color: white;
}
}
</style>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather page</title>
<!-- <link rel="stylesheet" href="./home.css"> -->
<link rel="stylesheet" href="./weather.css">
</head>
<body>
<div class="full">
<div id="menu__bar">
<a href="#" class="active">Weather</a>
<a href="/">Home</a>
<a href="/weather">Weather</a>
<a href="/about">About</a>
</div>
<form id="temp_form">
<div class="wrapper">
<input type="text" placeholder="Enter City Name" id="cityname">
<button id="btn1" type="submit" onclick="myFunc()">Submit</button>
</div>
<div class="date">
<p id="c_date"></p>
<p id="c_day"></p>
</div>
<div class="output">
<p id="xyz">Your Output will be here</p>
<p id="demo1"></p>
<!-- <p id="icons">Yeah</p> -->
</div>
<!-- <div class="footer">
<p>Created with ❤ by Nevil Saspara</p>
</div> -->
</div>
</body>
<script>
var today = new Date();
var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
document.getElementById("c_date").innerHTML = date;
var d = new Date();
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
var n = weekday[d.getDay()];
document.getElementById("c_day").innerHTML = n;
function myFunc() {
//stop to reloading page
event.preventDefault();
// storing input data in variable
var a = document.getElementById("cityname").value;
// checking on console/Alert
// console.log(a);
// alert(a);
// API Url
let url = `https://api.openweathermap.org/data/2.5/weather?q=${a}&appid=b4fb58dc4f3ab576a9822d894dc586f2&units=metric`;
//checking URL in console.log/Alert
// console.log(url);
// alert(url);
//fetch function
fetch(url).then((apidata) => {
// console.log(apidata);
return apidata.json();
}).then((actualdata) => {
//checking data on console.log
// console.log(actualdata);
// console.log(actualdata.name);
// console.log(actualdata.weather[0].main);
let yup = `${actualdata.main.temp}° C`;
var hm = actualdata.name + "," + actualdata.sys.country;
// document.getElementById("xyz").innerHTML = actualdata.name;
document.getElementById("xyz").innerHTML = hm;
// document.getElementById("demo1").innerHTML =actualdata.main.temp;
document.getElementById("demo1").innerHTML = yup;
// document.getElementById("icons").innerHTML = weather[0].icon;
})
}
</script>
</html>