Weather web app - FreeCodeCamp challenge

Size
3,494 Kb
Views
8,096

How do I make an weather web app - freecodecamp challenge?

What is a weather web app - freecodecamp challenge? How do you make a weather web app - freecodecamp challenge? This script and codes were developed by Antonio Erdeljac on 06 December 2022, Tuesday.

Weather web app - FreeCodeCamp challenge Previews

Weather web app - FreeCodeCamp challenge - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Weather web app - FreeCodeCamp challenge</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"> </head> <body> <div class="container-fluid centerme"> <div class="col-lg-4 text-center" id="cels"> <i id="icon" class="fa fa-caret-left fa-3x"></i> </div> <div class="col-lg-4 text-center"> <div id="info" class=""> <i id="icon_w" class="fa fa- fa-3x"></i> <hr> <p id="temp" class="mt-3"></p> <p id="desc_p">Please remove HTTPS</p> <p style="font-size:15px;" class="text-muted">Created by <a target="_blank" style="text-decoration: none; color:gray" href="https://codepen.io/antonioerda/full/XpwLVw/"><b>Antonio Erdeljac</b></a></br> as a <a target="_blank" style="text-decoration: none; color:gray" href="https://freecodecamp.com"><b>FreeCodeCamp</b></a> challenge.</p> </div> </div> <div class="col-lg-4 text-center"> <i id="icon" class="fa fa-caret-right fa-3x"></i> </div> <!-- jQuery first, then Tether, then Bootstrap JS. --> <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script> </body>
</html> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Weather web app - FreeCodeCamp challenge - Script Codes CSS Codes

html, body { height: 100%; font-size: 30px;
}
.centerme { height: 100%; display: flex; align-items: center;
}
.fa-caret-left { transition: .2s; font-size: 90px; cursor: pointer;
}
.fa-caret-left:hover { font-size: 150px; opacity: .5;
}
.fa-caret-right { font-size: 90px; transition: .2s; cursor: pointer;
}
.fa-caret-right:hover { font-size: 150px; opacity: .5;
}

Weather web app - FreeCodeCamp challenge - Script Codes JS Codes

$(document).ready(function(){ var orig = $('#temp').css('width'); var orig_h = $('#temp').css('height'); $('.fa-caret-right').hover(function() { $(this).html('°F'); }, function(){ $(this).html(''); }); $('.fa-caret-left').hover(function() { $(this).html('°C'); }, function(){ $(this).html(''); }); $('.fa-caret-left').hide(); // USING API INSTEAD OF GEOLOCATION BC HTTPS :/ function ApiLokacija() { $.getJSON("http://ip-api.com/json/", function(data) { var lat = data.lat; var lng = data.lon; var city = data.city; link = 'http://api.openweathermap.org/data/2.5/weather?lat='+lat+'&lon='+lng+'&APPID=be12e1b92c1b5f03df965d424e4d6057'; link_celsius = link+'&units=metric'; link_fahrenheit = link+'&units=imperial'; function celsius() { $.getJSON(link_celsius, function(geo) { console.log(geo.main); var celsius = geo.main.temp+' °C'; var desc = geo.weather[0]["main"]; var print_d = geo.weather[0]["description"]; //var desc = 'Extreme'; print_d_d= print_d.charAt(0).toUpperCase() + print_d.slice(1); $('#desc_p').html(print_d_d); console.log(desc); if(desc == 'Drizzle' || desc == 'Rain') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-tint fa-3x'); } else if(desc == 'Thunderstorm') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-bolt fa-3x'); } else if(desc == 'Snow') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-snowflake-o fa-3x'); } else if(desc == 'Clear') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-sun-o fa-3x'); } else if(desc == 'Clouds') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-cloud fa-3x'); } else if(desc = 'Extreme') { $('#icon_w').removeClass(); $('#icon_w').addClass('fa fa-exclamation-triangle fa-3x'); } setTimeout(function() { $('#temp').html(city+', '+celsius).fadeIn(1000); }, 700); }); } function fahr() { $.getJSON(link_fahrenheit, function(geo) { console.log(geo.main); var fahrenheit = geo.main.temp+' °F'; var desc = geo.weather[0]["main"]; console.log(desc);
setTimeout(function() { $('#temp').html(city+', '+fahrenheit).fadeIn(1000); }, 700); }); } celsius(); $('.fa-caret-right').click(function() { $('#temp').animate({width: 250, opacity: 0},700); fahr(); $('#temp').animate({opacity: 1,width:orig},700); $('.fa-caret-right').fadeOut(); $('.fa-caret-left').fadeIn(); console.log('clicked'); }); $('.fa-caret-left').click(function() { $('#temp').animate({opacity:0,width:250},700); celsius(); $('#temp').animate({opacity: 1, width:orig},700); $('.fa-caret-left').fadeOut(); $('.fa-caret-right').fadeIn(); console.log('clicked'); }); }); }; ApiLokacija();
});
Weather web app - FreeCodeCamp challenge - Script Codes
Weather web app - FreeCodeCamp challenge - Script Codes
Home Page Home
Developer Antonio Erdeljac
Username antonioerda
Uploaded December 06, 2022
Rating 3
Size 3,494 Kb
Views 8,096
Do you need developer help for Weather web app - FreeCodeCamp challenge?

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!

Antonio Erdeljac (antonioerda) Script Codes
Create amazing love letters 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!