FreeCodeCamp - Local Weather App
How do I make an freecodecamp - local weather app?
What is a freecodecamp - local weather app? How do you make a freecodecamp - local weather app? This script and codes were developed by Jason Thomas on 14 September 2022, Wednesday.
FreeCodeCamp - Local Weather App - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>freeCodeCamp - Local Weather App</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://erikflowers.github.io/weather-icons/css/weather-icons.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> <div class="container"> <div id="temp-data" class="text-center"> <h2 class="display-4" id="city_name"></h2> <h2 class="display-4" id="wea_name"></h2> <p id="cloud"> </p> <p id="temper"> </p> <p id="highLow"> </p> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
FreeCodeCamp - Local Weather App - Script Codes CSS Codes
body { background-image:url(https://dl.dropboxusercontent.com/s/kitaidk2kngujoy/weather.png?dl=0); padding-top:20px;
}
@media (min-width: 500px) { .container{ max-width: 500px; }
}
.container{ background: rgba(247,247,247, .6); color: #4d4d4d; padding: 10px; border-style: dashed; border-width: 1px;
}
#min_temp { float:left;
}
#wea_name { color:#c6011f;
}
#cloud { font-size:3.4em;
}
#tempCel, #tempFar { font-size:3.4em; vertical-align:text-top; line-height:80%;
}
#bt2 { color:blue; padding:0px; border-style: none; background-color:transparent;
}
#bt2:disabled { color:#4d4d4d;
}
#bt1 { color:blue; padding:0px; border-style: none; background-color:transparent;
}
#bt1:disabled { color:#4d4d4d;
}
#cloud, #temper, #highLow { width:100%; display:block;
}
#butDiv {
}
FreeCodeCamp - Local Weather App - Script Codes JS Codes
/*some of the code below was originally writtern by Arijit Layek. https://codepen.io/alayek/pen/xwPzWb */
document.addEventListener( "DOMContentLoaded", function() { var $displayCity = $("#temp-data"); var $cityName = $("#city_name"); var $weatherName = $("#wea_name"); var $cloudDiv = $("#cloud"); //get geo location var geoUrl = "https://freegeoip.net/json/"; console.log("geoUrl: " + geoUrl); $.getJSON(geoUrl, function(data) { geoCity = data.city; console.log("geoCity: " + geoCity); var tempUrl = "https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text='" + geoCity + "') and u='c'&format=json"; $.getJSON(tempUrl, function(data) { var resultArr = []; for (var x in data.query.results.channel) { if (window.CP.shouldStopExecution(1)) { break; } resultArr.push([x, data.query.results.channel[x]]); } window.CP.exitedLoop(1); //weather icons var icon = '<i class="wi wi-yahoo-' + data.query.results.channel.item.condition.code + '"></i>'; //add text from apis to HTML $cityName.append( data.query.results.channel.location.city + ", " + data.query.results.channel.location.country ); $weatherName.append(data.query.results.channel.item.condition.text); $cloudDiv.append(icon); var $tempCel = '<span id="tempCel">' + Math.round( data.query.results.channel.item.condition.temp ) + '</span>'; var $tempFar = '<span id="tempFar">' + Math.round( data.query.results.channel.item.condition.temp * 9 / 5 + 32 ) + '</span>';
/*Add the celcius and fahrenheit buttons*/ $("#temper").append($tempCel + '<span id="butDiv"><button id="bt1" disabled="disabled">℃</button> | <button id="bt2">℉</button></span>' );
/*the buttons' functions are added*/ $("#bt1").click(function() { $(this).attr("disabled", "disabled"); $("#tempFar").remove(); $("#temper").prepend($tempCel); $("#bt2").removeAttr("disabled"); }); $("#bt2").click(function() { $(this).attr("disabled", "disabled"); $("#tempCel").remove(); $("#temper").prepend($tempFar); $("#bt1").removeAttr("disabled"); }); }); }); }, false
);
/*To do:
- Add highs and lows
- add forcast throughout the week
*/
Developer | Jason Thomas |
Username | samoht513 |
Uploaded | September 14, 2022 |
Rating | 3 |
Size | 3,093 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 |
FreeCodeCamp - Twitchtv API | 2,531 Kb |
FreeCodeCamp - Pomodoro Clock | 2,959 Kb |
FreeCodeCamp - Random Quote Generator | 3,218 Kb |
Html - canvas | 1,658 Kb |
FreeCodeCamp - Javascript Calculator | 1,907 Kb |
Freecodecamp - Tribute Page | 3,583 Kb |
FreeCodeCamp - Wikipedia Viewer | 2,692 Kb |
FreeCodeCamp - Local Weather App | 3,093 Kb |
FreeCodeCamp - Personal Portfolio | 4,512 Kb |
FreeCodeCamp - Simon Game | 4,301 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 |
Calculator | Rzencoder | 4,572 Kb |
Mega menu | DimaZubkov | 5,066 Kb |
Twitch API | Coderpilot | 3,412 Kb |
Pure CSS albums gallery | Renaudtertrais | 2,978 Kb |
Addthis_button | Esambino | 1,691 Kb |
Mosaic transition effect between two photos using jQuery | Stathisg | 2,518 Kb |
Search field | Jamesbarnett | 2,100 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Alumni ECA | MatheusLima92 | 3,777 Kb |
Mostly Fluid | Mccreath | 3,308 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!