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,184 |
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 - Simon Game | 4,301 Kb |
FreeCodeCamp - Random Quote Generator | 3,218 Kb |
FreeCodeCamp - Tic Tac Toe Game | 2,820 Kb |
FreeCodeCamp - Wikipedia Viewer | 2,692 Kb |
FreeCodeCamp - Javascript Calculator | 1,907 Kb |
FreeCodeCamp - Pomodoro Clock | 2,959 Kb |
FreeCodeCamp - Personal Portfolio | 4,512 Kb |
FreeCodeCamp - Twitchtv API | 2,531 Kb |
Freecodecamp - Tribute Page | 3,583 Kb |
Html - canvas | 1,658 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 |
CSS3 Snow Animation | NickyCDK | 1,695 Kb |
Loading Bar | Jaradlight | 2,333 Kb |
React Vote Component | Souporserious | 5,465 Kb |
Polo, the flying squirrel | Agbales | 2,445 Kb |
SVG hamburger menu button | Elifitch | 2,602 Kb |
Ionic - Wordpress REST API starter | Superpikar | 2,961 Kb |
Css Rotating 3d cubes different speed | Dghez | 2,364 Kb |
Factorial | KeithleySLHS | 1,158 Kb |
GrcJS | Vino6 | 2,047 Kb |
Twitch Live Channels | Inkblotty | 4,956 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!