Local Weather
How do I make an local weather?
Local Weather for FreeCodeCamp.. What is a local weather? How do you make a local weather? This script and codes were developed by Thomas Vaeth on 24 September 2022, Saturday.
Local Weather - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Local Weather</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="site-wrapper"> <div class="site-wrapper-inner"> <div class="cover-container"> <div class="inner cover"> <p class="cover-heading information"></p> <p class="lead"> <a class="btn btn-lg btn-default btn-check">Check Weather</a> <a class="btn btn-lg btn-default btn-celsius">Convert to Celsius</a> <a class="btn btn-lg btn-default btn-fahrenheit">Convert to Fahrenheit</a> </p> </div> </div> </div>
</div> <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Local Weather - Script Codes CSS Codes
.btn-celsius,
.btn-fahrenheit { display: none;
}
a,
a:focus,
a:hover { color: #fff;
}
.btn-default,
.btn-default:hover,
.btn-default:focus { color: #333; text-shadow: none; background-color: #fff; border: 1px solid #fff;
}
.information { font-size: 36px; font-weight: 600;
}
html,
body { height: 100%; background-size: cover; background-color: #333;
}
body { color: #fff; text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.site-wrapper { display: table; width: 100%; height: 100%; /* For at least Firefox */ min-height: 100%; -webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5); box-shadow: inset 0 0 100px rgba(0,0,0,.5);
}
.site-wrapper-inner { display: table-cell; vertical-align: top;
}
.cover-container { margin-right: auto; margin-left: auto;
}
.inner { padding: 30px;
}
.cover { padding: 0 20px;
}
.cover .btn-lg { padding: 10px 20px; font-weight: bold;
}
@media (min-width: 768px) { .site-wrapper-inner { vertical-align: middle; } .cover-container { width: 100%; }
}
@media (min-width: 992px) { .cover-container { width: 700px; }
}
Local Weather - Script Codes JS Codes
$.getJSON('http://ip-api.com/json', function(ipAddress) { $.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' + ipAddress.lat + '&lon=' + ipAddress.lon + '&appid=3695e5e886e4a1b016cf201000ec807e', function(forecast) { var celsius = forecast.main.temp - 273.15; var fahrenheit = celsius * 1.8 + 32; var backgroundPic = forecast.weather[0].icon.substring(0, 2); var $body = $('body'); if (backgroundPic === '01' || backgroundPic === '02' || backgroundPic === '03') { $body.css('background-image', 'url("https://images.unsplash.com/reserve/r7LctaT0SOu1JcXIkTjC_AaronGuzman_Clouds_IMG_7335.jpg?q=80&fm=jpg&s=d262b0d4178eaddf09d05110f8ed3e85")'); } else if (backgroundPic === '04') { $body.css('background-image', 'url("https://images.unsplash.com/uploads/14122598319144c6eac10/5f8e7ade?q=80&fm=jpg&s=46441177a47450220f89e7ddc122b723")'); } else if (backgroundPic === '09') { $body.css('background-image', 'url("https://images.unsplash.com/photo-1417008914239-59b898b49382?q=80&fm=jpg&s=1ba958b4a89112d5abd517bd0dd6c185")'); } else if (backgroundPic === '10') { $body.css('background-image', 'url("https://images.unsplash.com/photo-1430932670556-d0002ea51b33?q=80&fm=jpg&s=8a96081b174e74ada407e1a381efbbd4")'); } else if (backgroundPic === '11') { $body.css('background-image', 'url("https://images.unsplash.com/16/unsplash_5252b10dacd20_1.JPG?q=80&fm=jpg&s=d75af66bc685e7cabbbd7dbc3be699a9")'); } else if (backgroundPic === '13') { $body.css('background-image', 'url("https://images.unsplash.com/43/WrZ1xIWJQY6UB8MEbWTd_IMG_9088_edt.jpg?q=80&fm=jpg&s=822a1dfacdde42231add50fe8550ce87")'); } else if (backgroundPic === '50') { $body.css('background-image', 'url("https://images.unsplash.com/photo-1428200698796-38743f953a43?q=80&fm=jpg&s=ce2aa88f64ed5dfdad0d04c23c5a2753")'); } else { $body.css('background-image', 'url("http://www.splitshire.com/wp-content/uploads/2015/02/SplitShire-3935-1800x977-970x500.jpg")'); } $('.information').text('Hello ' + ipAddress.city + ' from Seattle.'); $('.btn-check').on('click', function() { $('.btn-check').hide(); $('.btn-celsius').show(); $('.information').text('The current temperature in ' + ipAddress.city + ' is ' + fahrenheit.toFixed(0) + ' degrees Fahrenheit.'); }); $('.btn-celsius').on('click', function() { $('.btn-celsius').hide(); $('.btn-fahrenheit').show(); $('.information').text('The current temperature in ' + ipAddress.city + ' is ' + celsius.toFixed(0) + ' degrees Celsius.'); }); $('.btn-fahrenheit').on('click', function() { $('.btn-fahrenheit').hide(); $('.btn-celsius').show(); $('.information').text('The current temperature in ' + ipAddress.city + ' is ' + fahrenheit.toFixed(0) + ' degrees Fahrenheit.'); }); });
});
Developer | Thomas Vaeth |
Username | thomasvaeth |
Uploaded | September 24, 2022 |
Rating | 3 |
Size | 3,137 Kb |
Views | 28,336 |
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 |
Flexbox Grid Animation | 4,299 Kb |
Twitch.tv | 3,413 Kb |
Button Draw on Hover Mixin | 58,405 Kb |
Calculator | 2,959 Kb |
Button Split Mixin | 2,543 Kb |
Image Loop on Hover | 6,080 Kb |
Flexbox Sticky Navigation | 135,492 Kb |
Instafetch.js Example | 3,245 Kb |
Flexbox Flex-Grow Mast | 2,773 Kb |
Pomodoro Clock | 3,136 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 |
Pictos font library from CodePen | Jstam | 3,790 Kb |
Webkit decolorize | Fivera | 1,675 Kb |
A Pen by Shidhin | Shidhincr | 5,015 Kb |
Minimal Material Design Form Input | Koenigsegg1 | 3,076 Kb |
Headroom.js demo | WickyNilliams | 3,982 Kb |
Degree Picker | Idered | 4,307 Kb |
Tab panels | Accessibility | 0 Kb |
Wrap_Test | Mscfourn | 7,503 Kb |
Classy Blockquote Styling | Andrewwright | 3,212 Kb |
Sort the Knowlege | Eprouver | 3,915 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!