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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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'>
        <p>
          <span id='temp' class='results'></span>
          <span id='temp2' class='results'></span>
        </p>
      </div>
    </a>
    <div id='outlook' class='results'></div>
    <div id='location' class='results'></div>
    <div id='ide' class='results'></div>
  </div>
</div>
            
          
!
            
              body {
  background-color:grey;
  font-family: 'Baloo Tamma', cursive;
}
.header {
  font-size:4em;
  color:black;
}

.results {
  font-size:2em;
  color:black;
  margin:0.5em;
}

#tempChange {
  text-decoration:none;
}

#temp2 {
  display:none;
}

.app {
  border:20px solid black;
  border-radius:70px;
  background-color: white;
  margin-top:10%;
}
            
          
!
            
              $.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 = '';
    if(switchCase>=950)
          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>';
    else
          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;
  $('span').toggle();
  
  
});


            
          
!
999px
Loading ..................

Console