Weather App

Developer
Size
2,957 Kb
Views
12,144

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 Previews

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 + " &#176;C"); $("#temperature").click(function() { if (tempSwitch === true) { $("#temperature").html(tempF + " &#176;F"); tempSwitch = false; } else { $("#temperature").html(tempC + " &#176;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')"); } }); });
});
Weather App - Script Codes
Weather App - Script Codes
Home Page Home
Developer Roksana
Username roksanaop
Uploaded November 22, 2022
Rating 3
Size 2,957 Kb
Views 12,144
Do you need developer help for Weather App?

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!

Roksana (roksanaop) Script Codes
Create amazing blog posts with AI!

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!