-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomework_week1.html
173 lines (153 loc) · 5.19 KB
/
homework_week1.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Weather App</title>
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f3f3;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-image: url('https://source.unsplash.com/a-grassy-field-with-power-lines-in-the-distance-VZNMdtbkQ3o');
background-size: cover;
background-position: center;
color: #000000;
}
h1 {
font-size: 3rem;
line-height: 1.2;
text-align: center;
margin-bottom: 10px;
}
h1 span {
display: block;
font-size: 1.5rem;
}
h2 {
font-size: 2.5rem;
margin: 0;
}
h2 strong {
font-weight: bold;
font-size: 2rem;
margin-left: 5px;
}
ul {
padding: 0;
list-style: none;
display: flex;
justify-content: center;
margin: 20px 0;
}
li {
text-align: center;
padding: 10px;
border-radius: 10px;
transition: background 0.3s ease;
margin: 0 10px;
background: rgba(255, 254, 254, 0.2);
backdrop-filter: blur(5px);
}
li:hover {
background: rgba(5, 0, 0, 0.4);
}
p {
font-size: 1.2rem;
opacity: 0.8;
text-align: center;
margin-top: 10px;
}
button {
margin: 20px auto;
border: 1px solid #fefdf8;
background: none;
color: #080808;
font-size: 1rem;
line-height: 1.5;
padding: 10px 20px;
border-radius: 30px;
transition: all 200ms ease;
cursor: pointer;
}
button:hover {
background: #e7e3e3;
color: #90a9ce;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
p {
animation: fadeIn 2s ease;
}
</style>
</head>
<body>
<h1 id="weatherInfo">
😄<br />Currently 21°C in Kaduna
</h1>
<h2>13° / <strong>23°</strong></h2>
<ul>
<li>
<h3>
🌧Tomorrow
</h3>
<p>10° / <strong>22°</strong></p>
</li>
<li>
<h3>
🌥 Saturday
</h3>
<p>15° / <strong>17°</strong></p>
</li>
<li>
<h3>
☀️ Sunday
</h3>
<p>25° / <strong>28°</strong></p>
</li>
</ul>
<button onclick="changeCity()">
Change city
</button>
<p>
Coded by Nafisa Lawal Idris
</p>
<script>
function changeCity() {
// Prompt for city input
var newCity = prompt("Enter the city:");
if (newCity) { // Check if the user provided a city
// Prompt for temperature input
var newTemperature = prompt("Enter the current temperature:");
// Update weather information
var weatherInfo = document.getElementById("weatherInfo");
if (newTemperature < 0) {
weatherInfo.innerHTML = `☹️<br />Currently ${newTemperature}°C in ${newCity}`;
} else {
weatherInfo.innerHTML = `😄<br />Currently ${newTemperature}°C in ${newCity}`;
}
// Update other weather details (you can customize this based on your requirements)
document.querySelector("h2").innerHTML = `${Math.floor(Math.random() * 10) + 10}° / <strong>${Math.floor(Math.random() * 10) + 20}°</strong>`;
document.querySelectorAll("li h3")[0].innerHTML = `🌧 Random Weather Tomorrow`;
document.querySelectorAll("li p")[0].innerHTML = `${Math.floor(Math.random() * 10) + 10}° / <strong>${Math.floor(Math.random() * 10) + 20}°</strong>`;
document.querySelectorAll("li h3")[1].innerHTML = `🌥 Random Weather Saturday`;
document.querySelectorAll("li p")[1].innerHTML = `${Math.floor(Math.random() * 10) + 15}° / <strong>${Math.floor(Math.random() * 10) + 17}°</strong>`;
document.querySelectorAll("li h3")[2].innerHTML = `☀️ Random Weather Sunday`;
document.querySelectorAll("li p")[2].innerHTML = `${Math.floor(Math.random() * 10) + 25}° / <strong>${Math.floor(Math.random() * 10) + 28}°</strong>`;
}
}
</script>
</body>
</html>