Weather app v.2

Developer
Size
4,878 Kb
Views
28,336

How do I make an weather app v.2?

What is a weather app v.2? How do you make a weather app v.2? This script and codes were developed by Hantz Pierre on 07 September 2022, Wednesday.

Weather app v.2 Previews

Weather app v.2 - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>weather app v.2</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <title>Your Local Weather App</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/weather-icons/2.0.9/css/weather-icons.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<body> <div id="header" class="container text-center"> <h1>Local Weather</h1> <h2>Front End Dev | FreeCodeCamp</h2> </div> <div id="current-weather-wrapper"> <div id="temp"> <div id="degrees">100</div> <i id="icon"></i> <div class="column" id="description">Current Weather</div> <div id="location"></div> <div id="wind"></div> <button class="btn-5" id="unit"> ºC </button> </div> </div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="weatherapp.js"></script> </body> <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Weather app v.2 - Script Codes CSS Codes

html{
font-size: 10em;
}
header { text-align: center; display: block;
}
h2,
h1 {
}
body { font-family: 'Cabin', sans-serif; font-weight: bold; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; height: 100vh; width: 100vw;
}
#location{ font-size: 2em; margin: 0 0 0 0;
}
#temp { margin: 0 auto; text-align: center; font-size: 1em; text-shadow: 2px 4px 2px #333333;
}
#degrees { font-size: 5em;
}
#description { font-size: 1em;
}
#container { text-align: center; text-shadow: 1px 1px 1px #333333; border: 1px solid #ffffff; border-radius: 2%; padding: 10px 0px 0px 15px; background-color: rgba(147, 175, 196, .4); box-shadow: .2em .2em .2em #222222; max-width: 360px; height: 190px; margin: 0 auto;
}
#current-weather-wrapper{ padding: 1.43em; width: 57.142em; margin: 4em auto; border: 1px solid rgba(237, 255, 255, .6); border-radius: 1em; background-color: rgba(37, 76, 132, .32); -webkit-box-shadow: 0 0 0.4666em rgba(0, 0, 0, .6); -moz-box-shadow: 0 0 0.4666em rgba(0, 0, 0, .6); -o-box-shadow: 0 0 0.4666em rgba(0, 0, 0, .6); box-shadow: 0 0 0.4666em rgba(0, 0, 0, .6);
}
#wind{
padding-top: 20px;
padding-bottom: 10px;
}
input:focus { outline: 0 !important;
}
.button { margin: 10px auto 0px auto; width: 165px; height: 30px;
}
.sunny { background: url(https://67.media.tumblr.com/c8a81bb0221980c44ee57f947aa3c84d/tumblr_n8ctq1QY9f1ruulogo1_400.gif) no-repeat center center fixed; background-size: cover; color: rgb(0,0,0);
}
.cloudy { background: url(https://hd.unsplash.com/photo-1429734956993-8a9b0555e122) no-repeat center center fixed; background-size: cover; color: rgb(0,0,0);
}
.sprinkle { background: url(https://media.giphy.com/media/l0K7p42O2ynDTV3Pi/giphy.gif) no-repeat center center fixed; background-size: cover; color: rgb(255,255,255);
}
.rain { background: url(https://media.giphy.com/media/BJ7HNoh62K5nG/giphy.gif) no-repeat center center fixed; background-size: cover; color: rgb(30,20,250);
}
.haze { background: url(http://i1.wp.com/www.ecomena.org/wp-content/uploads/2015/04/sand-dust-storm.gif) no-repeat center center fixed; background-size: cover; color: rgb(255,255,255);
}
.showers { background: url(https://4.bp.blogspot.com/-YPmQcxA0eho/U0LbtD3YiVI/AAAAAAAABP8/B3UDPXFVQ1A/s1600/rain-fall-animation.gif) no-repeat center center fixed; background-size: cover; color: rgb(120,150,170);
}
.thunderstorm { background: url(https://media.giphy.com/media/rvdUftzA8567u/giphy.gif) no-repeat center center fixed; background-size: cover; color: rgb(250,240,50);
}
.gusts { background: url(http://rs854.pbsrc.com/albums/ab109/lacilu22/Landscapes%20Nature%20Animated/giphy-1.gif~c200) no-repeat center center fixed; background-size: cover; color: rgb(0,0,0);
}
.fog { background: url(https://i.kinja-img.com/gawker-media/image/upload/s--lOnyBfYq--/c_fit,fl_progressive,q_80,w_636/18smq7zu9xj6igif.gif) no-repeat center center fixed; background-size: cover; color: rgb(255,255,255);
}
.snow {
background: url(https://media.giphy.com/media/Yy26NRbpB9lDi/giphy.gif) no-repeat center center fixed; background-size: cover; color: rgb(0,0,0);
}
.wind { background: url(https://cdn2.scratch.mit.edu/get_image/user/11754206_90x90.png?v=1465331718.38) no-repeat center center fixed; background-size: cover; color: rgb(255,255,255);
}
.storm { background: url(https://d3rde5ck80dcsn.cloudfront.net/wp-content/uploads/2015/12/ezgif.com-optimize1.gif) no-repeat center center fixed; background-size: cover; color: rgb(130,215,255);
}
.tornado { background: url(https://media.giphy.com/media/UIbf99Ufh9LMY/giphy.gif) no-repeat center center fixed; background-size: cover; color: rgb(255,190,170);
}
.hurricane { background: url(http://ww2010.atmos.uiuc.edu/guides/mtr/hurr/stages/cane/gifs/home3.gif) no-repeat center center fixed; background-size: cover; color: rgb(20,250,220);
}
a { display: none;
}
.btn-5 { font-size: 2em; background-color: transparent; border-color: transparent;
}
.btn-5:hover { background-color: transparent; border-color: transparent; border: 1px solid; box-shadow: inset 0 0 20px rgba(255, 255, 255, .5), 0 0 20px rgba(255, 255, 255, .2); outline-color: rgba(255, 255, 255, 0); text-shadow: 1px 1px 2px #427388;
}
@media screen and (min-width: 320px){ #current-weather-wrapper{ width: 25em; } html{ font-size: 14px; }
}
@media screen and (min-width: 570px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 15px; }
}
@media screen and (min-width: 620px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 16px; }
}
@media screen and (min-width: 680px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 17px; }
}
@media screen and (min-width: 720px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 18px; }
}
@media screen and (min-width: 800px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 19px; }
}
@media screen and (min-width: 860px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 5em; }
}
@media screen and (min-width: 920px){ #current-weather-wrapper{ width: 35em; } html{ font-size: 5em; }
}
@media screen and (min-width: 1000px){ html{ font-size: 10em; }
}

Weather app v.2 - Script Codes JS Codes

$(document).ready(function(){ var location = "http://ip-api.com/json"; var apiURL = "http://api.openweathermap.org/data/2.5/weather?lat="; var appID = "&appid=33326ed68f6b699ecb62fa6ced1150c2" var units = "&units=metric"; // gets location $.getJSON(location, function(data){ var coord = data.lat + "&lon=" + data.lon; var city = data.city; var region = data.regionName; var country = data.country; //Grabing info from API url + coord + APPID + APIunits $.getJSON(apiURL + coord + appID + units, function (data){ var currentLocation = city + ", " + region + ", " + country; var temp = Math.round(data.main.temp); //Var for temperartue change converts from F to C var icon = convert_icon(data.weather[0].id); // weatherType is the weather description var weatherType = data.weather[0].description; var windSpeed = data.wind.speed; windSpeed = Math.floor((2.237*(windSpeed))); var metric = true; if (country == "United States") { metric = false; //United States is metric temp is converted from Kelvin temp = Math.round((data.main.temp * 9) / 5 + 32); } //Incorporating data into HTML $('body').removeClass().addClass(icon_to_class(icon)); $("#icon").removeClass().addClass(icon); $("#description").html(weatherType); $("#location").html(currentLocation); $("#degrees").html(temp); $("#unit").html("º" + assign_unit(metric)); $("#wind").html("Wind Speed: " + windSpeed + "mph"); }) })
}); //grabs windSpeed and adds MPH to wind speed
function convert_icon(id) { switch (id) { case 800: case 904: return "column wi wi-day-sunny"; case 801: case 802: case 803: case 804: return "column wi wi-day-cloudy"; case 300: case 301: case 302: case 310: case 311: case 313: case 321: case 500: case 501: case 901: case 906: return "column wi wi-day-sprinkle"; case 312: case 314: case 502: case 503: case 504: case 520: case 522: case 521: case 531: return "column wi wi-day-rain"; case 731: case 751: case 761: case 762: case 951: return "column wi wi-day-haze"; case 200: case 202: case 210: case 211: case 230: case 232: return "column wi wi-day-storm-showers"; case 201: case 212: case 221: case 231: return "column wi wi-day-thunderstorm"; case 903: case 905: case 952: case 953: case 954: case 955: return "column wi wi-cloudy-gusts"; case 701: case 711: case 721: case 741: return "column wi wi-day-fog"; case 600: case 601: case 602: case 620: case 621: return "column wi wi-day-snow"; case 956: case 957: case 958: case 969: return "column wi wi-strong-wind"; case 511: case 611: case 612: case 615: case 616: case 622: return "column wi wi-day-sleet-storm"; case 771: case 781: case 900: return "column wi wi-tornado"; case 902: case 960: case 961: case 962: return "column wi wi-hurricane"; default: return "column wi wi-day-sunny"; }
}
function icon_to_class(id) { switch(id) { case "column wi wi-day-sunny": return "sunny"; case "column wi wi-day-cloudy": return "cloudy"; case "column wi wi-day-sprinkle": return "sprinkle"; case "column wi wi-day-rain": return "rain"; case "column wi wi-day-haze": return "haze"; case "column wi wi-day-storm-showers": return "showers"; case "column wi wi-day-thunderstorm": return "thunderstorm"; case "column wi wi-cloudy-gusts": return "gusts"; case "column wi wi-day-fog": return "fog"; case "column wi wi-day-snow": return "snow"; case "column wi wi-strong-wind": return "wind"; case "column wi wi-day-sleet-storm": return "storm"; case "column wi wi-tornado": return "tornado"; case "column wi wi-hurricane": return "hurricane"; default: return "sunny"; }
}
function assign_unit(metric) { var unit_system = document.getElementById('unit').innerText if (metric === true) { unit_system.id = 'unit cel' return "C" } unit_system.id = 'unit fah' return "F"
}
$("#unit").on("click", function() { var originalTemp = document.getElementById('degrees').innerText; var originalSystem = document.getElementById('unit').innerText; if (originalSystem == "ºC") { $("#degrees").html(Math.round(((originalTemp * 9) / 5) + 32)); $("#unit").html("º" + assign_unit(false)); } else { $("#degrees").html(Math.round(((originalTemp - 32) * 5) / 9)); $("#unit").html("º" + assign_unit(true)); }
});
Weather app v.2 - Script Codes
Weather app v.2 - Script Codes
Home Page Home
Developer Hantz Pierre
Username universe360
Uploaded September 07, 2022
Rating 3
Size 4,878 Kb
Views 28,336
Do you need developer help for Weather app v.2?

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!

Hantz Pierre (universe360) Script Codes
Create amazing SEO content 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!