cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <div class='container'>
  <div class='col-xs-12 col-sm-8 col-md-6 col-sm-offset-3 text-center app'>
    <h1 class='header'>Free Code Camp<br /> Weather App</h1>
    <div id='icon' class='results'></div>
    <a href='#' id=tempChange>
      <div class = 'row'>
          <span id='temp' class='results'></span>
          <span id='temp2' class='results'></span>
    <div id='outlook' class='results'></div>
    <div id='location' class='results'></div>
    <div id='ide' class='results'></div>
              body {
  font-family: 'Baloo Tamma', cursive;
.header {

.results {

#tempChange {

#temp2 {

.app {
  border:20px solid black;
  background-color: white;
              $.getJSON('http://ipinfo.io', function(data){
  var city = data.city + ', ' + data.country;
  var query = "http://api.openweathermap.org/data/2.5/weather?q=" + city +"&appid=343cfc83d30ae3ad205f5745debe351e";
  $.get(query, function(results){  
    var temp = results.main.temp;
    var tempCel = temp - 273.15;
    var tempFar = temp * 9/5 - 459.67;
    var finalTemp = tempCel.toPrecision(3);
    var finalTemp2 = tempFar.toPrecision(3);
    var description = results.weather[0].main;
    var switchCase = results.weather[0].id;
    var iconPrint = '';
          iconPrint = '<i class="fa fa-sun-o fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=900 && switchCase<950)
          iconPrint = '<i class="fa fa-exclamation-triangle fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=801 && switchCase<900)
          iconPrint = '<i class="fa fa-cloud fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=800)
          iconPrint = '<i class="fa fa-sun-o fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=700 && switchCase<800)
          iconPrint = '<i class="fa fa-cloud fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=600 && switchCase<700)
          iconPrint = '<i class="fa fa-cog fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=500 && switchCase<600)
          iconPrint = '<i class="fa fa-tint fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=300 && switchCase<500)
          iconPrint = '<i class="fa fa-tint fa-4x" aria-hidden="true"></i>';
    else if(switchCase>=200 && switchCase<300)
          iconPrint = '<i class="fa fa-bolt fa-4x" aria-hidden="true"></i>';
          iconPrint = 'Error';
    document.getElementById('temp').innerHTML = finalTemp + '&#176; C';
    document.getElementById('temp2').innerHTML = finalTemp2 + '&#176; F';
    document.getElementById('outlook').innerHTML = description;
    document.getElementById('icon').innerHTML = iconPrint;
  document.getElementById('location').innerHTML = city;

$('#tempChange').click(function() {
  var input = document.getElementById('temp').value;

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................