html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather App</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="weather-app" id="weatherApp">
<h1>US Weather App</h1>
<!-- State Selection -->
<div class="state-select">
<label for="state">Select State:</label>
<select id="state">
<option value="">Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
Enter to Rename, Shift+Enter to Preview
css
css
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
/* style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #e0f7fa;
}
/* Loading Screen Styles */
.loading-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #0288d1;
color: #fff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
}
.spinner {
Enter to Rename, Shift+Enter to Preview
js
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.addEventListener("DOMContentLoaded", () => {
// Ensure the loading screen is hidden initially (if it's in use)
document.getElementById("loadingScreen")?.style.display = "none";
document.getElementById("weatherApp").style.display = "block";
});
function fetchWeather() {
const state = document.getElementById("state").value;
if (!state) {
alert("Please select a state.");
return;
}
// Hardcoded fake temperatures for each state
const stateTemperatures = {
AL: "75°F",
AK: "40°F",
AZ: "85°F",
AR: "78°F",
CA: "70°F",
CO: "65°F",
CT: "60°F",
DE: "68°F",
FL: "80°F",
GA: "77°F",
HI: "85°F",
ID: "55°F",
IL: "65°F",
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run