Weather App
How do I make an weather app?
What is a weather app? How do you make a weather app? This script and codes were developed by Roksana on 22 November 2022, Tuesday.
Weather App - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Weather App</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!DOCTYPE HTML>
<html lang="en">
<head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <title>Exercise - Show the Local Weather</title> <link rel="stylesheet" href="main.css" type="text/css" /> <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body> <div class="background"> <header class="header"> <h1>Local Weather App</h1> <h2>Free Code Camp</h2> </header> <div class="weather-box"> <div class="weather-text" id = "location"></div> <div class="weather-text" id = "temperature"></div> <div class="weather-text" id = "weather-conditions"></div> </div> <footer> <p>by <a href="#">Roksana</a></p> </footer> </div> <script src="main.js"></script>
</body> <script src="js/index.js"></script>
</body>
</html>
Weather App - Script Codes CSS Codes
html { font-size: 62.5%; margin: 0; padding: 0;
}
body { margin: 0; padding: 0; font-family: 'Raleway', sans-serif; font-size: 3rem; color: #FFFFFF; background-position: 50%; background-repeat: no-repeat; background-size: cover;
}
.header { width: 100%; text-align: center; text-shadow: 0 0 5px #00CCCC;
}
.weather-box { width: 40%; padding: 50px; margin: 0; margin: auto; text-align: center; color: #00CCCC; border-radius: 5px; font-size: 2.8rem;
}
.weather-text { width: 70%; padding: 10px; margin: 10px auto; text-align: center; background-color: #FFFFFF; color: #00CCCC; border-radius: 5px; font-size: 2.8rem; font-weight: 500;
}
#temperature:hover { opacity: 0.8; cursor: pointer;
}
footer { margin: auto; text-align: center; color: #FFFFFF; font-size: 1.8rem; text-shadow: 0 0 1px #00CCCC;
}
footer a { text-decoration: none; color: #FFFFFF;
}
Weather App - Script Codes JS Codes
$(document).ready(function() { $.getJSON("http://ip-api.com/json", function(data) { var lat = data.lat; var long = data.lon; var api = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + long + "&appid=432bdff2aed845e2b011b247bbeec4d5"; $.getJSON(api, function(weatherData){ var city = weatherData.name; var country = weatherData.sys.country; var tempK = weatherData.main.temp; var tempF = ((tempK) * (9/5) - 459.67).toFixed(1); var tempC = ((tempF - 32) * (5/9)).toFixed(1); var tempSwitch = true; var weatherConditions = weatherData.weather[0].main; $("#location").html(city + ", " + country); $("#temperature").html(tempC + " °C"); $("#temperature").click(function() { if (tempSwitch === true) { $("#temperature").html(tempF + " °F"); tempSwitch = false; } else { $("#temperature").html(tempC + " °C"); tempSwitch = true; } }); $("#weather-conditions").html(weatherConditions); switch (weatherConditions.toLowerCase()) { case "clear": $("body").css("background-image", "url('http://www.lanrensucai.com/uploadfile/2013/1224/20131224111710333.jpg')"); break; case "clouds": $("body").css("background-image", "url('https://mryanhouse.files.wordpress.com/2014/04/atmosphere-clouds.jpg')"); break; case "drizzle": $("body").css("background-image", "url('https://www.metoffice.gov.uk/binaries/content/gallery/mohippo/media/image/d/light_rain.jpg')"); break; case "rain": $("body").css("background-image", "url('https://www.ibiza2day.com/wp-content/uploads/2015/03/rain.jpg')"); break; case "snow": $("body").css("background-image", "url('http://decibel.fi.muni.cz/models/cinema2014/x390623/1/tex/snowing-sky-6.jpg')"); break; case "thunderstorm": $("body").css("background-image", "url('http://www.atwillett.com/images/lightning_blacketsridge2008%20copy.jpg')"); break; default: $("body").css("background-image", "url('https://crystalseye.files.wordpress.com/2011/08/dsc_0724.jpg')"); } }); });
});
Developer | Roksana |
Username | roksanaop |
Uploaded | November 22, 2022 |
Rating | 3 |
Size | 2,957 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Built a Tribute Page | 3,726 Kb |
Use the Twitchtv JSON API | 3,561 Kb |
Exercise - Build a Random Quote Machine | 4,604 Kb |
Build a JavaScript Calculator | 2,903 Kb |
Exercise - Build a Tribute Page | 5,463 Kb |
Build a Tic Tac Toe Game | 3,883 Kb |
Build a Wikipedia Viewer - FCC | 2,910 Kb |
Image Processing | 3,788 Kb |
Build a Pomodoro Clock | 3,419 Kb |
Build a Simon Game | 4,017 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Search Box in Content Moves to Fixed Header | Chriscoyier | 2,768 Kb |
Colorful Sliders | Chanrith | 1,246 Kb |
A Pen by Kenny Mark | Kennymark | 5,574 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 Kb |
Hard-Stop Gradients | Mackdoyle | 2,288 Kb |
Board Site | IndianaLuft | 10,542 Kb |
Direction-icon | Alexandremasy | 3,323 Kb |
Starting out with Ember.JS | Cfleschhut | 4,808 Kb |
Mapbox Directions with geolocation tracking | Pollardld | 5,827 Kb |
V.35 The Monolith Update - Hero Release Notes | Jordan | 12,045 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!