FreeCodeCamp : Show the Local Weather
How do I make an freecodecamp : show the local weather?
What is a freecodecamp : show the local weather? How do you make a freecodecamp : show the local weather? This script and codes were developed by Markku Lehmonen on 30 November 2022, Wednesday.
FreeCodeCamp : Show the Local Weather - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>FreeCodeCamp : Show the Local Weather</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
<link rel='stylesheet prefetch' href='https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="app container testRender centerStuff"> <div class="panel panel-default testRender"> <div class="panel-heading"><h4 class="panel-title text-center">WeatherApp</h4></div> <div class="panel-body"> <div class="row testRender"> <div class="col-xs-6 testRender"> <div class="weatherIcon center-block testRender"> <div class="weatherIconBase"> <div id="sunny" class="iconComponent"> <div class="mainlet"><i class="sun fa fa-sun-o" aria-hidden="true"></i></div> </div> <div id="broken" class="iconComponent"> <div class="mainlet"><i class="fa fa-cloud" aria-hidden="true"></i></div> <div class="sideletCorner"><i class="sun fa fa-sun-o" aria-hidden="true"></i></div> </div> <div id="cloudy" class="iconComponent"> <div class="mainlet"><i class="fa fa-cloud" aria-hidden="true"></i></div> </div> <div id="rain" class="iconComponent"> <div class="mainlet"><i class="fa fa-cloud" aria-hidden="true"></i></div> <div class="sideletBottom"> <i class="dropLeft fa fa-tint" aria-hidden="true"></i> <i class="dropCenter fa fa-tint" aria-hidden="true"></i> <i class="dropRight fa fa-tint" aria-hidden="true"></i> </div> </div> <div id="thunderstorm" class="iconComponent"> <div class="mainlet"><i class="fa fa-cloud" aria-hidden="true"></i></div> <div class="sideletBottom"><i class="thunder fa fa-bolt" aria-hidden="true"></i></div> <div class="sideletBottom"> <i class="dropLeft fa fa-tint" aria-hidden="true"></i> <i class="dropCenter fa fa-tint" aria-hidden="true"></i> <i class="dropRight fa fa-tint" aria-hidden="true"></i> </div> </div> <div id="snowfall" class="iconComponent"> <div class="mainlet"><i class="fa fa-cloud" aria-hidden="true"></i></div> <div class="sideletBottom"> <i class="dropLeft fa fa-snowflake-o" aria-hidden="true"></i> <i class="dropCenter fa fa-snowflake-o" aria-hidden="true"></i> <i class="dropRight fa fa-snowflake-o" aria-hidden="true"></i> </div> </div> </div> </div> </div> <div class="col-xs-6 testRender"> <div class="weatherInfo"> <h3><span id="city">[City]</span>, <span id="country"><small>[Country]</small></span></h3> <h1><span id="weather">[Weather]</span></h1> <h2><span id="temperature">[dd]</span> <span id="unit">°C</span></h2> </div> </div> </div> </div> <div class="panel-footer"> <div class="row"> <div class="col-xs-10"> <div class="input-group"> <input id="apiKey" type="text" class="form-control" placeholder="API Key"> <span class="input-group-btn"> <button id="goButton" class="btn btn-default" type="button">Go!</button> </span> </div> </div> <div class="col-xs-2"> <div class="input-group"> <input id="toggleButton" type="checkbox" data-toggle="toggle" data-on="°C" data-off="°F" data-onstyle="default" checked disabled> </div> </div> </div> <div class="row"> <div class="col-xs=12 text-center"> <p class="infoLabel"><small>The usage of this app needs an API key, get it from<a href="http://openweathermap.org/appid" target="_blank"> here</a>!</small></p> </div> </div> </div> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js'></script>
<script src='https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
FreeCodeCamp : Show the Local Weather - Script Codes CSS Codes
/** DEV STUFF **/
.testRender { /*border:1px solid red;*/ /*background-color:rgba(255,255,255,0.3); color:rgba(255,255,255,0.8);*/}
.testBlock {border:1px solid red; width:100px; height:50px;}
/** APP STUFF **/
body {background-color:#eeeeee;}
.app {width:520px;} /* QUICK FIX MARGIN */
.infoLabel {margin-top:20px;}
.centerStuff { min-height:100%; min-height:100vh; display:flex; align-items:center; /*justify-content:center;*/ /* !This centers horizontally too! */
}
/** WEATHER ICON COMPONENT **/
.weatherIcon {width:170px; height:170px;}
.weatherIconBase {width:100%; height:100%; border: 5px solid #bbbbbb; border-radius:20px; text-align:center;}
.iconComponent {position:relative; color:#bbbbbb;}
.mainlet {position:absolute; top:15px; left:18px; height:125px; width:125px; font-size:90px; z-index:2;}
.sideletCorner {position:absolute; top:15px; left:71px; height:75px; width:75px; font-size:57px; z-index:1;}
.sideletBottom {position:absolute; top:73px; left:7px; height:75px; width:150px; font-size:57px;}
.sun {color:#dddddd;}
.thunder {position:relative; top:-20px; right:0px; transform: rotate(26deg); color:#cccccc; z-index:3;}
.dropLeft {position:relative; top:-2px; left:10px; font-size: 29px; color:#cccccc; z-index:3;}
.dropCenter {position:relative; top:8px; right:0px; font-size: 44px; color:#cccccc; z-index:3;}
.dropRight {position:relative; top:-10px; right:14px; font-size: 21px; color:#cccccc; z-index:3;}
/** WEATHER INFO COMPONENT **/
.weatherInfo { color:#888888; }
FreeCodeCamp : Show the Local Weather - Script Codes JS Codes
$(document).ready(function() { hideWeatherIcon(); // Bind Functions $("#goButton").on("click", function() { getWeather("&units=metric"); }); $("#toggleButton").change(toggleTemperature);
});
function getWeather(units) { $.getJSON("//ipinfo.io", function(locationData){ $("#city").text(locationData.city); $("#country").text(locationData.country); var location = locationData.city + "," + locationData.country; var urlBase = "//api.openweathermap.org/data/2.5/weather?q="; var appId ="&APPID=" + $("#apiKey").val(); //var units ="&units=metric"; var url = urlBase + location + appId + units; $.getJSON(url, function(weatherData) { $("#temperature").text(Math.round(weatherData.main.temp)); $("#weather").text(weatherData.weather[0].main); setWeatherIcon(weatherData.weather[0].main); $("#toggleButton").bootstrapToggle("enable"); if(units === "&units=metric") { $("#unit").text("°C"); } else if(units === "&units=imperial") { $("#unit").text("°F"); } }); });
}
function hideWeatherIcon() { $("#sunny").hide(); $("#broken").hide(); $("#cloudy").hide(); $("#rain").hide(); $("#snowfall").hide(); $("#thunderstorm").hide();
}
function setWeatherIcon(mainCondition) { hideWeatherIcon(); switch(mainCondition) { case "Thunderstorm": case "Extreme": $("#thunderstorm").show(); break; case "Drizzle": case "Rain": $("#rain").show(); break; case "Snow": $("#snowfall").show(); break; case "Clear": $("#sunny").show(); break; case "Clouds": $("#cloudy").show(); break; case "Additional": case "Atmosphere": $("#broken").show(); break; }
}
function toggleTemperature() { if($('#toggleButton').is(":checked")) { getWeather("&units=metric"); } else { getWeather("&units=imperial"); }
}
Developer | Markku Lehmonen |
Username | SharpDal |
Uploaded | November 30, 2022 |
Rating | 3 |
Size | 3,709 Kb |
Views | 16,192 |
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 |
A Pen by Markku Lehmonen | 7,804 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 |
Lazy Load for Background Images | The_ruther4d | 2,977 Kb |
Basic HTML5 Structure | YuvarajTana | 1,289 Kb |
Sticky menu on scroll | Senff | 2,869 Kb |
Weird glowy CSS3 game | Toneworm | 3,684 Kb |
Contact | GanNichiHa | 2,514 Kb |
A Pen by Mike Otis | Mikeotis | 3,185 Kb |
Search field | Jamesbarnett | 2,100 Kb |
Resizable SASS Icons | Marianarlt | 7,611 Kb |
Adding and Removing Element | Accimeesterlin | 2,119 Kb |
Marching Squares Visualized | Sakri | 7,074 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!