Pen Settings

HTML

CSS

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

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
    <div class="container-fluid">
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">Local Weather</a>
                </div>
                <ul class="nav navbar-nav">
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#" id='toggle'><span class="cloud"><i class="fa fa-cloud" aria-hidden="true"></i></span> Celsius/Fahrenheit</a></li>
                </ul>
            </div>
        </nav>
        <div class="spacer"></div>
        

        <div class="block">
          <div id= "response">
            <h1 class="text-center"><span id="currentTemp">...</span></h1>
            <h1 class="text-center"><span id="currentConditions">...</span></h1><br>
            Country name: <span id="country"></span><br> City: <span id="city"></span><br> Latitude: <span id="latitude"></span><br> Longitude: <span id="longitude"></span><br>
        </div>


        <div class='spacer'></div>
    </div>
    <!-------Footer---------->
    <div class="spacer"></div>
  <footer>
  <div  class="footer">
    <div class="container-fluid text-center">
  <div class="footer-text text-muted row"> Copyright &copy; <script>document.write(new Date().getFullYear());</script>  Developed for the FreeCodeCamp Front-end Development Challenges </div>
    <div class="footer-logos row">
      <a href="https://www.linkedin.com/in/nadia-ardon-5a021772" target="_blank"><i class="fa fa-linkedin"></i></a>
      <a href="https://github.com/npardon" target="_blank"><i class="fa fa-github"></i></a>
      <a href="https://www.freecodecamp.org/npardon" target="_blank"><i class="fa fa-fire"></i></a>
      <a href="https://codepen.io/npardon/#" target="_blank"><i class="fa fa-codepen"></i></a>
      
    </div>
  </div>

</div>
</footer>
<!-------footer end ------------------>
</div>
</body>

       
        
              
            
!

CSS

              
                .block {
background-color: #DFF3E3;
opacity: .70;
color:#68F40A; 
padding: 20%;
width: 50%;
margin-right: auto;
margin-left: auto;
border-radius: 20px;
font-size:1em;
padding-bottom: 10px;
}

.spacer{
	padding: 5%
}
body{
background:no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size:cover;
background-size: cover;

}

/*----------footer-------*/

.footer {
  background-color: #000000;
}
#footer {
  background-color: #000000;
  border-top: 1px solid black;
  bottom: 0;
  font-size: 12px;
  font-weight: normal;
  margin-top: 5em;
  min-width: 320px;
  padding: 1em 1em 0 1em;
  position: absolute;
  width: 100%;
}

.footer-logos {
  font-size: 14px;
  margin-top: -1em;
}

.footer-logos a {
  text-decoration: none;
}

.footer-logos i {
  border: 1px solid rgb(130,14,248);
  border: 1px solid rgb(92,14,250);
  border-radius: 25%;
  color: #4B144C;
  margin: 0 0 1em 1em;
  padding-top: .25em;
  text-align: center;
  vertical-align: -1.5em;
}

.footer-logos .genericon {
  height: 1.6em;
  width: 1.6em;
}

.footer-logos .fa {
  height: 1.75em;  
  width: 1.75em;
}
              
            
!

JS

              
                $(function(){
  
    var api="https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=c3a54977f0f3d2c9556b4d1e1bdee268"; 
    var apiKey = 'c3a54977f0f3d2c9556b4d1e1bdee268';
  //var lat;
  //var long;
  var C =false; 
  var apiData;
  var data;
  var id;

  
  
  function displayTemp(fTemp, c){
    if (c) return Math.round((fTemp-32)*(5/9)) + '&deg; c';
    return Math.round(fTemp) + '&deg; F';
  }
  
function response(data, C){
             var currentLocation=data.name;
              var currentConditions=data.weather[0].description;
              var currentTemp= displayTemp (data.main.temp,C);
              var icon=  data.weather[0].icon;
              var apiData=data;
                              
              $('#currentTemp').html(currentTemp);
              $('#currentConditions').html(currentConditions);
                 
              var iconSrc= "https://openweathermap.org/img/w/" + icon + ".png"; 
                
              $('#currentTemp').prepend('<img src=' + iconSrc + '>');
}

$('#submit weather').click(function(){
  var city = $('#city').val();
  if(city != ''){
  $.ajax({
    url: 'https//api.openweathermap.org/data/2.5/weather?q=' + city + "&units=imperial" + '&type=accurate' + callback + "&APPID=c3a54977f0f3d2c9556b4d1e1bdee268",
        type: 'GET',
        datatype: 'jsonp',
        success: function(data){
          var widget = show(data);
          $("#resonse").html(widget);
         $('#city').val('');
        }
  }); 
  } 
  });

  
  
 backgroundImg = [
        'https://c2.staticflickr.com/4/3046/2804916709_6e37da6cc4_b.jpg',
        'https://upload.wikimedia.org/wikipedia/commons/8/8d/Here_comes_rain_again.jpg',
        'https://static.pexels.com/photos/81769/rain-green-trees-water-81769.jpeg',
        'http://maxpixel.freegreatpicture.com/static/photo/1x/Snow-Nature-Winter-Landscape-Cold-Sunny-Day-1891364.jpg',
        'https://upload.wikimedia.org/wikipedia/commons/3/30/A_foggy_day_in_Pathriata.JPG',
        'https://static.pexels.com/photos/440731/pexels-photo-440731.jpeg',
        'https://upload.wikimedia.org/wikipedia/commons/6/6b/Cloudy_Day_01.jpg',
        'https://images.pexels.com/photos/89010/pexels-photo-89010.png?w=940&h=650&auto=compress&cs=tinysrgb'
 
   ];
  
  
  
 $.getJSON('https://freegeoip.net/json/') 
     .done (function(location)
     {
         $('#country').html(location.country_name);
          $('#city').html(location.city);
          $('#latitude').html(location.latitude);
          $('#longitude').html(location.longitude);
          $('#ip').html(location.ip);
          
          
   
        
   
              $.getJSON('https://api.openweathermap.org/data/2.5/weather?lat='+location.latitude+'&lon='+location.longitude+'&units=imperial&appid=c3a54977f0f3d2c9556b4d1e1bdee268', function(data){//--->USE HTTPS^

                //console.log(data);//Success!!!

                apiData=data;
                
                response (apiData,C);
                
                $('#toggle').click(function(){
                    C = !C;
                    response(data,C);          
                });
               
                var id = data.weather[0].id,
                bgIndex,
                backgroundId = [299, 399, 599, 699, 799, 800, 899, 905];



            backgroundId.push(id);
            bgIndex = backgroundId.sort().indexOf(id);

            $('body').css('background-image', 'url(' + backgroundImg[bgIndex] + ')'); 
                
               });
   
   
   

   
     });
  
          
  
});

              
            
!
999px

Console